Skip to content

Commit

Permalink
WIP: visit object hashes
Browse files Browse the repository at this point in the history
  • Loading branch information
ggreif committed Jan 13, 2025
1 parent 6498fe3 commit f1e37a1
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions src/codegen/compile_classical.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2191,8 +2191,7 @@ module Tagged = struct
E.else_trap_with env "missing object forwarding" ^^
get_object ^^
(if unskewed then
compile_unboxed_const ptr_unskew ^^
G.i (Binary (Wasm.Values.I32 I32Op.Add))
compile_add_const ptr_unskew
else G.nop))
else G.nop)

Expand Down Expand Up @@ -4146,6 +4145,30 @@ module Object = struct
get_ri ^^
Tagged.allocation_barrier env

(* Invoke supplied code for each runtime hash, with object on stack *)
let iterate_hashes env code =
let set_x, get_x = new_local env "obj/count" in
let set_h_ptr, get_h_ptr = new_local env "h_ptr" in

set_x ^^ get_x ^^ Tagged.load_forwarding_pointer env ^^ set_x ^^
get_x ^^ Tagged.load_field env (hash_ptr_field env) ^^

compile_add_const ptr_unskew ^^ set_h_ptr ^^
get_x ^^ Tagged.load_field env (size_field env) ^^ set_x ^^ (* now count *)
(* Linearly scan through the hashes *)
G.loop0 (
get_x ^^
G.if0
begin
get_h_ptr ^^ load_unskewed_ptr ^^
code ^^
get_h_ptr ^^ compile_add_const Heap.word_size ^^ set_h_ptr ^^
get_x ^^ compile_sub_const 1l ^^ set_x ^^
G.i (Br (nr 1l))
end
G.nop
)

(* Returns a pointer to the object field (without following the field indirection) *)
let idx_hash_raw env low_bound =
let name = Printf.sprintf "obj_idx<%d>" low_bound in
Expand Down

0 comments on commit f1e37a1

Please sign in to comment.