polyhedral optimization for javascript the challenges
play

Polyhedral Optimization For JavaScript: The Challenges Manuel Selva - PowerPoint PPT Presentation

Motivation JavaScriptCore Proposal Challenges And Solutions Preliminary Results Conclusion Polyhedral Optimization For JavaScript: The Challenges Manuel Selva , Julien Pags, Philippe Clauss INRIA CAMUS, ICube, CNRS, University of


  1. Motivation JavaScriptCore Proposal Challenges And Solutions Preliminary Results Conclusion Polyhedral Optimization For JavaScript: The Challenges Manuel Selva , Julien Pagès, Philippe Clauss INRIA CAMUS, ICube, CNRS, University of Strasbourg January 23, 2018 1 / 25

  2. Motivation JavaScriptCore Proposal Challenges And Solutions Preliminary Results Conclusion The JavaScript Language Created in 1995 at Netscape • To implement dynamism in web pages • High level and dynamic • ECMAScript standard Now widely used both on client and server sides • For complex applications • Because of portability • Because of performances 5th language - PYPL index 2 / 25

  3. Motivation JavaScriptCore Proposal Challenges And Solutions Preliminary Results Conclusion JavaScript Implementation Widespread engines app.js • SpiderMonkey - Mozilla Engine • JavaScriptCore - Apple • V8 - Google result • Chakra - Microsoft 3 / 25

  4. Motivation JavaScriptCore Proposal Challenges And Solutions Preliminary Results Conclusion JavaScript Implementation Widespread engines app.js • SpiderMonkey - Mozilla Engine • JavaScriptCore - Apple • V8 - Google result • Chakra - Microsoft Browser wars • Complex optimization • Nevertheless, no parallelism 3 / 25

  5. Motivation JavaScriptCore Proposal Challenges And Solutions Preliminary Results Conclusion You Said Polyhedral Model And JavaScript Together How to cope with dynamism? • Static Control Parts (SCoPs) cannot be detected statically • When and how detect polyhedral opportunities? Is it worthwhile to use the polyhedral model at runtime? • Gain versus overhead 4 / 25

  6. Motivation JavaScriptCore Proposal Challenges And Solutions Preliminary Results Conclusion Outline Motivation JavaScript Polyhedral Model And JavaScript JavaScriptCore Challenges And Solutions Detection Of SCoPs Parallel Speculation Failure Gain vs Overhead Preliminary Results 5 / 25

  7. Motivation JavaScriptCore Proposal Challenges And Solutions Preliminary Results Conclusion JavaScript Is Dynamic → We Need An Engine f(img, width, height) { for ( var i = 0; i < width; i++) { for ( var j = 0; j < height; i++) { var v = img[i*width + j]; v = v + 41; v = v * 2; img[i*width + j] = v; } } } 6 / 25

  8. Motivation JavaScriptCore Proposal Challenges And Solutions Preliminary Results Conclusion JavaScript Is Dynamic → We Need An Engine f(img, width, height) { for ( var i = 0; i < width; i++) { for ( var j = 0; j < height; i++) { var v = img[i*width + j]; v = v + 41; v = v * 2; img[i*width + j] = v; } } } • Types are dynamic 6 / 25

  9. Motivation JavaScriptCore Proposal Challenges And Solutions Preliminary Results Conclusion JavaScript Is Dynamic → We Need An Engine f(img, width, height) { for ( var i = 0; i < width; i++) { for ( var j = 0; j < height; i++) { var v = img[i*width + j]; v = v + 41; v = v * 2; img[i*width + j] = v; } } } • Types are dynamic • Arrays are dynamic 6 / 25

  10. Motivation JavaScriptCore Proposal Challenges And Solutions Preliminary Results Conclusion JavaScript Is Dynamic → We Need An Engine f(img, width, height) { for ( var i = 0; i < width; i++) { for ( var j = 0; j < height; i++) { var v = img[i*width + j]; v = v + 41; v = v * 2; img[i*width + j] = v; } } } • Types are dynamic • Arrays are dynamic • Only double precision floating point numbers 6 / 25

  11. Motivation JavaScriptCore Proposal Challenges And Solutions Preliminary Results Conclusion 4 Layers f.js Bytecode compiler f.bc 1. LLInt (Low Level Interpreter) 7 / 25

  12. Motivation JavaScriptCore Proposal Challenges And Solutions Preliminary Results Conclusion 4 Layers f.js Bytecode compiler f.bc 1. LLInt (Low Level Interpreter) f-v1.native 2. Baseline JIT 7 / 25

  13. Motivation JavaScriptCore Proposal Challenges And Solutions Preliminary Results Conclusion 4 Layers f.js Bytecode compiler f.bc 1. LLInt (Low Level Interpreter) f.prof f-v1.native 2. Baseline JIT 3. DFG (Dataflow Graph) JIT f-v2.native 7 / 25

  14. Motivation JavaScriptCore Proposal Challenges And Solutions Preliminary Results Conclusion 4 Layers f.js Bytecode compiler f.bc 1. LLInt (Low Level Interpreter) f.prof f-v1.native 2. Baseline JIT 3. DFG (Dataflow Graph) JIT f-v2.native 4. FTL (Fourth Tiers LLVM) JIT f-v3.native 7 / 25

  15. Motivation JavaScriptCore Proposal Challenges And Solutions Preliminary Results Conclusion 1. LLInt f(img, width, height) { for ( var i = 0; i < width; i++) { for ( var j = 0; j < height; i++) { var v = img[i*width + j]; v = v + 41; v = v * 2; img[i*width + j] = v; } } } Source 8 / 25

  16. Motivation JavaScriptCore Proposal Challenges And Solutions Preliminary Results Conclusion 1. LLInt f(img, width, height) { for ( var i = 0; i < width; i++) { f(img, width, height) { for ( var j = 0; j < height; i++) { ... var v = img[i*width + j]; ... v = v + 41; op_add v 41 v; v = v * 2; op_mul v 2 v; img[i*width + j] = v; ... } ... } } Bytecode } Source 8 / 25

  17. Motivation JavaScriptCore Proposal Challenges And Solutions Preliminary Results Conclusion 1. LLInt f(img, width, height) { for ( var i = 0; i < width; i++) { f(img, width, height) { for ( var j = 0; j < height; i++) { ... var v = img[i*width + j]; ... v = v + 41; op_add v 41 v; v = v * 2; op_mul v 2 v; img[i*width + j] = v; ... } ... } } Bytecode } Source while (i = next_instruction()) { Interpreter switch (i->opcode) { case add: switch (type_pair(i->operand1->type(), i->operand2->type())): case number_number: i->dest = add(i->operand1, i->operand2); case object_number: i->dest = add(i->operand1->as_number(), i->operand2); ... case mul: ... } } 8 / 25

  18. Motivation JavaScriptCore Proposal Challenges And Solutions Preliminary Results Conclusion 2. Baseline JIT f(img, width, height) { for ( var i = 0; i < width; i++) { f(img, width, height) { for ( var j = 0; j < height; i++) { ... var v = img[i*width + j]; ... v = v + 41; op_add v 41 v; v = v * 2; op_mul v 2 v; img[i*width + j] = v; ... } ... } } Bytecode } Source 9 / 25

  19. Motivation JavaScriptCore Proposal Challenges And Solutions Preliminary Results Conclusion 2. Baseline JIT f(img, width, height) { for ( var i = 0; i < width; i++) { f(img, width, height) { for ( var j = 0; j < height; i++) { ... var v = img[i*width + j]; ... v = v + 41; op_add v 41 v; v = v * 2; op_mul v 2 v; img[i*width + j] = v; ... } ... } } Bytecode } Source ... Native code switch (type_pair(v, 41)): case number_number: op_add v 41 v; v = add(v, 41); case object_number: ... switch (type_pair(v, 2)): op_mul v 2 v; case number_number: v = mul(v->as_number() * 2); case object_number: ... ... 9 / 25

  20. Motivation JavaScriptCore Proposal Challenges And Solutions Preliminary Results Conclusion 3. DFG JIT f(img, width, height) { for ( var i = 0; i < width; i++) { f(img, width, height) { for ( var j = 0; j < height; i++) { ... var v = img[i*width + j]; ... v = v + 41; op_add v 41 v; v = v * 2; op_mul v 2 v; img[i*width + j] = v; ... } ... } } Bytecode } Source 10 / 25

  21. Motivation JavaScriptCore Proposal Challenges And Solutions Preliminary Results Conclusion 3. DFG JIT f(img, width, height) { for ( var i = 0; i < width; i++) { f(img, width, height) { for ( var j = 0; j < height; i++) { ... var v = img[i*width + j]; ... v = v + 41; op_add v 41 v; v = v * 2; op_mul v 2 v; img[i*width + j] = v; ... } ... } } Bytecode } Source if (!is_32int_array(img)) { return to Baseline JIT; } ... DFG IR - Typed res = v->as_32int() + 41; if (overflow(res)) { return to Baseline JIT; } v = res; res = v->as_32int() * 2; if (overflow(res)) { return to Baseline JIT; } v = res; ... 10 / 25

  22. Motivation JavaScriptCore Proposal Challenges And Solutions Preliminary Results Conclusion 3. DFG JIT f(img, width, height) { for ( var i = 0; i < width; i++) { f(img, width, height) { for ( var j = 0; j < height; i++) { ... var v = img[i*width + j]; ... v = v + 41; op_add v 41 v; v = v * 2; op_mul v 2 v; img[i*width + j] = v; ... } ... } } Bytecode } Source if (!is_32int_array(img)) { return to Baseline JIT; } ... DFG IR - Typed res = v->as_32int() + 41; if (overflow(res)) { return to Baseline JIT; } v = res; Homemade res = v->as_32int() * 2; optim and if (overflow(res)) { return to Baseline JIT; } v = res; backend ... ... Native code ... 10 / 25

  23. Motivation JavaScriptCore Proposal Challenges And Solutions Preliminary Results Conclusion 4. FTL JIT f(img, width, height) { for ( var i = 0; i < width; i++) { f(img, width, height) { for ( var j = 0; j < height; i++) { ... var v = img[i*width + j]; ... v = v + 41; op_add v 41 v; v = v * 2; op_mul v 2 v; img[i*width + j] = v; ... } ... } } Bytecode } Source 11 / 25

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend