Your SlideShare is downloading. ×
igdshare 110220: LuaJIT intro
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

igdshare 110220: LuaJIT intro

1,776

Published on

A simple introduction to Lua and LuaJIT. …

A simple introduction to Lua and LuaJIT.
In chinese, sorry.

http://blog.igdshare.org
http://www.youtube.com/user/igdshare

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,776
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
23
Comments
0
Likes
2
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. LuaJIT a Just-in-Time compiler for the language Lua
  • 2. 誰在用 Lua
    • World of Warcraft
    • 3. Angry Birds
    • 4. Civilization 5
    • 5. Homeworld 2
    • 6. ...
    • 7. http://en.wikipedia.org/wiki/Category:Lua-scripted_video_games
    • ...AND YOU ! (possibly)
  • 8. 認識 Lua
    • 語法簡單、靈活
    • 9. 速度快
    • 10. 體積小
    • 11. 易延展( Lua/C API )
    • 12.   =>Extensible & Embeddable
    • 13. 『通常不獨立使用』
  • 14. Lua 效能
  • 15. Lua 效能
  • 16. LuaJIT
    • http://luajit.org
    • 17. Michael (Mike) Pall
    • 2005~ LuaJIT 1.x (stable 1.1.6)
    • 18. 2009~ LuaJIT 2.0-beta releases
    • 19. Now =>LuaJIT 2.0-beta6
    • 20. (google for LuaJIT Roadmap 2011)
  • 21. Just-in-Time Compiler?
    • 即時編譯器
    • 22. Source code => bytecode => machine code
    • 23. Java Hotspot
    • 24. C# .Net
    • 25. Javascript V8/Trace(Jaeger) Monkey
    • 26. Python Pypy
    • 27. ... 還有很多
  • 28. JIT 效能
  • 29. 速度 & 程式碼量
  • 30. LuaJIT 2.0
    • 超級快
    • 31. 只算 interpreter 也比原本快 2x-4x
    • 32. Lua 5.1 語法完全相同
    • 33. 丟進去就可以用 ( drop-in replacement )
    • 34. Beta 已經很穩定
    • 35. Foreign Function Interface(beta6)
    • 36. 現在只有 x86/64 版本
  • 37. LuaJIT in Games?
      The Settlers 7
    • 搶在上市前實裝 LuaJIT2-beta
    • 38. 個人測試:
    • 39. Civilization 5 只能用 LuaJIT1
    • 40. (可能是因為 bytecode 不相容)
    • Mike 本人透露,還有很多不能講 ...
  • 41. LuaJIT 注意事項
    • Lua table 盡量用,不用怕 overhead
    • 42. 避免大量的 closure (目前)
    • 43. 避免只跑幾次的 inner loop
    • 44. 避免 global object
    • for i = 1, 100000000 do
    • 45.   local t = {'a','b','c'}
    • 46.   for j = 1, 3 do t[j] = .. end
    • 47. End -- p.s. 通常這可以被自動 unroll ,但若其 loop 次數是由變數決定就很難講
  • 48. LuaJIT 注意事項
    • 避免無謂的暫存物件
    • 49. 多用 -jv option 查看執行效果
    • 50. Bytecode 不相容於 Lua 5.1
    • 51. 不打算積極跟上 Lua 5.2
  • 52. LuaJIT 近期重點
    • Qualcomm 贊助 ARM Port !
    • 53. Foreign Function Interface !
    • local ffi = require("ffi")
    • 54. ffi.cdef[[
    • 55. typedef struct { float x,y,z; } SVertex;
    • 56. int MessageBoxA(void*,char const*,char const*,int);
    • 57. ]]
    • 58. ffi.C.MessageBoxA(nil, "Hello world!", "Test", 0)
    • 59. local img = ffi.new("SVertex[?]", 100)
    • 60. img[0].x = 123
  • 61. What's to come?
    • 2011 年內:   LuaJIT 2.0 正式版與 2.1 測試版   ARM port of LuaJIT 2.0  
    • 62. About 2.1 :   New Garbage Collector   FFI C-preprocessor (?)
    • 63.  
  • 64. What's to come?
    • 更遠程: LuaJIT FFI to C++ (!?)
    • 65. Binding 再也不用額外寫,運算可以幾乎都寫在 Lua 裡 ...
    • 66. ...Full Lua 3D engines ?
    • 67. ...Full Lua Triple-A Titles ?  
    • 68. What's in the next level ?
  • 69. My 2 Cents: 沒有天天過年的啦
    • Lua nature1 :沒有統一穩定的電池
    • 70. Lua nature2 :大概永遠不適合大團隊開發
    • 71. 因為太簡單,大家自成一套 =>
    • 72.  結果反而不穩定、難用?
    • 73. x86/64 、 ARM 以外的平台大概有得等
  • 74. Demo Time
    • Game of Life benchmark :
    • 75.  純邏輯速度比較 C/C++
    • 76.  加上繪圖速度比較 =>
    • 77.    GL primitive 、 Vertex Array 、
    • 78.    VBO 、 PBO
    • 79.  繪圖加速情況下把邏輯加速關掉
    • 80. [1] https://github.com/archilifelin/mysandbox/blob/master/lua/lifegame_ffi_sdl_gl.lua
    • 81. [2] https://github.com/archilifelin/mysandbox/tree/master/cpp/lifegame_sdl
  • 82. Lua 框架
  • 88. Love2D
    • http://love2d.org
    • 89. OpenGL 加速的輕量 2D 遊戲框架
    • 90. Box2D integration
    • 91. TrueType Font ( no unicode yet )
    • 92. Pure Lua
    function love.draw() love.graphics.print('Hello World!', 400, 300) end
  • 93. Q & A 資料來源
    • Lua mailing list
    • 94. http://luajit.org
    • 95. http://love2d.org
    • 96. http://en.wikipedia.org
    • 97. http://shootout.alioth.debian.org
    • cubeat dot tw at gmail dot com
    • 98. http://igdshare.blogspot.com

×