in source/hack_parallel/hack_parallel/heap/hh_shared.c [1430:1479]
CAMLprim value hh_get_dep(value ocaml_key) {
CAMLparam1(ocaml_key);
check_should_exit();
CAMLlocal2(result, cell);
volatile deptbl_entry_t* const table = deptbl;
// The caller is required to pass a 32-bit node ID.
const uint64_t key64 = Long_val(ocaml_key);
const uint32_t key = (uint32_t)key64;
assert((key & 0x7FFFFFFF) == key64);
result = Val_int(0); // The empty list
for (size_t slot = (size_t)hash_uint64(key);; ++slot) {
slot &= dep_size - 1;
deptbl_entry_t slotval = table[slot];
if (slotval.raw == 0) {
// There are no entries associated with this key.
break;
}
if (slotval.s.key.num == key && slotval.s.key.tag == TAG_KEY) {
// We found the list for 'key', so walk it.
while (slotval.s.next.tag == TAG_NEXT) {
assert(slotval.s.next.num < dep_size);
slotval = table[slotval.s.next.num];
cell = caml_alloc_tuple(2);
Field(cell, 0) = Val_long(slotval.s.key.num);
Field(cell, 1) = result;
result = cell;
}
// The tail of the list is special, "next" is really a value.
cell = caml_alloc_tuple(2);
Field(cell, 0) = Val_long(slotval.s.next.num);
Field(cell, 1) = result;
result = cell;
// We are done!
break;
}
}
CAMLreturn(result);
}