if(to_boolean(labels.value()))
fixup_labels(labels.as<array>().untagged(),compiled);
- compiled->stack_frame_size = frame_size_untagged;
+ compiled->set_stack_frame_size(frame_size_untagged);
/* Once we are ready, fill in literal and word references in this code
block's instruction operands. In most cases this is done right after this
struct code_block
{
// header format (bits indexed with least significant as zero):
- // bit 0 : free?
- // bits 1- 2: type (as a code_block_type)
- // bits 4- : code size / 16
+ // bit 0 : free?
+ // bits 1-2: type (as a code_block_type)
+ // if not free:
+ // bits 3-23: code size / 8
+ // bits 24-31: stack frame size / 16
+ // if free:
+ // bits 3-end: code size / 8
cell header;
cell owner; /* tagged pointer to word, quotation or f */
cell parameters; /* tagged pointer to array or f */
cell relocation; /* tagged pointer to byte-array or f */
- cell stack_frame_size;
- cell pad;
bool free_p() const
{
cell size() const
{
- cell size = header & ~7;
+ cell size;
+ if (free_p())
+ size = header & ~7;
+ else
+ size = header & 0xFFFFF8;
FACTOR_ASSERT(size > 0);
return size;
}
+ cell stack_frame_size() const
+ {
+ if (free_p())
+ return 0;
+ else
+ return (header >> 20) & 0xFF0;
+ }
+
+ void set_stack_frame_size(cell frame_size)
+ {
+ FACTOR_ASSERT(size() < 0xFFFFFF);
+ FACTOR_ASSERT(!free_p());
+ FACTOR_ASSERT(frame_size % 16 == 0);
+ FACTOR_ASSERT(frame_size <= 0xFF0);
+ header = (header & 0xFFFFFF) | (frame_size << 20);
+ }
+
template<typename Fixup> cell size(Fixup fixup) const
{
return size();
std::cout << std::hex << (cell)scan << std::dec << " ";
std::cout << std::hex << size << std::dec << " ";
std::cout << status << " ";
- std::cout << "stack frame " << scan->stack_frame_size;
+ std::cout << "stack frame " << scan->stack_frame_size();
std::cout << std::endl;
}
}