Skip to main content
14 votes
Accepted

Is a call stack required for robust computer architecture?

... which makes me wonder if there are any systems / architectures for defining a virtual machine without a call stack Continuation Passing Style enables tail call optimization for all function ...
Erik Eidt's user avatar
  • 34.8k
11 votes

How are "registers" implemented in VMs?

JVM and .NET both employ "JIT"'s. These JITs take their respective byte code (both stack-based) and translate them into machine code for the processor they're on.  Thus, the same hardware that ...
Erik Eidt's user avatar
  • 34.8k
11 votes

Why are most language virtual machines designed with a load/store architecture? Is there a speed advantage vs. a register-memory architecture?

There are a variety of VMs, including VMs that use “registers”. However, the point of the VM is that it abstracts over physical machines so the VM will likely not limit the number of registers! Such ...
amon's user avatar
  • 136k
10 votes
Accepted

Why is it difficult to create a truly portable garbage collector for C?

Garbage collection requires the possibility to find objects in memory that are no longer used. One way of doing it is to have a marking algorithm that goes through all the active references. Another ...
Christophe's user avatar
  • 82.2k
6 votes

Why are most language virtual machines designed with a load/store architecture? Is there a speed advantage vs. a register-memory architecture?

The idea is that the code for your virtual machine is not interpreted, but compiled at runtime into machine code for the real machine. A register/memory approach makes it harder to translate into ...
gnasher729's user avatar
  • 49.4k
6 votes
Accepted

GCC or Clang to output bytecode for a VM?

I would strongly advocate for LLVM. LLVM is the future, and IMHO is favorable for new compiler implementations compared to GCC. Here's why: Modularity: LLVM is a modular compiler framework, much ...
valiano's user avatar
  • 222
6 votes

What is the best way to run untrusted hooks/plugins?

If you do not trust the code, do not execute it - period. If you wish to trust the code. Constrain what is permitted as code reject specific operations such as eval(...) reject unbounded loops reject ...
Kain0_0's user avatar
  • 16.6k
6 votes
Accepted

To show the difference between system VMs and JVMs

It's fine as is, if you think about it the right way. You can think of a Virtual Machine as a task running on the hypervisor. They get context switched nearly the same way after all. Tasks and Apps ...
candied_orange's user avatar
6 votes
Accepted

Use of globals in stack-based virtual machine implementation

Usage of globals is a matter of scope of the program "around" them. If this "stack-based virtual machine" is the whole program, and the statement "...variables are used by ...
Doc Brown's user avatar
  • 220k
5 votes
Accepted

Why do we need nginx server on top of linux server?

Very roughly: A Linux system speaks UNIX. It gives you the ability to run UNIX programs by offering the syscalls open(), malloc(), socket() etc. etc. A web server like nginx speaks HTTP - it ...
Kilian Foth's user avatar
5 votes
Accepted

How should a bytecode VM call external C functions?

Exactly, you can obtain function pointers via dlsym() and then call them – but how to perform the call depends on the function's calling convention. In theory you could write some assembly to bridge ...
amon's user avatar
  • 136k
4 votes

Help With Memory Mapped I/O and Hardware Interrupts for Virtual Machine

The part I'm not sure about is exactly how interrupts work and how I can have my processor jump in the middle of an instruction to deal with an interrupt. The basic idea you already have is that the ...
Erik Eidt's user avatar
  • 34.8k
4 votes
Accepted

What is the minimum set of operations a language implementation must provide for it to be usable for all applications?

Step 1: determine which platform/operating system you are targetting. Step 2: offer access to the full capabilities of that platform. For example: If you are developing a language that is supposed ...
amon's user avatar
  • 136k
4 votes
Accepted

Is there any reason I shouldn't use a LInux host for a Linux guest VM?

Using a Linux-on-Linux virtual machine is perfectly fine and can make sense for better configuration management. For example, you can keep a fairly stable, lean, and secure host system like Debian and ...
amon's user avatar
  • 136k
3 votes
Accepted

How is an async stack implemented?

If I understand correctly, you are trying to implement fibers in JavaScript. If I am wrong, then you just need to look how the JavaScript event loop works. Instead of fibers, you can have promises. As ...
Theraot's user avatar
  • 9,261
3 votes

Is a call stack required for robust computer architecture?

I do not think robustness is an issue here. Functionality is, in the most literal sense. Forget implementation details for a moment and consider what a call stack is, really. It allows you to call ...
Martin Maat's user avatar
  • 18.6k
3 votes
Accepted

Why do some VMs manage their own memory instead of relying fully on the system allocator?

One reason is that applications, being higher level, know their requirements better than the underlying system.  For example, if the application is doing garbage collection, that benefits greatly ...
Erik Eidt's user avatar
  • 34.8k
3 votes
Accepted

What is the best way to run untrusted hooks/plugins?

Python has no security model that would allow you to safely execute untrusted code. If you want to execute untrusted Python code you need to apply operating system level safety measures, for example ...
amon's user avatar
  • 136k
3 votes

GCC or Clang to output bytecode for a VM?

Between GCC and LLVM, I'd suggested looking at LLVM first. GCC is apparently known to be cumbersome to develop, whereas some of LLVM's code was specifically written in reaction to that very same ...
aerohammer's user avatar
3 votes
Accepted

How can I access attached data section in custom script language?

Plain bytes don't carry any types. Instead, the operations on these bytes impose an interpretation of this data. Most instruction sets have different instructions for performing the same operation but ...
amon's user avatar
  • 136k
3 votes

Virtualization vs Container

The question is no longer accurate. Today containerization as defined by the Open Container Initiative (which includes Docker) is a means of hosting complex applications as if they were individual ...
Berin Loritsch's user avatar
3 votes

How to model opcodes effectively for a language VM?

Practical instruction sets tend to use variable length instructions, which has a number of advantageous consequences: You can include immediate values directly with the instructions, without having ...
amon's user avatar
  • 136k
2 votes

How do interpreters and VM print?

I would like to take Python as an example. In CPython we have a print statement represented by PRINT_ITEM VM instruction. Then we have a print() function which (sic!) I believe calls directly or not ...
Netch's user avatar
  • 1,560
2 votes

How does a stack VM manage with only one stack?

Why: Because it's simple & efficient. When you have only one stack, you don't have to do anything for your stack memory management. All the things you have to do is allocate one big chunk of ...
付和雷同's user avatar
2 votes
Accepted

Sharing virtual box / environment?

There is no need for a “cloud” environment at all. Every developer should have their own development environment. This may be local or on a server, and this may or may not be a virtual machine. The ...
amon's user avatar
  • 136k
2 votes

Is comparing "dollar-hours" for running a specific piece of code practical as an estimate of rented system performance?

Yes, but they are called dollars, not dollar-hours. You are not multiplying cents and minutes; you are multiplying cents per hour, and minutes. The time units cancel out and give you cents. 7.5 ...
Stack Exchange Broke The Law's user avatar
2 votes
Accepted

OS tax in dockerized production environment

It doesn't sound to me like the quoted bit isn't saying "4 instances of the same application", rather it's "4 different applications". But the question of why you might want to run multiple copies of ...
autophage's user avatar
  • 880
2 votes

How can one bake a GUI framework inside an interpreter without freezing the interpreter?

once you call the C function g_application_run, the thread enters an endless listening loop inside GTK. That is only part of what happens. What you have to do here first is to register callbacks for ...
Doc Brown's user avatar
  • 220k

Only top scored, non community-wiki answers of a minimum length are eligible