Reorder LuaJIT runtime
This commit is contained in:
parent
508fff73ef
commit
65374481ff
@ -26,11 +26,6 @@ do
|
|||||||
|
|
||||||
local to_signed = bit.tobit
|
local to_signed = bit.tobit
|
||||||
|
|
||||||
module.add = add
|
|
||||||
module.sub = sub
|
|
||||||
module.mul = mul
|
|
||||||
module.div = div
|
|
||||||
|
|
||||||
function add.i32(a, b) return to_signed(a + b) end
|
function add.i32(a, b) return to_signed(a + b) end
|
||||||
function add.i64(a, b) return a + b end
|
function add.i64(a, b) return a + b end
|
||||||
|
|
||||||
@ -60,6 +55,11 @@ do
|
|||||||
|
|
||||||
return i64(u64(lhs) / u64(rhs))
|
return i64(u64(lhs) / u64(rhs))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
module.add = add
|
||||||
|
module.sub = sub
|
||||||
|
module.mul = mul
|
||||||
|
module.div = div
|
||||||
end
|
end
|
||||||
|
|
||||||
do
|
do
|
||||||
@ -70,10 +70,6 @@ do
|
|||||||
local lj_band = bit.band
|
local lj_band = bit.band
|
||||||
local lj_lshift = bit.lshift
|
local lj_lshift = bit.lshift
|
||||||
|
|
||||||
module.clz = clz
|
|
||||||
module.ctz = ctz
|
|
||||||
module.popcnt = popcnt
|
|
||||||
|
|
||||||
function clz.i32(num)
|
function clz.i32(num)
|
||||||
for i = 0, 31 do
|
for i = 0, 31 do
|
||||||
local mask = lj_lshift(1, 31 - i)
|
local mask = lj_lshift(1, 31 - i)
|
||||||
@ -104,6 +100,10 @@ do
|
|||||||
|
|
||||||
return count
|
return count
|
||||||
end
|
end
|
||||||
|
|
||||||
|
module.clz = clz
|
||||||
|
module.ctz = ctz
|
||||||
|
module.popcnt = popcnt
|
||||||
end
|
end
|
||||||
|
|
||||||
do
|
do
|
||||||
@ -115,14 +115,6 @@ do
|
|||||||
local ge = {}
|
local ge = {}
|
||||||
local gt = {}
|
local gt = {}
|
||||||
|
|
||||||
module.eqz = eqz
|
|
||||||
module.eq = eq
|
|
||||||
module.ne = ne
|
|
||||||
module.le = le
|
|
||||||
module.lt = lt
|
|
||||||
module.ge = ge
|
|
||||||
module.gt = gt
|
|
||||||
|
|
||||||
local function to_boolean(cond)
|
local function to_boolean(cond)
|
||||||
if cond then
|
if cond then
|
||||||
return 1
|
return 1
|
||||||
@ -159,6 +151,14 @@ do
|
|||||||
function lt.i64(lhs, rhs) return to_boolean(lhs < rhs) end
|
function lt.i64(lhs, rhs) return to_boolean(lhs < rhs) end
|
||||||
function lt.u32(lhs, rhs) return to_boolean(u32(lhs) < u32(rhs)) end
|
function lt.u32(lhs, rhs) return to_boolean(u32(lhs) < u32(rhs)) end
|
||||||
function lt.u64(lhs, rhs) return to_boolean(u64(lhs) < u64(rhs)) end
|
function lt.u64(lhs, rhs) return to_boolean(u64(lhs) < u64(rhs)) end
|
||||||
|
|
||||||
|
module.eqz = eqz
|
||||||
|
module.eq = eq
|
||||||
|
module.ne = ne
|
||||||
|
module.le = le
|
||||||
|
module.lt = lt
|
||||||
|
module.ge = ge
|
||||||
|
module.gt = gt
|
||||||
end
|
end
|
||||||
|
|
||||||
do
|
do
|
||||||
@ -167,11 +167,6 @@ do
|
|||||||
local bxor = {}
|
local bxor = {}
|
||||||
local bnot = {}
|
local bnot = {}
|
||||||
|
|
||||||
module.band = band
|
|
||||||
module.bor = bor
|
|
||||||
module.bxor = bxor
|
|
||||||
module.bnot = bnot
|
|
||||||
|
|
||||||
band.i32 = bit.band
|
band.i32 = bit.band
|
||||||
band.i64 = bit.band
|
band.i64 = bit.band
|
||||||
bnot.i32 = bit.bnot
|
bnot.i32 = bit.bnot
|
||||||
@ -180,6 +175,11 @@ do
|
|||||||
bor.i64 = bit.bor
|
bor.i64 = bit.bor
|
||||||
bxor.i32 = bit.bxor
|
bxor.i32 = bit.bxor
|
||||||
bxor.i64 = bit.bxor
|
bxor.i64 = bit.bxor
|
||||||
|
|
||||||
|
module.band = band
|
||||||
|
module.bor = bor
|
||||||
|
module.bxor = bxor
|
||||||
|
module.bnot = bnot
|
||||||
end
|
end
|
||||||
|
|
||||||
do
|
do
|
||||||
@ -192,11 +192,6 @@ do
|
|||||||
local lj_rshift = bit.rshift
|
local lj_rshift = bit.rshift
|
||||||
local lj_arshift = bit.arshift
|
local lj_arshift = bit.arshift
|
||||||
|
|
||||||
module.shl = shl
|
|
||||||
module.shr = shr
|
|
||||||
module.rotl = rotl
|
|
||||||
module.rotr = rotr
|
|
||||||
|
|
||||||
rotl.i32 = bit.rol
|
rotl.i32 = bit.rol
|
||||||
rotl.i64 = bit.rol
|
rotl.i64 = bit.rol
|
||||||
rotr.i32 = bit.ror
|
rotr.i32 = bit.ror
|
||||||
@ -210,6 +205,11 @@ do
|
|||||||
shr.i64 = lj_arshift
|
shr.i64 = lj_arshift
|
||||||
shr.u32 = lj_rshift
|
shr.u32 = lj_rshift
|
||||||
shr.u64 = lj_rshift
|
shr.u64 = lj_rshift
|
||||||
|
|
||||||
|
module.shl = shl
|
||||||
|
module.shr = shr
|
||||||
|
module.rotl = rotl
|
||||||
|
module.rotr = rotr
|
||||||
end
|
end
|
||||||
|
|
||||||
do
|
do
|
||||||
@ -230,12 +230,6 @@ do
|
|||||||
|
|
||||||
local function truncate_i64(num) return i64(truncate(num)) end
|
local function truncate_i64(num) return i64(truncate(num)) end
|
||||||
|
|
||||||
module.wrap = wrap
|
|
||||||
module.trunc = trunc
|
|
||||||
module.extend = extend
|
|
||||||
module.convert = convert
|
|
||||||
module.reinterpret = reinterpret
|
|
||||||
|
|
||||||
function wrap.i32_i64(num)
|
function wrap.i32_i64(num)
|
||||||
RE_INSTANCE.i64 = num
|
RE_INSTANCE.i64 = num
|
||||||
|
|
||||||
@ -293,11 +287,18 @@ do
|
|||||||
|
|
||||||
return RE_INSTANCE.f64
|
return RE_INSTANCE.f64
|
||||||
end
|
end
|
||||||
|
|
||||||
|
module.wrap = wrap
|
||||||
|
module.trunc = trunc
|
||||||
|
module.extend = extend
|
||||||
|
module.convert = convert
|
||||||
|
module.reinterpret = reinterpret
|
||||||
end
|
end
|
||||||
|
|
||||||
do
|
do
|
||||||
local load = {}
|
local load = {}
|
||||||
local store = {}
|
local store = {}
|
||||||
|
|
||||||
local cast = ffi.cast
|
local cast = ffi.cast
|
||||||
|
|
||||||
local ptr_i8 = ffi.typeof('int8_t *')
|
local ptr_i8 = ffi.typeof('int8_t *')
|
||||||
@ -311,9 +312,6 @@ do
|
|||||||
local ptr_f32 = ffi.typeof('float *')
|
local ptr_f32 = ffi.typeof('float *')
|
||||||
local ptr_f64 = ffi.typeof('double *')
|
local ptr_f64 = ffi.typeof('double *')
|
||||||
|
|
||||||
module.load = load
|
|
||||||
module.store = store
|
|
||||||
|
|
||||||
function load.i32_i8(memory, addr) return cast(ptr_i8, memory.data)[addr] end
|
function load.i32_i8(memory, addr) return cast(ptr_i8, memory.data)[addr] end
|
||||||
function load.i32_u8(memory, addr) return memory.data[addr] end
|
function load.i32_u8(memory, addr) return memory.data[addr] end
|
||||||
function load.i32_i16(memory, addr) return cast(ptr_i16, memory.data + addr)[0] end
|
function load.i32_i16(memory, addr) return cast(ptr_i16, memory.data + addr)[0] end
|
||||||
@ -342,6 +340,9 @@ do
|
|||||||
|
|
||||||
function store.f32(memory, addr, value) cast(ptr_f32, memory.data + addr)[0] = value end
|
function store.f32(memory, addr, value) cast(ptr_f32, memory.data + addr)[0] = value end
|
||||||
function store.f64(memory, addr, value) cast(ptr_f64, memory.data + addr)[0] = value end
|
function store.f64(memory, addr, value) cast(ptr_f64, memory.data + addr)[0] = value end
|
||||||
|
|
||||||
|
module.load = load
|
||||||
|
module.store = store
|
||||||
end
|
end
|
||||||
|
|
||||||
do
|
do
|
||||||
@ -363,8 +364,6 @@ do
|
|||||||
|
|
||||||
local mem_t = ffi.typeof('struct Memory')
|
local mem_t = ffi.typeof('struct Memory')
|
||||||
|
|
||||||
module.memory = memory
|
|
||||||
|
|
||||||
local function finalizer(mem) ffi.C.free(mem.data) end
|
local function finalizer(mem) ffi.C.free(mem.data) end
|
||||||
|
|
||||||
local function grow_unchecked(memory, old, new)
|
local function grow_unchecked(memory, old, new)
|
||||||
@ -401,6 +400,8 @@ do
|
|||||||
return old
|
return old
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
module.memory = memory
|
||||||
end
|
end
|
||||||
|
|
||||||
return module
|
return module
|
||||||
|
Loading…
x
Reference in New Issue
Block a user