namespace factor {
static cell code_block_owner(code_block* compiled) {
- tagged<object> owner(compiled->owner);
+ cell owner = compiled->owner;
// Cold generic word call sites point to quotations that call the
// inline-cache-miss and inline-cache-miss-tail primitives.
- if (owner.type() == QUOTATION_TYPE) {
- tagged<quotation> quot(owner.as<quotation>());
- tagged<array> elements(quot->array);
-
- FACTOR_ASSERT(array_capacity(elements.untagged()) == 5);
- FACTOR_ASSERT(array_nth(elements.untagged(), 4) ==
- special_objects[PIC_MISS_WORD] ||
- array_nth(elements.untagged(), 4) ==
- special_objects[PIC_MISS_TAIL_WORD]);
-
- tagged<wrapper> word_wrapper(array_nth(elements.untagged(), 0));
- return word_wrapper->object;
- }
- return compiled->owner;
+ if (TAG(owner) != QUOTATION_TYPE)
+ return owner;
+
+ quotation* quot = untag<quotation>(owner);
+ array* elements = untag<array>(quot->array);
+
+ FACTOR_ASSERT(array_capacity(elements) == 5);
+ wrapper* wrap = untag<wrapper>(array_nth(elements, 0));
+ return wrap->object;
}
static cell compute_entry_point_address(cell obj) {
- switch (tagged<object>(obj).type()) {
+ switch (TAG(obj)) {
case WORD_TYPE:
return untag<word>(obj)->entry_point;
case QUOTATION_TYPE:
}
cell code_block::owner_quot() const {
- tagged<object> executing(owner);
- if (type() != CODE_BLOCK_OPTIMIZED && executing->type() == WORD_TYPE)
- executing = executing.as<word>()->def;
- return executing.value();
+ if (type() != CODE_BLOCK_OPTIMIZED && TAG(owner) == WORD_TYPE)
+ return untag<word>(owner)->def;
+ return owner;
}
// If the code block is an unoptimized quotation, we can calculate the
return tag_fixnum(-1);
}
- tagged<object> obj(owner);
- if (obj.type() == WORD_TYPE)
- obj = obj.as<word>()->def;
- if (obj.type() != QUOTATION_TYPE)
+ cell ptr = owner;
+ if (TAG(ptr) == WORD_TYPE)
+ ptr = untag<word>(ptr)->def;
+ if (TAG(ptr) != QUOTATION_TYPE)
return tag_fixnum(-1);
cell ofs = offset(addr);
- return tag_fixnum(vm->quot_code_offset_to_scan(obj.value(), ofs));
+ return tag_fixnum(vm->quot_code_offset_to_scan(ptr, ofs));
}
cell factor_vm::compute_entry_point_pic_address(word* w, cell tagged_quot) {