namespace factor {
+cell code_block_owner(code_block* compiled) {
+ 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 (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;
+}
+
+cell compute_entry_point_address(cell obj) {
+ switch (TAG(obj)) {
+ case WORD_TYPE:
+ return untag<word>(obj)->entry_point;
+ case QUOTATION_TYPE:
+ return untag<quotation>(obj)->entry_point;
+ default:
+ critical_error("Expected word or quotation", obj);
+ return 0;
+ }
+}
+
cell code_block::owner_quot() const {
if (!optimized_p() && TAG(owner) == WORD_TYPE)
return untag<word>(owner)->def;
return tag_fixnum(vm->quot_code_offset_to_scan(ptr, ofs));
}
-cell factor_vm::compute_entry_point_address(cell obj) {
- switch (TAG(obj)) {
- case WORD_TYPE:
- return untag<word>(obj)->entry_point;
- case QUOTATION_TYPE:
- return untag<quotation>(obj)->entry_point;
- default:
- critical_error("Expected word or quotation", obj);
- return 0;
- }
-}
-
cell factor_vm::compute_entry_point_pic_address(word* w, cell tagged_quot) {
if (!to_boolean(tagged_quot) || max_pic_size == 0)
return w->entry_point;
return compute_entry_point_pic_address(w.untagged(), w->pic_tail_def);
}
-cell factor_vm::code_block_owner(code_block* compiled) {
- 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 (TAG(owner) != QUOTATION_TYPE)
- return owner;
-
- quotation* quot = untag<quotation>(owner);
- array* elements = untag<array>(quot->array);
-
- FACTOR_ASSERT(array_capacity(elements) == 5);
- FACTOR_ASSERT(array_nth(elements, 4) == special_objects[PIC_MISS_WORD] ||
- array_nth(elements, 4) == special_objects[PIC_MISS_TAIL_WORD]);
- wrapper* wrap = untag<wrapper>(array_nth(elements, 0));
- return wrap->object;
-}
-
struct update_word_references_relocation_visitor {
factor_vm* parent;
bool reset_inline_caches;
case RT_ENTRY_POINT: {
cell owner = compiled->owner;
if (to_boolean(owner))
- op.store_value(parent->compute_entry_point_address(owner));
+ op.store_value(compute_entry_point_address(owner));
break;
}
case RT_ENTRY_POINT_PIC: {
if (reset_inline_caches || !compiled->pic_p()) {
- cell owner = parent->code_block_owner(compiled);
+ cell owner = code_block_owner(compiled);
if (to_boolean(owner))
op.store_value(parent->compute_entry_point_pic_address(owner));
}
}
case RT_ENTRY_POINT_PIC_TAIL: {
if (reset_inline_caches || !compiled->pic_p()) {
- cell owner = parent->code_block_owner(compiled);
+ cell owner = code_block_owner(compiled);
if (to_boolean(owner))
op.store_value(parent->compute_entry_point_pic_tail_address(owner));
}
case RT_LITERAL:
return next_literal();
case RT_ENTRY_POINT:
- return parent->compute_entry_point_address(next_literal());
+ return compute_entry_point_address(next_literal());
case RT_ENTRY_POINT_PIC:
return parent->compute_entry_point_pic_address(next_literal());
case RT_ENTRY_POINT_PIC_TAIL:
namespace factor {
+/* Size of the object pointed to by a tagged pointer */
+cell object_size(cell tagged) {
+ if (immediate_p(tagged))
+ return 0;
+ return untag<object>(tagged)->size();
+}
+
void factor_vm::primitive_special_object() {
fixnum n = untag_fixnum(ctx->peek());
ctx->replace(special_objects[n]);
/* Allocates memory */
void factor_vm::primitive_clone() { ctx->replace(clone_object(ctx->peek())); }
-/* Size of the object pointed to by a tagged pointer */
-cell factor_vm::object_size(cell tagged) {
- if (immediate_p(tagged))
- return 0;
- return untag<object>(tagged)->size();
-}
-
/* Allocates memory */
void factor_vm::primitive_size() {
ctx->replace(from_unsigned_cell(object_size(ctx->peek())));
void primitive_identity_hashcode();
void compute_identity_hashcode(object* obj);
void primitive_compute_identity_hashcode();
- cell object_size(cell tagged);
cell clone_object(cell obj_);
void primitive_clone();
void primitive_become();
void primitive_fclose();
// code_block
- cell compute_entry_point_address(cell obj);
cell compute_entry_point_pic_address(word* w, cell tagged_quot);
cell compute_entry_point_pic_address(cell w_);
cell compute_entry_point_pic_tail_address(cell w_);
cell compute_external_address(instruction_operand op);
- cell code_block_owner(code_block* compiled);
void update_word_references(code_block* compiled, bool reset_inline_caches);
void undefined_symbol();
cell compute_dlsym_address(array* literals, cell index, bool toc);