编辑: sunny爹 | 2017-09-03 |
3198 16 What'
s?New?in?1.4 ? Low-level Intermediate R epresentation ? Deoptimization ? Inlining ? Improved D ebugging and P rofiling S upport S ession
3198 17 Deoptimization?and?Inlining ? 1.3.x client compiler inlined simple accessors ? 1.4 uses deoptimization and C HA C More inlining possibilities ? 1.4.0 client compiler does not inline: C Methods with exception handlers C S ynchronized methods S ession
3198 18 Improved?Debugging?and?Profiling ? F ull-speed debugging C C ompiler no longer disabled when using debuggers (-Xdebug) C Application runs at full speed ? Breakpoint setting causes deoptimization C S erver compiler support coming in 1.4.1 ? P rofiling C S ubstantial work on J VM P I robustness C E xisting tools work much better with 1.4 S ession
3198 19 Structure?of?the?Client?Compiler ? R epresentation of bytecodes ? F rontend ? Backend ? Machine code generation S ession
3198 20 Representation?of?Code ? High Level Intermediate (HIR ) C C losely mimics bytecode C Directed graph to enforce evaluation order ? Low Level Intermediate (LIR ) C C lose to machine instructions C S ome high level instructions ? Virtual calls ? T ype checks ? Intrinsics S ession
3198 21 Frontend ? P arse bytecodes into HIR C E liminate loads (copy propagation) C Local value numbering C C onstant folding and identities C Inline C Use C HA to optimize calls ? G lobal O ptimizations C Block merging C E liminate null checks S ession
3198 22 Intermediate?Representation basic block instructions successor(s) CFG Bytecodes
0 aload_1
1 bipush
46 3 invokevirtual #139
6 istore_2
7 iload_2
8 ifgt
18 11 aload_0
12 getfield #2
15 invokevirtual #93
18 aload_1
19 iconst_0
20 ... S ession
3198 23 Backend ? G enerate LIR by walking HIR C E xpression level register allocation ? O ptimize LIR C Assign locals to registers ? Loop focused C P eephole optimizer ? E mit machine code from LIR C G enerate object maps for use by G C C G enerate information for deoptimization S ession
3198 24 Code?Generation Machine code: movl %edi,%eax movl 0x4,%esi cmpl 0x80000000,%eax jne -0x252e6b7b xorl %edx,%edx cmpl -1,%esi je -0x252e6b78 cltd idivl %esi,%eax cmpl 0,%eax movl 0x0,%esi jne -0x252e6b65 movl 0x1,%esi movl %esi,%eax movl %ebp,%esp popl %ebp ret LIR: label [label:0x8176838] move [edi|I] [eax|I] move [int:4|I] [esi|I] idiv [eax|I] [esi|I] [edx|I] [eax|I] [bci:8] cmp [eax|I] [int:0|I] move [int:0|I] [esi|I] branch [NE] [label:0x8182d60] move [int:1|I] [esi|I] label [label:0x8182d60] move [esi|I] [eax|I] return [eax|I] S ession
3198 25 Quick?Summary ? F rontend does C P arse and analyze bytecodes C Build and optimize IR C Use C HA for very effective O O optimizations C R eorder C F G for code generation ? Backend does C LIR C R egister allocation, low-level optimizations C C ode generation S ession
3198 26 Implications?for?Code?Written?in? the?Java??Programming?Language ? Accessors ? Usage of final ? O bject Allocation (new) ? E xception Handling ? O ther Issues ? Q uick S ummary S ession
3198 27 Accessors ? Use accessors C XType getX() { return _x;
} C void setX(XType x) { _x = x;
} ? Abstracts from implementation ? E asier to maintain ? No performance penalty C Inlining! S ession
3198 28 Usage?of?final ? Don'
t use final for performance tuning ? C HA will do the work C Where C HA can'
t do it, final doesn'
t help either ? K eep software extensible ? No performance penalty C S tatic calls C Inlining S ession
3198 29 Object?Allocation?(new) ? O bject allocation (new) inlined C Works in most cases C E xtremely fast (~ 10C20 clock cycles) ? Do not manage memory yourself C G C will slow down C Larger memory footprint ? K eep software simple S ession