Open mbebenita opened 9 years ago
(We're marking with the "intex" label the things that block us from landing the intex branch, with "intex-followup" things that we need to do but that don't block us from landing it)
This is a fascinating problem. SpiderMonkey, after executing the J2ME interpreter loop decides to compile it with Baseline and then ION. Unfortunately, the type information recorded by SpiderMonkey when it first compiles the interpreter loop is not complete since it is likely that parts of the interpreter loop were never executed (for example the code dealing with OSR or bailouts). When those parts of the code are executed, we end up bailing out of ION and back to baseline, then back into ION for another compilation, and so on. If we are really unlucky, SpiderMonkey might give up on ION all together and we never execute in optimized code.
The only way to stay in ION from the very beginning is to probably warm up the interpreter loop evenly, before it get compiled by ION. Another thing that might help is it factor out infrequently used parts of the interpreter loop into functions.
I pulled a histogram of the startup sequence, showing the top 80% of executed bytecodes.
With JIT Enabled:
ALOAD_0 13.09% 23033
GETFIELD 6.58% 11573
INVOKEVIRTUAL 5.26% 9259
ILOAD 3.85% 6780
PUTFIELD 3.67% 6466
DUP 3.65% 6424
ALOAD_1 3.56% 6268
INVOKESPECIAL 3.15% 5536
BIPUSH 2.77% 4869
RETURN 2.58% 4546
ICONST_0 2.58% 4537
ILOAD_2 2.37% 4174
INVOKESTATIC 2.36% 4151
ILOAD_1 2.00% 3526
ALOAD 1.94% 3411
ICONST_1 1.88% 3315
GETSTATIC 1.59% 2801
ILOAD_3 1.57% 2769
GOTO 1.53% 2696
ISTORE 1.53% 2692
NEW 1.44% 2536
IFEQ 1.40% 2467
IRETURN 1.32% 2317
IADD 1.26% 2223
ARETURN 1.18% 2076
LDC 1.14% 2011
ALOAD_2 1.05% 1856
IFNE 0.79% 1397
IF_ICMPGE 0.79% 1391
ALOAD_3 0.79% 1384
PUTSTATIC 0.79% 1383
With JIT Disabled:
ALOAD_0 11.88% 2576326
GETFIELD 9.65% 2093871
ILOAD 9.06% 1965620
ILOAD_2 5.78% 1254358
GOTO 3.93% 852107
ILOAD_1 3.40% 736872
IF_ICMPGE 3.32% 720257
BIPUSH 2.84% 615380
IINC 2.80% 607237
ISTORE 2.42% 524609
ICONST_1 2.31% 501056
ICONST_0 2.18% 473358
IADD 2.17% 471250
INVOKEVIRTUAL 2.01% 435600
IRETURN 2.00% 433069
IASTORE 1.94% 421679
IF_ICMPEQ 1.94% 420708
DUP 1.56% 338008
ICONST_4 1.53% 331056
CALOAD 1.49% 322349
ISTORE_2 1.31% 284207
IALOAD 1.28% 278660
ILOAD_3 1.28% 278233
ALOAD_1 1.21% 262003
PUTFIELD 1.16% 251748
We should figure out why this is, and make sure it is never compiled more than once. The method is very large and probably takes a while to compile.