@@ -739,7 +739,7 @@ void lauf_asm_inst_call(lauf_asm_builder* b, const lauf_asm_function* callee)
739739
740740 LAUF_BUILD_ASSERT (b->cur ->vstack .pop (callee->sig .input_count ), " missing input values for call" );
741741
742- auto offset = lauf::compress_pointer_offset (b->fn , callee);
742+ auto offset = lauf::new_compress_pointer_offset (b->fn , callee);
743743 b->cur ->insts .push_back (*b, LAUF_BUILD_INST_OFFSET (call, offset));
744744
745745 b->cur ->vstack .push_output (*b, callee->sig .output_count );
@@ -777,7 +777,7 @@ void lauf_asm_inst_call_indirect(lauf_asm_builder* b, lauf_asm_signature sig)
777777 if (auto callee = get_constant_function (b->mod , *fn_addr, sig))
778778 {
779779 add_pop_top_n (b, 1 );
780- auto offset = lauf::compress_pointer_offset (b->fn , callee);
780+ auto offset = lauf::new_compress_pointer_offset (b->fn , callee);
781781 b->cur ->insts .push_back (*b, LAUF_BUILD_INST_OFFSET (call, offset));
782782 }
783783 else
@@ -793,7 +793,7 @@ namespace
793793{
794794void add_call_builtin (lauf_asm_builder* b, lauf_runtime_builtin_function callee)
795795{
796- auto offset = lauf::compress_pointer_offset (&lauf_runtime_builtin_dispatch, callee.impl );
796+ auto offset = lauf::new_compress_pointer_offset (&lauf_runtime_builtin_dispatch, callee.impl );
797797 if ((callee.flags & LAUF_RUNTIME_BUILTIN_NO_PROCESS) != 0
798798 && (callee.flags & LAUF_RUNTIME_BUILTIN_NO_PANIC) != 0 )
799799 b->cur ->insts .push_back (*b, LAUF_BUILD_INST_OFFSET (call_builtin_no_regs, offset));
@@ -1021,10 +1021,12 @@ void lauf_asm_inst_global_addr(lauf_asm_builder* b, const lauf_asm_global* globa
10211021
10221022 b->cur ->insts .push_back (*b, LAUF_BUILD_INST_VALUE (global_addr, global->allocation_idx ));
10231023 b->cur ->vstack .push_constant (*b, [&] {
1024- lauf_runtime_value result;
1025- LAUF_BITFIELD_CONVERSION (result.as_address .allocation = global->allocation_idx );
1026- result.as_address .offset = 0 ;
1027- result.as_address .generation = 0 ; // Always true for globals.
1024+ lauf_runtime_value result;
1025+ lauf_runtime_address addr;
1026+ LAUF_BITFIELD_CONVERSION (addr.allocation = global->allocation_idx );
1027+ addr.offset = 0 ;
1028+ addr.generation = 0 ; // Always true for globals.
1029+ result.as_address = lauf_runtime_address_to_store (addr);
10281030 return result;
10291031 }());
10301032}
@@ -1048,7 +1050,7 @@ void lauf_asm_inst_function_addr(lauf_asm_builder* b, const lauf_asm_function* f
10481050{
10491051 LAUF_BUILD_CHECK_CUR;
10501052
1051- auto offset = lauf::compress_pointer_offset (b->fn , function);
1053+ auto offset = lauf::new_compress_pointer_offset (b->fn , function);
10521054 b->cur ->insts .push_back (*b, LAUF_BUILD_INST_OFFSET (function_addr, offset));
10531055 b->cur ->vstack .push_constant (*b, [&] {
10541056 lauf_runtime_value result;
@@ -1288,7 +1290,7 @@ load_store_constant load_store_constant_folding(lauf_asm_module* mod,
12881290 // TOCTOU is okay, we just can't constant fold because of it.
12891291 auto globals = lauf::get_globals (mod);
12901292
1291- auto constant_addr = addr.as_constant .as_address ;
1293+ auto constant_addr = lauf_runtime_address_from_store ( addr.as_constant .as_address ) ;
12921294 if (constant_addr.allocation >= globals.count && constant_addr.generation != 0
12931295 && constant_addr.offset != 0 )
12941296 return load_store_dynamic;
@@ -1330,8 +1332,10 @@ void lauf_asm_inst_load_field(lauf_asm_builder* b, lauf_asm_type type, size_t fi
13301332 else if (constant_folding == load_store_global)
13311333 {
13321334 add_pop_top_n (b, 1 );
1333- b->cur ->insts .push_back (*b, LAUF_BUILD_INST_VALUE (load_global_value,
1334- addr->as_constant .as_address .allocation ));
1335+ b->cur ->insts .push_back ( //
1336+ *b, LAUF_BUILD_INST_VALUE ( //
1337+ load_global_value,
1338+ lauf_runtime_address_from_store (addr->as_constant .as_address ).allocation ));
13351339 b->cur ->vstack .push_output (*b, 1 );
13361340 }
13371341 else if (type.layout .size == 0 && type.load_fn == nullptr )
@@ -1374,8 +1378,10 @@ void lauf_asm_inst_store_field(lauf_asm_builder* b, lauf_asm_type type, size_t f
13741378 else if (constant_folding == load_store_global)
13751379 {
13761380 add_pop_top_n (b, 1 );
1377- b->cur ->insts .push_back (*b, LAUF_BUILD_INST_VALUE (store_global_value,
1378- addr->as_constant .as_address .allocation ));
1381+ b->cur ->insts .push_back ( //
1382+ *b, LAUF_BUILD_INST_VALUE ( //
1383+ store_global_value,
1384+ lauf_runtime_address_from_store (addr->as_constant .as_address ).allocation ));
13791385 LAUF_BUILD_ASSERT (b->cur ->vstack .pop (1 ), " missing value" );
13801386 }
13811387 else if (type.layout .size == 0 && type.store_fn == nullptr )
0 commit comments