Fix bulk memory stores
This commit is contained in:
@@ -754,6 +754,19 @@ do
|
||||
ffi.copy(start, data, len or #data)
|
||||
end
|
||||
|
||||
function store.copy(memory_1, addr_1, memory_2, addr_2, len)
|
||||
local start_1 = by_offset(memory_1.data, addr_1)
|
||||
local start_2 = by_offset(memory_2.data, addr_2)
|
||||
|
||||
ffi.copy(start_1, start_2, len)
|
||||
end
|
||||
|
||||
function store.fill(memory, addr, len, value)
|
||||
local start = by_offset(memory.data, addr)
|
||||
|
||||
ffi.fill(start, len, value)
|
||||
end
|
||||
|
||||
local WASM_PAGE_SIZE = 65536
|
||||
|
||||
local function finalizer(memory)
|
||||
@@ -795,19 +808,6 @@ do
|
||||
return old
|
||||
end
|
||||
end
|
||||
|
||||
function allocator.copy(memory, destination, source, length)
|
||||
local destination_addr = by_offset(memory.data, destination)
|
||||
local source_addr = by_offset(memory.data, source)
|
||||
|
||||
ffi.copy(destination_addr, source_addr, length)
|
||||
end
|
||||
|
||||
function allocator.fill(memory, address, value, length)
|
||||
local start = by_offset(memory.data, address)
|
||||
|
||||
ffi.fill(start, length, value)
|
||||
end
|
||||
|
||||
module.load = load
|
||||
module.store = store
|
||||
|
||||
@@ -288,10 +288,14 @@ impl DriverNoContext for MemoryGrow {
|
||||
|
||||
impl DriverNoContext for MemoryCopy {
|
||||
fn write(&self, w: &mut dyn Write) -> Result<()> {
|
||||
let dst = self.dst();
|
||||
let src = self.src();
|
||||
let memory_1 = self.destination().memory();
|
||||
let memory_2 = self.source().memory();
|
||||
|
||||
write!(w, "rt.allocator.copy(memory_at_0, {dst}, {src}, ")?;
|
||||
write!(w, "rt.store.copy(memory_at_{memory_1}, ")?;
|
||||
self.destination().pointer().write(w)?;
|
||||
write!(w, ", memory_at_{memory_2}, ")?;
|
||||
self.source().pointer().write(w)?;
|
||||
write!(w, ", ")?;
|
||||
self.size().write(w)?;
|
||||
write!(w, ")")
|
||||
}
|
||||
@@ -299,14 +303,14 @@ impl DriverNoContext for MemoryCopy {
|
||||
|
||||
impl DriverNoContext for MemoryFill {
|
||||
fn write(&self, w: &mut dyn Write) -> Result<()> {
|
||||
let mem = self.mem();
|
||||
let value = self.value();
|
||||
let n = self.n();
|
||||
let memory = self.destination().memory();
|
||||
|
||||
write!(w, "rt.allocator.fill(memory_at_0, {mem}, ")?;
|
||||
value.write(w)?;
|
||||
write!(w, "rt.store.fill(memory_at_{memory}, ")?;
|
||||
self.destination().pointer().write(w)?;
|
||||
write!(w, ", ")?;
|
||||
n.write(w)?;
|
||||
self.size().write(w)?;
|
||||
write!(w, ", ")?;
|
||||
self.value().write(w)?;
|
||||
write!(w, ")")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user