Faster way of zeroing memory
This commit is contained in:
parent
0065d37c58
commit
26e512a540
2 changed files with 5 additions and 2 deletions
|
|
@ -277,6 +277,7 @@ CPU.prototype.wasm_patch = function()
|
|||
this.codegen_finalize_finished = get_import("codegen_finalize_finished");
|
||||
|
||||
this.allocate_memory = get_import("allocate_memory");
|
||||
this.zero_memory = get_import("zero_memory");
|
||||
|
||||
this.zstd_create_ctx = get_import("zstd_create_ctx");
|
||||
this.zstd_get_src_ptr = get_import("zstd_get_src_ptr");
|
||||
|
|
@ -534,8 +535,7 @@ CPU.prototype.pack_memory = function()
|
|||
|
||||
CPU.prototype.unpack_memory = function(bitmap, packed_memory)
|
||||
{
|
||||
// TODO: Skip zeroing memory if the memory has just been allocated
|
||||
this.mem8.fill(0);
|
||||
this.zero_memory(this.memory_size[0]);
|
||||
|
||||
const page_count = this.memory_size[0] >> 12;
|
||||
let packed_page = 0;
|
||||
|
|
|
|||
|
|
@ -33,6 +33,9 @@ pub fn allocate_memory(size: u32) -> u32 {
|
|||
ptr
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe fn zero_memory(size: u32) { ptr::write_bytes(mem8, 0, size as usize); }
|
||||
|
||||
#[no_mangle]
|
||||
pub fn in_mapped_range(addr: u32) -> bool {
|
||||
return addr >= 0xA0000 && addr < 0xC0000 || addr >= unsafe { *memory_size };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue