lightweight scheduling in a single pass javascript jit
play

Lightweight Scheduling in a Single-Pass JavaScript JIT Compiler - PowerPoint PPT Presentation

Lightweight Scheduling in a Single-Pass JavaScript JIT Compiler Alexander Jordan, Vienna University of Technology ajordan@complang.tuwien.ac.at Christophe Guillon, STMicroelectronics christophe.guillon@st.com January 22, 2013 1/16 Alexander


  1. Lightweight Scheduling in a Single-Pass JavaScript JIT Compiler Alexander Jordan, Vienna University of Technology ajordan@complang.tuwien.ac.at Christophe Guillon, STMicroelectronics christophe.guillon@st.com January 22, 2013 1/16 Alexander Jordan, Christophe Guillon Lightweight JavaScript JIT Scheduling

  2. Introduction SH4 (SuperH) ➙ 32-bit RISC ➙ Compact 16-bit instruction set ➙ 32/64-bit floating point hardware ➙ Dual-issue, in-order pipeline (with interlocking) Issue Constraints: LS, MUL, BR, FPx Latencies: default: 1, LS:3, MUL:2, FP: long 2/16 Alexander Jordan, Christophe Guillon Lightweight JavaScript JIT Scheduling

  3. V8 JavaScript Engine V8 JavaScript Engine ➙ JIT-only (arm, ia32, mips, x64, sh4 ) ➙ Precise Garbage Collector ➙ Inline caching and adaptive optimizations (Crankshaft) 3/16 Alexander Jordan, Christophe Guillon Lightweight JavaScript JIT Scheduling

  4. V8 JavaScript Engine V8 JavaScript Engine ➙ JIT-only (arm, ia32, mips, x64, sh4 ) ➙ Precise Garbage Collector ➙ Inline caching and adaptive optimizations (Crankshaft) Efficient 1 st -level JIT ➙ Single-pass code generation ➙ No register allocation ➙ Emits at the same time Code Relocation information Constants (pooled) ➙ No instruction scheduling 3/16 Alexander Jordan, Christophe Guillon Lightweight JavaScript JIT Scheduling

  5. V8 JavaScript Engine 4/16 Alexander Jordan, Christophe Guillon Lightweight JavaScript JIT Scheduling

  6. Challenges Computational Complexity Runtime: slower (optimizing) compiler impacts overall execution time 5/16 Alexander Jordan, Christophe Guillon Lightweight JavaScript JIT Scheduling

  7. Challenges Computational Complexity Runtime: slower (optimizing) compiler impacts overall execution time Dynamic-compilation issues Constants are pooled to optimize their placement Branches are written once their destinations are resolved Inline caching rewrites call sites during execution ➙ Instructions may be changed after being emitted (conflict: back-patching vs. reordering) 5/16 Alexander Jordan, Christophe Guillon Lightweight JavaScript JIT Scheduling

  8. Challenge: Constant pool (example) Emit instructions loading large constants... 0x42b1cb00 0 02 d0 mov.l ? , r0 ! 0xff000000 0x42b1cb02 2 2a e0 mov #42 , r1 0x42b1cb04 4 02 d0 mov.l ? , r2 ! 0 x f 0 f 0 f 0 f 0 0x42b1cb06 6 03 d0 mov.l ? , r3 ! 0 x f f f 0 f f f f 0x42b1cb08 8 0b 00 r t s 0x42b1cb0a 10 09 00 nop 6/16 Alexander Jordan, Christophe Guillon Lightweight JavaScript JIT Scheduling

  9. Challenge: Constant pool (example) ..add constant pool and patch addresses. 0x42b1cb00 0 02 d0 mov.l 0x42b1cb0c , r0 ! 0xff000000 0x42b1cb02 2 2a e0 #42 , r1 mov 0x42b1cb04 4 02 d0 mov.l 0x42b1cb10 , r2 ! 0 x f 0 f 0 f 0 f 0 0x42b1cb06 6 03 d0 mov.l 0x42b1cb14 , r3 ! 0 x f f f 0 f f f f 0x42b1cb08 8 0b 00 r t s 0x42b1cb0a 10 09 00 nop 0x42b1cb0c 12 ff000000 constant pool begin 0x42b1cb10 16 f 0 f 0 f 0 f 0 constant 0x42b1cb14 20 f f f 0 f f f f constant 7/16 Alexander Jordan, Christophe Guillon Lightweight JavaScript JIT Scheduling

  10. Scoreboard Scheduling In a nutshell ➙ Assigns issue dates to instructions during dispatch ➙ Keeps track of dependencies and resource use within a time window ➙ Lightweight (no dependency graph) but inferior results compared to List Scheduling 8/16 Alexander Jordan, Christophe Guillon Lightweight JavaScript JIT Scheduling

  11. Scoreboard Scheduling In a nutshell ➙ Assigns issue dates to instructions during dispatch ➙ Keeps track of dependencies and resource use within a time window ➙ Lightweight (no dependency graph) but inferior results compared to List Scheduling Data structures ➙ Dependency records 2 per resource (read/write) Pseudo records ➙ Reservation table (window length × resources) 8/16 Alexander Jordan, Christophe Guillon Lightweight JavaScript JIT Scheduling

  12. Scoreboard Scheduling Example s✉❜ ✶✻✱r✶✺ ♠♦✈ r✶✺✱r✶✹ ❝♠♣✴❡q ✵✱r✶✺ ♠♦✈✳❧ ❅✭❝♣✰✷✹✮✱r✺ ❛❞❞ r✺✱r✵ ▲❙✿ ✵✵✵✵✵ ❁♥♦ r❡❝♦r❞s❃ ▼❯▲✿ ✵✵✵✵✵ ❇❘✿ ✵✵✵✵✵ ❋P❯✿ ✵✵✵✵✵ ✐ss✉❡✿ ✵✵✵✵✵ 9/16 Alexander Jordan, Christophe Guillon Lightweight JavaScript JIT Scheduling

  13. Scoreboard Scheduling Example s✉❜ ✶✻✱r✶✺ ✵✳✵✿ s✉❜ ✶✻✱r✶✺ ♠♦✈ r✶✺✱r✶✹ ❝♠♣✴❡q ✵✱r✶✺ ♠♦✈✳❧ ❅✭❝♣✰✷✹✮✱r✺ ❛❞❞ r✺✱r✵ ▲❙✿ ✵✵✵✵✵ ▼❯▲✿ ✵✵✵✵✵ ❇❘✿ ✵✵✵✵✵ ❋P❯✿ ✵✵✵✵✵ ✐ss✉❡✿ ✶✵✵✵✵ r❡❛❞ ❬r✶✺❪✿ ✵ ✇r✐t❡❬r✶✺❪✿ ✶ 9/16 Alexander Jordan, Christophe Guillon Lightweight JavaScript JIT Scheduling

  14. Scoreboard Scheduling Example s✉❜ ✶✻✱r✶✺ ✵✳✵✿ s✉❜ ✶✻✱r✶✺ ♠♦✈ r✶✺✱r✶✹ ❝♠♣✴❡q ✵✱r✶✺ ✶✳✵✿ ♠♦✈ r✶✺✱r✶✹ ♠♦✈✳❧ ❅✭❝♣✰✷✹✮✱r✺ ❛❞❞ r✺✱r✵ ▲❙✿ ✵✵✵✵✵ ▼❯▲✿ ✵✵✵✵✵ ❇❘✿ ✵✵✵✵✵ ❋P❯✿ ✵✵✵✵✵ ✇r✐t❡❬r✶✹❪✿ ✶ ✐ss✉❡✿ ✶✶✵✵✵ r❡❛❞ ❬r✶✺❪✿ ✶ ✇r✐t❡❬r✶✺❪✿ ✶ 9/16 Alexander Jordan, Christophe Guillon Lightweight JavaScript JIT Scheduling

  15. Scoreboard Scheduling Example s✉❜ ✶✻✱r✶✺ ✵✳✵✿ s✉❜ ✶✻✱r✶✺ ♠♦✈ r✶✺✱r✶✹ ❝♠♣✴❡q ✵✱r✶✺ ✶✳✵✿ ♠♦✈ r✶✺✱r✶✹ ♠♦✈✳❧ ❅✭❝♣✰✷✹✮✱r✺ ✶✳✶✿ ❝♠♣✴❡q ✵✱r✶✺ ❛❞❞ r✺✱r✵ ▲❙✿ ✵✵✵✵✵ ▼❯▲✿ ✵✵✵✵✵ ❇❘✿ ✵✵✵✵✵ ❋P❯✿ ✵✵✵✵✵ ✇r✐t❡❬r✶✹❪✿ ✶ ✐ss✉❡✿ ✶✷✵✵✵ r❡❛❞ ❬r✶✺❪✿ ✶ ✇r✐t❡❬r✶✺❪✿ ✶ ✇r✐t❡❬❚❪✿ ✷ 9/16 Alexander Jordan, Christophe Guillon Lightweight JavaScript JIT Scheduling

  16. Scoreboard Scheduling Example s✉❜ ✶✻✱r✶✺ ✵✳✵✿ s✉❜ ✶✻✱r✶✺ ♠♦✈ r✶✺✱r✶✹ ✵✳✶✿ ♠♦✈✳❧ ❅✭❝♣✰✷✹✮✱r✺ ❝♠♣✴❡q ✵✱r✶✺ ✶✳✵✿ ♠♦✈ r✶✺✱r✶✹ ♠♦✈✳❧ ❅✭❝♣✰✷✹✮✱r✺ ✶✳✶✿ ❝♠♣✴❡q ✵✱r✶✺ ❛❞❞ r✺✱r✵ ▲❙✿ ✶✵✵✵✵ ▼❯▲✿ ✵✵✵✵✵ r❡❛❞ ❬r✺❪✿ ✵ ❇❘✿ ✵✵✵✵✵ ✇r✐t❡❬r✺❪✿ ✸ ❋P❯✿ ✵✵✵✵✵ ✇r✐t❡❬r✶✹❪✿ ✶ ✐ss✉❡✿ ✷✷✵✵✵ r❡❛❞ ❬r✶✺❪✿ ✶ ✇r✐t❡❬r✶✺❪✿ ✶ ✇r✐t❡❬❚❪✿ ✷ 9/16 Alexander Jordan, Christophe Guillon Lightweight JavaScript JIT Scheduling

  17. Scoreboard Scheduling Example s✉❜ ✶✻✱r✶✺ ✵✳✵✿ s✉❜ ✶✻✱r✶✺ ♠♦✈ r✶✺✱r✶✹ ✵✳✶✿ ♠♦✈✳❧ ❅✭❝♣✰✷✹✮✱r✺ ❝♠♣✴❡q ✵✱r✶✺ ✶✳✵✿ ♠♦✈ r✶✺✱r✶✹ ♠♦✈✳❧ ❅✭❝♣✰✷✹✮✱r✺ ✶✳✶✿ ❝♠♣✴❡q ✵✱r✶✺ ❛❞❞ r✺✱r✵ ✸✳✵✿ ❛❞❞ r✺✱r✵ ▲❙✿ ✶✵✵✵✵ ✇r✐t❡❬r✵❪✿ ✹ ▼❯▲✿ ✵✵✵✵✵ r❡❛❞ ❬r✺❪✿ ✸ ❇❘✿ ✵✵✵✵✵ ✇r✐t❡❬r✺❪✿ ✸ ❋P❯✿ ✵✵✵✵✵ ✇r✐t❡❬r✶✹❪✿ ✶ ✐ss✉❡✿ ✷✷✵✶✵ r❡❛❞ ❬r✶✺❪✿ ✶ ✇r✐t❡❬r✶✺❪✿ ✶ ✇r✐t❡❬❚❪✿ ✷ 9/16 Alexander Jordan, Christophe Guillon Lightweight JavaScript JIT Scheduling

  18. Scoreboard Scheduling in V8 10/16 Alexander Jordan, Christophe Guillon Lightweight JavaScript JIT Scheduling

  19. Scoreboard Scheduling in V8 Reordering Pitfalls ➙ Back-patching ➙ Atomic sequences ➙ Synchronized access to target buffer 10/16 Alexander Jordan, Christophe Guillon Lightweight JavaScript JIT Scheduling

  20. Scoreboard Scheduling in V8 Reordering Pitfalls ➙ Back-patching ➙ Atomic sequences ➙ Synchronized access to target buffer Possible Solutions ➙ Naive: Flush frequently ➙ Better: Keep some extra information 10/16 Alexander Jordan, Christophe Guillon Lightweight JavaScript JIT Scheduling

  21. Results: Execution time breakdown GC Compilation JS VM · 10 4 1 . 8 1 . 6 1 . 4 Profiling Ticks 1 . 2 1 0 . 8 0 . 6 0 . 4 0 . 2 crypto raytrace regexp deltablue earley-boyer navier-stokes richards splay 11/16 Alexander Jordan, Christophe Guillon Lightweight JavaScript JIT Scheduling

  22. Results: Good News Table: Profiled JS Ticks Benchmark Unscheduled Scheduled Speedup(%) crypto 11 , 501 11 , 288 1 . 89 deltablue 729 684 6 . 58 earley-boyer 5 , 115 4 , 926 3 . 84 navier-stokes 16 , 351 15 , 629 4 . 62 raytrace 5 , 314 5 , 063 4 . 96 regexp 4 , 103 4 , 134 − 0 . 75 richards 491 479 2 . 51 splay 625 616 1 . 46 Mean 3 . 11 12/16 Alexander Jordan, Christophe Guillon Lightweight JavaScript JIT Scheduling

  23. Results: Bad News Table: Scoreboard Scheduling Overhead (slowdown factor) Assembler * Benchmark crypto 6 . 561 deltablue 3 . 952 earley-boyer 5 . 310 navier-stokes 6 . 870 raytrace 4 . 110 richards 7 . 609 splay 6 . 870 Mean 5 . 732 13/16 Alexander Jordan, Christophe Guillon Lightweight JavaScript JIT Scheduling

Recommend


More recommend