4 /* The compiled code heap is structured into blocks. */
8 cell owner; /* tagged pointer to word, quotation or f */
9 cell parameters; /* tagged pointer to array or f */
10 cell relocation; /* tagged pointer to byte-array or f */
14 return (header & 1) == 1;
17 code_block_type type() const
19 return (code_block_type)((header >> 1) & 0x3);
22 void set_type(code_block_type type)
24 header = ((header & ~0x7) | (type << 1));
29 return type() == code_block_pic;
32 bool optimized_p() const
34 return type() == code_block_optimized;
39 cell size = header & ~7;
41 FACTOR_ASSERT(size > 0);
46 template<typename Fixup> cell size(Fixup fixup) const
51 void *entry_point() const
53 return (void *)(this + 1);
56 /* GC info is stored at the end of the block */
57 gc_info *block_gc_info() const
59 return (gc_info *)((u8 *)this + size() - sizeof(gc_info));
64 factor::flush_icache((cell)this,size());
67 template<typename Iterator> void each_instruction_operand(Iterator &iter)
69 if(to_boolean(relocation))
71 byte_array *rels = (byte_array *)UNTAG(relocation);
74 cell length = (rels->capacity >> TAG_BITS) / sizeof(relocation_entry);
76 for(cell i = 0; i < length; i++)
78 relocation_entry rel = rels->data<relocation_entry>()[i];
79 iter(instruction_operand(rel,this,index));
80 index += rel.number_of_parameters();
86 VM_C_API void undefined_symbol(void);
88 inline code_block *word::code() const {
89 FACTOR_ASSERT(entry_point != NULL);
90 return (code_block*)entry_point - 1;
93 inline code_block *quotation::code() const {
94 FACTOR_ASSERT(entry_point != NULL);
95 return (code_block*)entry_point - 1;