Disambiguate allocator and memory
This commit is contained in:
parent
5fb7899c7e
commit
02232b46ca
@ -320,7 +320,7 @@ end
|
||||
do
|
||||
local load = {}
|
||||
local store = {}
|
||||
local memory = {}
|
||||
local allocator = {}
|
||||
|
||||
ffi.cdef([[
|
||||
union Any {
|
||||
@ -465,7 +465,7 @@ do
|
||||
ffi.fill(by_offset(memory.data, old), new - old, 0)
|
||||
end
|
||||
|
||||
function memory.new(min, max)
|
||||
function allocator.new(min, max)
|
||||
local data = ffi.C.calloc(max, WASM_PAGE_SIZE)
|
||||
|
||||
assert(data ~= nil, "failed to allocate")
|
||||
@ -475,11 +475,11 @@ do
|
||||
return ffi.gc(memory, finalizer)
|
||||
end
|
||||
|
||||
function memory.init(memory, addr, data)
|
||||
function allocator.init(memory, addr, data)
|
||||
ffi.copy(by_offset(memory.data, addr), data, #data - 1)
|
||||
end
|
||||
|
||||
function memory.grow(memory, num)
|
||||
function allocator.grow(memory, num)
|
||||
local old = memory.min
|
||||
local new = old + num
|
||||
|
||||
@ -495,7 +495,7 @@ do
|
||||
|
||||
module.load = load
|
||||
module.store = store
|
||||
module.memory = memory
|
||||
module.allocator = allocator
|
||||
end
|
||||
|
||||
return module
|
||||
|
@ -239,7 +239,7 @@ end
|
||||
do
|
||||
local load = {}
|
||||
local store = {}
|
||||
local memory = {}
|
||||
local allocator = {}
|
||||
|
||||
local function rip_u64(x)
|
||||
return math.floor(x / 0x100000000), x % 0x100000000
|
||||
@ -327,11 +327,11 @@ do
|
||||
store.i32(memory, addr + 4, hi)
|
||||
end
|
||||
|
||||
function memory.new(min, max)
|
||||
function allocator.new(min, max)
|
||||
return { min = min, max = max, data = {} }
|
||||
end
|
||||
|
||||
function memory.init(memory, offset, data)
|
||||
function allocator.init(memory, offset, data)
|
||||
local store_i8 = module.store.i32_n8
|
||||
local store_i32 = module.store.i32
|
||||
|
||||
@ -351,7 +351,7 @@ do
|
||||
end
|
||||
end
|
||||
|
||||
function memory.grow(memory, num)
|
||||
function allocator.grow(memory, num)
|
||||
local old = memory.min
|
||||
local new = old + num
|
||||
|
||||
@ -366,7 +366,7 @@ do
|
||||
|
||||
module.load = load
|
||||
module.store = store
|
||||
module.memory = memory
|
||||
module.allocator = allocator
|
||||
end
|
||||
|
||||
return module
|
||||
|
@ -148,7 +148,7 @@ impl Driver for MemorySize {
|
||||
|
||||
impl Driver for MemoryGrow {
|
||||
fn visit(&self, v: &mut Visitor, w: Writer) -> Result<()> {
|
||||
write!(w, "rt.memory.grow(memory_at_{}, ", self.memory)?;
|
||||
write!(w, "rt.allocator.grow(memory_at_{}, ", self.memory)?;
|
||||
self.value.visit(v, w)?;
|
||||
write!(w, ")")
|
||||
}
|
||||
@ -645,7 +645,7 @@ impl<'a> LuaJIT<'a> {
|
||||
|
||||
write!(w, "\"")?;
|
||||
|
||||
write!(w, "rt.memory.init(target, offset, data)")?;
|
||||
write!(w, "rt.allocator.init(target, offset, data)")?;
|
||||
|
||||
write!(w, "end ")?;
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ impl Driver for MemorySize {
|
||||
|
||||
impl Driver for MemoryGrow {
|
||||
fn visit(&self, v: &mut Visitor, w: Writer) -> Result<()> {
|
||||
write!(w, "rt.memory.grow(memory_at_{}, ", self.memory)?;
|
||||
write!(w, "rt.allocator.grow(memory_at_{}, ", self.memory)?;
|
||||
self.value.visit(v, w)?;
|
||||
write!(w, ")")
|
||||
}
|
||||
@ -642,7 +642,7 @@ impl<'a> Luau<'a> {
|
||||
|
||||
write!(w, "\"")?;
|
||||
|
||||
write!(w, "rt.memory.init(target, offset, data)")?;
|
||||
write!(w, "rt.allocator.init(target, offset, data)")?;
|
||||
|
||||
write!(w, "end ")?;
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ pub fn write_memory_init(limit: &ResizableLimits, w: Writer) -> Result<()> {
|
||||
let a = limit.initial();
|
||||
let b = new_limit_max(limit);
|
||||
|
||||
write!(w, "rt.memory.new({}, {})", a, b)
|
||||
write!(w, "rt.allocator.new({}, {})", a, b)
|
||||
}
|
||||
|
||||
pub fn write_func_name(wasm: &Module, index: u32, offset: u32, w: Writer) -> Result<()> {
|
||||
|
Loading…
x
Reference in New Issue
Block a user