Advertisement
Guest User

A whirlwind tour through the LuaJIT VM, by Mike Pall

a guest
Oct 7th, 2013
734
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. A whirlwind tour through the LuaJIT VM, by its creator
  2. Talk by Mike Pall
  3. Notes by Felix Rabe — feel free to integrate with your own notes if you were at the event!
  4. 2013-Oct-03 at the Zurich FLOSS and IT geeks meetup: http://www.meetup.com/zhgeeks/events/141272252/
  5.  
  6. 2005
  7. Business logic
  8. Codebase in C
  9.  
  10. Lua 5.0 -> 5.1
  11. incremental GC
  12. low-latency requirements
  13. delays of 100ms not acceptable / affordable
  14.  
  15. Got involved in Lua community (patches, ...)
  16. At the time, Lua's performance was top-5
  17.  
  18. Tail calls = "kind of goto"
  19. Syntax does not matter, what matters is semantics
  20.  
  21. 2005...
  22. Projects was abandoned
  23. Stayed with Lua community
  24.  
  25. Lua bytecode
  26. (Stupid) register(-based) allocator
  27.  
  28. IR
  29. Dataflow
  30. 64-bit representation (very little for compilers / IA)
  31. linear IR
  32. PHI's at the end
  33. IR => assembly goes backward (to allocate registers)
  34. x86 FPU is fast, often waste not to use it
  35. ARM often uses integers (weak FPU); overflow check
  36.  
  37. Branches get patched when new traces are introduced
  38. Counters on looping instructions are used to determine hot code areas
  39. Dynamic languages have a lot of guards
  40. C preprocessor-based DSL
  41. C compiler does not know what aliases what (pointers!)
  42. Luajit knows what tables do (not) alias other tables
  43. Allocation sinking
  44.  
  45. Q: Tail recursion?
  46. Not many Lua users write recursive code
  47. Not very optimized
  48.  
  49. Don't get lost in the details (=> Spidermonkey / Tracemonkey), stick to what's important:
  50. Loop optimization
  51. Alias ...
  52.  
  53. Sparse snapshotting, only where necessary (Tracemonkey: snapshot after every instruction)
  54. Tracemonkey people had no experience writing compilers
  55. Luajit 1 => Luajit 2
  56.  
  57. Do not write a trace compiler for your thesis!
  58.  
  59. Cloudflare: Web application firewall
  60. Huge amount of rules (blacklisting...)
  61. Ahead-of-time optimization cannot adapt to changes
  62.  
  63. Luajit does pay for the time invested, but not a full-time project
  64. Not too interested in money: fun => keep going
  65.  
  66. Advantage: Luajit built on existing Lua ecosystem => large body of code already available
  67. Not optimizing corner cases
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement