igdshare 110220: LuaJIT intro

Embed Size (px)

Citation preview

LuaJIT

a Just-in-Time compiler
for the language Lua

Lua

World of Warcraft

Angry Birds

Civilization 5

Homeworld 2...

http://en.wikipedia.org/wiki/Category:Lua-scripted_video_games

...AND YOU(possibly)

Lua

Lua/C API

=>Extensible & Embeddable

Lua

Lua

LuaJIT

http://luajit.org

Michael (Mike) Pall

2005~ LuaJIT 1.x (stable 1.1.6)

2009~ LuaJIT 2.0-beta releases

Now =>LuaJIT 2.0-beta6

(google for LuaJIT Roadmap 2011)

Just-in-Time Compiler?

Source code => bytecode => machine code

Java Hotspot

C# .Net

Javascript V8/Trace(Jaeger) Monkey

Python Pypy

...

JIT

&

LuaJIT 2.0

interpreter 2x-4x

Lua 5.1

drop-in replacement

Beta

Foreign Function Interface(beta6)

x86/64

LuaJIT in Games?

The Settlers 7 LuaJIT2-beta

Civilization 5 LuaJIT1

bytecode

Mike ...

LuaJIT

Lua table overhead

closure

inner loop





global object

for i = 1, 100000000 do

local t = {'a','b','c'}

for j = 1, 3 do t[j] = .. end

End --p.s. unroll loop

LuaJIT

-jv option

Bytecode Lua 5.1

Lua 5.2

LuaJIT

Qualcomm ARM Port

Foreign Function Interface

local ffi = require("ffi")

ffi.cdef[[

typedef struct { float x,y,z; } SVertex;

int MessageBoxA(void*,char const*,char const*,int);

]]

ffi.C.MessageBoxA(nil, "Hello world!", "Test", 0)

local img = ffi.new("SVertex[?]", 100)

img[0].x = 123

What's to come?

2011
LuaJIT 2.0 2.1
ARM port of LuaJIT 2.0

About 2.1
New Garbage Collector
FFI C-preprocessor (?)

What's to come?

LuaJIT FFI to C++ (!?)

Binding Lua ...

...Full Lua 3D engines ?

...Full Lua Triple-A Titles ?

What's in the next level ?

My 2 Cents:

Lua nature1

Lua nature2

=>

x86/64ARM

Demo Time

Game of Life benchmark

C/C++

=>

GL primitiveVertex Array

VBOPBO

[1] https://github.com/archilifelin/mysandbox/blob/master/lua/lifegame_ffi_sdl_gl.lua

[2] https://github.com/archilifelin/mysandbox/tree/master/cpp/lifegame_sdl

Lua

CoronaSDK

Scripting-Layer for Android (SL4A)

Gamekit (based on Ogre)

ShiVa Engine

Love2D

...and more

Love2D

http://love2d.org

OpenGL 2D

Box2D integration

TrueType Fontno unicode yet

Pure Lua

function love.draw() love.graphics.print('Hello World!', 400, 300)end

Q & A

Lua mailing list

http://luajit.org

http://love2d.org

http://en.wikipedia.org

http://shootout.alioth.debian.org

cubeat dot tw at gmail dot com

http://igdshare.blogspot.com