JIT 23 2 2
1 3 1.1............................ 3 1.2.......................... 3 2 5 2.1.............................. 5 2.1.1............................... 5 2.1.2.................... 5 2.1.3................... 7 2.1.4.......................... 9 2.1.5............................. 12 2.2 JIT.............................. 13 2.2.1.......................... 13 2.2.2......................... 14 2.3 Java............................. 17 2.3.1............................. 17 2.3.2.............. 18 2.3.3...................... 20 3 22 3.1.............................. 22 3.2............................... 22 4 24 4.1.............................. 24 4.2......................... 26 4.3............................... 26 4.4......................... 30 5 32 5.1.............................. 32 5.2................................. 32 1
6 37 7 40 8 42 9 44 10 46 2
1 1.1 Java JIT SableVM Java JIT JavaScript ( ) TraceMonkey FireFox 1.2 Java JIT Java 3
Java Java Java 4
2 2.1 2.1.1 2.1.2 VM 5
Java 2.1: 6
2.1.3 goto 2.2: 7
GCC GCC 2.2 8
2.1.4 2.3: 9
2.4: 1 ( ) jump call 10
PC C C ( gcc x86 ) C START END C 11
2.1.5 2.5: 12
2.2 JIT 2.2.1 JIT JIT ( ) VM JIT VM 13
2.6: 2.2.2 VM 14
2.7: 15
2.8: JavaScript TraceMonkey JIT Java 16
2.3 Java 2.3.1 Java Java JavaVM Java Java Java Java class ( ) class Java Java class Java Java OS 17
C Java 2.3.2 JavaVM Java Java Java Java JavaVM JavaVM Java Java JavaVM Java JavaVM Java JavaVM 0 18
2.9: Java 19
2.3.3 Java C++ iload 1 ; // iload 2 ; // iadd ; 20
2.10: 21
3 Java JavaScript JIT Java Java 3.1 Java Java SableVM SableVM SableVM 3.2 istore iload 22
23
4 4.1 24
25
4.2 TraceMonkey JIT 4.3 istore iload istore iload (iload INLINED_START_ILOAD ) INLINED_START_ 26
/* ----------------------------------------------- ISTORE ----------------------------------------------- */ case SVM_INSTRUCTION_ISTORE: { env->vm->instructions[instr].param_count = 1; /* implementation address */ env->vm->instructions[instr].code.implementation = &&START_ISTORE; env->vm->instructions[instr].inlined_code.implementation = &&INLINED_START_ISTORE; /* code size */ env->vm->instructions[instr].inlined_size = ((char *) &&END_ISTORE) - ((char *) &&INLINED_START_ISTORE); /* can the implementation be relocated? */ env->vm->instructions[instr].flag = SVM_INLINEABLE_ISTORE; #if!defined(ndebug) defined(_sablevm_inlinability_testing) strcpy (env->vm->instructions[instr].name, "ISTORE"); #endif break; START_ISTORE: { #ifndef NDEBUG if (env->vm->verbose_instructions == JNI_TRUE) { _svmf_printf (env, stderr, "T%d: [verbose instructions: executing @%p ISTORE]\n", env->thread.id, (void *) (pc - 1)); 27
} #endif } INLINED_START_ISTORE: { _svmm_verbose_instructions_inlined (env, pc, "ISTORE"); /* instruction body */ { } jint indx = (pc++)->jint; locals[indx].jint = stack[--stack_size].jint; } { } END_ISTORE: /* dispatch */ goto *((pc++)->implementation); } 28
INLINED_START_ILOAD: { _svmm_verbose_instructions_inlined (env, pc, "ILOAD"); /* instruction body */ { } jint indx = (pc++)->jint; stack[stack_size++].jint = locals[indx].jint; } { } END_ILOAD: /* dispatch */ goto *((pc++)->implementation); } istore integer pop iload integer push istore iload integer pop push isl istore iload istore iload isl 29
4.1: istore,iadd 4.4 istore iload istore isl isl iload 30
isl iload iload 4.2: isl 31
5 5.1 goto goto JIT prepare_code.c 5.2 isl 32
/* --------------------------------------------------------- ISL --------------------------------------------------------- */ case SVM_INSTRUCTION_ISL: { env->vm->instructions[instr].param_count = 1; /* implementation address */ env->vm->instructions[instr].code.implementation = &&START_ISL; env->vm->instructions[instr].inlined_code. implementation = &&INLINED_START_ISL; /* code size */ env->vm->instructions[instr].inlined_size = ((char *) &&END_ISL) - ((char *) &&INLINED_START_ISL); /* can the implementation be relocated? */ env->vm->instructions[instr].flag = SVM_INLINEABLE_ISTORE; #if!defined(ndebug) defined(_sablevm_inlinability_testing) strcpy (env->vm->instructions[instr].name, "ISL"); #endif break; START_ISL: { #ifndef NDEBUG if (env->vm->verbose_instructions == JNI_TRUE) { _svmf_printf (env, stderr, "T%d: [verbose instructions: executing @%p ISL]\n", env->thread.id, (void *) (pc - 1)); 33
} #endif } INLINED_START_ISL: { _svmm_verbose_instructions_inlined (env, pc, "ISL"); /* instruction body */ { } } jint indx = (pc++)->jint; locals[indx].jint = stack[stack_size-1].jint; pc = pc + 2; { } END_ISL: /* dispatch */ goto *((pc++)->implementation); } integer pop push Java load 34
5.1: isl case SVM_INSTRUCTION_ISTORE: { instructions[instruction_index].data.arg.index = bytecode[pc+1]; jint test = bytecode[pc+1]; if(bytecode[pc+2]==svm_instruction_iload){ jint test2 = bytecode[pc+3]; if (test == test2){ method->data.code_attribute->code[pc] = SVM_INSTRUCTION_ISL; pc = pc+2; } } } break; istore iload istore isl 35
SVM_INSTRUCTION_ISL 36
6 SableVM SableVM 6.1 6.1 a SableVM b SableVM 6.1: 37
6.2: SableVM 3 SableVM 38
6.3: 39
7 SableVM SableVM SableVM SableVM 40
41
8 8.1 JavaVM SableVM JavaVM SableVM SableVM SableVM 8.2 42
43
9 Analyzing the Performance of Code-copying Virtual Machines :Gregory B. Prokopski, Clark Verbrugge Trace-based Just-in-Time Type Specialization for Dynamic Languages :Andreas Gal Effective Inline-Threaded Interpretation of Java Bytecode Using Preparation Sequences :Etienne Gagnon, Laurie Hendren Tracing for Web 3.0 :Mason Chang A Portable Research Framework For The Execution Of Java Bytecode :Etienne Gagnon SableVM: A Research Framework for the Efficient Execution of Java Bytecode :Etienne M. Gagnon, Laurie J. Hendren Optimizing Indirect Branch Prediction Accuracy in Virtual Machine Interpreters :Kevin Casey Optimizing code-copying JIT compilers for virtual stack machines :Devid Gregg, M. Anton Ertl Incremental Dynamic Code Generation with Trace Trees :Andreas Gal, Michael Franz TraceMonkey Technology Summary :Tomoya Asai http://mozilla.jp/blog/entry/3800/ Java Virtual Machine :Jon Meyer, Troy Downing Java :, Algebraic characterization of trace and decorated trace equivalences over tree-like structures :Xiao Jun Chen, Rocco de Nicola Speeding up the Synthesis of Programs from Traces :A. W. Biermann, R. I. Baum, F. E. Petry 44
Analyzing the performance of code-copying virtual machines :Gregory B. Prokopski, Clark Verbrugge 45
10 sablevm PDF CD 46