From: Brendan Hansen Date: Mon, 27 Jul 2020 15:50:17 +0000 (-0500) Subject: not filling the binary with thousands of unnecessary zeros X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=bf396284e6e6820312a6fdfa948026fc09cc0daf;p=onyx.git not filling the binary with thousands of unnecessary zeros --- diff --git a/onyx b/onyx index b644cefb..cbe7e0ba 100755 Binary files a/onyx and b/onyx differ diff --git a/progs/ez.onyx b/progs/ez.onyx index 947baca2..e4f056cb 100644 --- a/progs/ez.onyx +++ b/progs/ez.onyx @@ -13,10 +13,15 @@ Foo :: struct { st : SomeType; } -foo_sum :: proc (use foo: ^Foo) -> i32 { +foo_sum :: proc (use this: ^Foo) -> i32 { + this.foo_other(); return x + y; } +foo_other :: proc (use this: ^Foo) { + print(st as i32); +} + asdf :: proc (pa: PrintableArray) { for i: 0, pa.len print(pa.data[i] as i32); } @@ -32,18 +37,18 @@ print_st :: proc (st: SomeType, other: i32) { print(st as i32); } -single_int : u8 +single_int : u32 -array : [N] Foo N :: 1024 +array : [N] Foo proc #export "main" { print("Hello World! this is slightly longer\n"); print(__heap_start as i32); - single_int = 10 as u8; - print(single_int as i32); + single_int = 10; + print(single_int); array[4].y = 1234; print(array[4].y); diff --git a/progs/ufc.onyx b/progs/ufc.onyx index 50cd18c1..fb88f6ac 100644 --- a/progs/ufc.onyx +++ b/progs/ufc.onyx @@ -64,10 +64,6 @@ dot :: proc (v: Vec2, u: Vec2) -> f32 { return v.x * u.x + v.y * u.y; } -asdf :: proc (use v: ^Vec2, use u: ^Vec2) -> f32 { - return x + x; -} - // SomeType :: enum (u32) { Value1, Value2 } diff --git a/src/onyxwasm.c b/src/onyxwasm.c index aa03c2d7..409fb1d0 100644 --- a/src/onyxwasm.c +++ b/src/onyxwasm.c @@ -1358,19 +1358,16 @@ static void compile_memory_reservation(OnyxWasmModule* mod, AstMemRes* memres) { offset += alignment - (offset % alignment); } - ptr data = bh_alloc_array(global_heap_allocator, i8, size); - memset(data, 0, size); - - WasmDatum datum = { - .offset = offset, - .length = size, - .data = data - }; + // WasmDatum datum = { + // .offset = offset, + // .length = size, + // .data = NULL + // }; memres->addr = offset; mod->next_datum_offset = offset + size; - bh_arr_push(mod->data, datum); + // bh_arr_push(mod->data, datum); } OnyxWasmModule onyx_wasm_module_create(bh_allocator alloc) { @@ -1948,6 +1945,8 @@ static i32 output_datasection(OnyxWasmModule* module, bh_buffer* buff) { bh_buffer_append(&vec_buff, leb, leb_len); bh_arr_each(WasmDatum, datum, module->data) { + if (datum->data == NULL) continue; + // NOTE: 0x00 memory index bh_buffer_write_byte(&vec_buff, 0x00);