Tutorial/resource for implementing VM

I assume you want a virtual machine rather than a mere interpreter. I think they are two points on a continuum. An interpreter works on something close to the original representation of the program. A VM works on more primitive (and self-contained) instructions. This means you need a compilation stage to translate the one to … Read more

What are the primitive Forth operators? [closed]

This thread covers your exact question. Here is a soup-to-nuts implementation with complete documentation. I wrote a subroutine threaded Forth targeting 68K when I was in college. I defined the runtime environment and dictionary format, then wrote some C code that boot strapped a Macintosh application that loaded a default dictionary, populated some I/O vectors … Read more

Why is it hard to beat AOT compiler with a JIT compiler (in terms of app. performance)?

There’s a definite trade-off between JIT and AOT (ahead-of-time) compilation. As you stated, JIT has access to run-time information that can aid in optimization. This includes data about the machine it’s executing on, enabling platform-specific native optimization. However, JIT also has the overhead of translating byte-code to native instructions. This overhead often becomes apparent in … Read more

Differences between Just in Time compilation and On Stack Replacement

In general, Just-in-time compilation refers to compiling native code at runtime and executing it instead of (or in addition to) interpreting. Some VMs, such as Google V8, don’t even have an interpreter; they JIT compile every function that gets executed (with varying degrees of optimization). On Stack Replacement (OSR) is a technique for switching between … Read more

Is the CLR a virtual machine?

There are a lot of misconceptions here. I suppose you could think of .Net as a virtual machine if you really wanted, but let’s look at how the .Net Framework really handles your code. The typical scenario looks like this You write a .Net program in C#, VB.Net, F#, or some other compatible language. That … Read more

What is the purpose of the Java Constant Pool?

Constant pool is a part of .class file (and its in-memory representation) that contains constants needed to run the code of that class. These constants include literals specified by the programmer and symbolic references generated by compiler. Symbolic references are basically names of classes, methods and fields referenced from the code. These references are used … Read more

Why is the JVM stack-based and the Dalvik VM register-based?

There are a few attributes of a stack-based VM that fit in well with Java’s design goals: A stack-based design makes very few assumptions about the target hardware (registers, CPU features), so it’s easy to implement a VM on a wide variety of hardware. Since the operands for instructions are largely implicit, the object code … Read more