vm-implementation

Whats the best way to learn about VM implementation besides actually hacking code?

痞子三分冷 提交于 2019-12-31 12:08:31
问题 I'd like to learn more about VM implementation and optimization. Right now I'm contributing (in a small way) with JRuby and am also playing/writing with my own lisp-like language implementation that runs in a VM. However I'd like to get more information on working with VM's and designing them. Is there a good resource for this type of information besides reading/working with existing code? I'm not opposed to do that, I just wondered if there were other sources I could be looking into. 回答1:

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

坚强是说给别人听的谎言 提交于 2019-12-29 11:35:07
问题 I was thinking that JIT compilers will eventually beat AOT compilers in terms of the performance of the compiled code, due to the inherent advantage of JIT (can use information available only at runtime). One argument is that AOT compilers can spend more time compiling code, but a server VM could spend a lot of time, too. I do understand that JIT does seem to beat AOT compilers in some cases, but they still seem to lag behind in most cases. So my question is, what are the specific, tough

Why does python VM have co_names instead of just using co_consts?

妖精的绣舞 提交于 2019-12-23 10:55:14
问题 A code object generated by Python compiler contains a tuple of constants used in the instructions (named co_consts ) and also a tuple containing names (named co_names ). Why having two distinct lists? Wouldn't be simpler to just use co_consts for names too? 回答1: Consider the following function. def f(x): x += n return x * 4 Here x is a local name, its value can change. 4 is a constant. Its value will never change. However, it's still an object and it's better to cache them rather than create

How does a Java virtual machine implement the “happens-before” memory model?

…衆ロ難τιáo~ 提交于 2019-12-22 05:58:22
问题 Java's memory model is based on "happens-before" relationship that enforces rules but also allows for optimization in the virtual machine's implementation in terms of cache invalidation. For example in the following case: // thread A private void method() { //code before lock synchronized (lockA) { //code inside } } // thread B private void method2() { //code before lock synchronized (lockA) { //code inside } } // thread B private void method3() { //code before lock synchronized (lockB) { /

Is the CLR a virtual machine?

一世执手 提交于 2019-12-17 08:13:32
问题 I read a book which referred to the .net CLR as a virtual machine ? Can anyone justify this? What is the reason we need the concept of virtual machines on some development platforms? Isn't it possible to develop a native framework [one without virtual machine] that is fully object oriented and as powerful as .net? The book which refers to CLR as virtual machine is " Professional .Net Framework 2.0 ". 回答1: There are a lot of misconceptions here. I suppose you could think of .Net as a virtual

Is the CLR a virtual machine?

为君一笑 提交于 2019-12-17 08:12:26
问题 I read a book which referred to the .net CLR as a virtual machine ? Can anyone justify this? What is the reason we need the concept of virtual machines on some development platforms? Isn't it possible to develop a native framework [one without virtual machine] that is fully object oriented and as powerful as .net? The book which refers to CLR as virtual machine is " Professional .Net Framework 2.0 ". 回答1: There are a lot of misconceptions here. I suppose you could think of .Net as a virtual

How can a JVM decide if a class “belongs” (e.g. inner or nested classes) to another class?

佐手、 提交于 2019-12-12 08:09:03
问题 I want to understand class files and inner/nested classes a bit better and I'm wondering about the following things: Is the InnerClasses attribute used to refer tothe inner/nested classes in the ´containing´ class or is it used in the inner/nested classes to refer to the ‘container’ class? Is the InnerClasses attribute in class files sufficient? E.g. Do inner/nested classes have to follow the name mangling with $ or is this just a convention? Is there a way to make a class look like an inner

How to simulate a call stack in JavaScript using only a single array

回眸只為那壹抹淺笑 提交于 2019-12-11 16:04:46
问题 I am looking at the Wikipedia page on Call Stack, and trying to grok this image: This is as far as I get lol: const memory = [] memory[0] = 3 // top of stack pointer memory[1] = 4 // stackframe pointer memory[2] = 1000 // max call stack size memory[3] = 5 // first frame memory[4] = 0 // first frame return address (exit let's say) But let's say we have 2 actions: add == 1 , and load == 2 , plus whatever is required to do the stack manipulation. How do i feed it a stream of data to execute some

How I get the value from the Immediate part of a 32 Bit sequence in C?

谁说胖子不能爱 提交于 2019-12-11 11:58:09
问题 I built a virtual machine in C. And for this I have the Instruction pushc <const> I saved the command and the value in 32 Bit. The First 8 Bit are for the command and the rest for the value. 8 Bit -> Opcode 24 Bit -> Immediate value For this I make a macro #define PUSHC 1 //1 is for the command value in the Opcode #define IMMEDIATE(x) ((x) & 0x00FFFFFF) UPDATE: **#define SIGN_EXTEND(i) ((i) & 0x00800000 ? (i) | 0xFF000000 : (i))** Then I load for testing this in a unsigned int array: Update:

Contents of Stack Frame in Java

血红的双手。 提交于 2019-12-10 09:29:07
问题 It is evident from Java Virtual Machine Implementation (http://docs.oracle.com/javase/specs/jvms/se7/html/index.html) that stack frame present on heap which stores the method's runtime data. But what are the contents of stack frame in java and how the stack frame is organized to store values of local variables and intermediate results. How is the data structure organized. 回答1: First of all, stack frame is part of JVM stack, not Heap [JVM memory is divided in 5 parts: Method Area, Heap, Stack,