vm: move binary_payload_start() method from factor_vm to object class
parent
29a27cfde4
commit
03f4b4cdd6
|
@ -209,7 +209,7 @@ template<typename TargetGeneration, typename Policy> struct collector {
|
||||||
if(end < card_start_address(card_index))
|
if(end < card_start_address(card_index))
|
||||||
{
|
{
|
||||||
start = gen->starts.find_object_containing_card(card_index - gen_start_card);
|
start = gen->starts.find_object_containing_card(card_index - gen_start_card);
|
||||||
binary_start = start + parent->binary_payload_start((object *)start);
|
binary_start = start + ((object *)start)->binary_payload_start();
|
||||||
end = start + ((object *)start)->size();
|
end = start + ((object *)start)->size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,7 +229,7 @@ scan_next_object: {
|
||||||
start = gen->next_object_after(start);
|
start = gen->next_object_after(start);
|
||||||
if(start)
|
if(start)
|
||||||
{
|
{
|
||||||
binary_start = start + parent->binary_payload_start((object *)start);
|
binary_start = ((object *)start)->binary_payload_start();
|
||||||
end = start + ((object *)start)->size();
|
end = start + ((object *)start)->size();
|
||||||
goto scan_next_object;
|
goto scan_next_object;
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,17 +159,12 @@ cell object::size() const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void factor_vm::primitive_size()
|
|
||||||
{
|
|
||||||
box_unsigned_cell(object_size(dpop()));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* The number of cells from the start of the object which should be scanned by
|
/* The number of cells from the start of the object which should be scanned by
|
||||||
the GC. Some types have a binary payload at the end (string, word, DLL) which
|
the GC. Some types have a binary payload at the end (string, word, DLL) which
|
||||||
we ignore. */
|
we ignore. */
|
||||||
cell factor_vm::binary_payload_start(object *pointer)
|
cell object::binary_payload_start() const
|
||||||
{
|
{
|
||||||
switch(pointer->h.hi_tag())
|
switch(h.hi_tag())
|
||||||
{
|
{
|
||||||
/* these objects do not refer to other objects at all */
|
/* these objects do not refer to other objects at all */
|
||||||
case FLOAT_TYPE:
|
case FLOAT_TYPE:
|
||||||
|
@ -190,17 +185,22 @@ cell factor_vm::binary_payload_start(object *pointer)
|
||||||
return sizeof(string);
|
return sizeof(string);
|
||||||
/* everything else consists entirely of pointers */
|
/* everything else consists entirely of pointers */
|
||||||
case ARRAY_TYPE:
|
case ARRAY_TYPE:
|
||||||
return array_size<array>(array_capacity((array*)pointer));
|
return array_size<array>(array_capacity((array*)this));
|
||||||
case TUPLE_TYPE:
|
case TUPLE_TYPE:
|
||||||
return tuple_size(untag<tuple_layout>(((tuple *)pointer)->layout));
|
return tuple_size(untag<tuple_layout>(((tuple *)this)->layout));
|
||||||
case WRAPPER_TYPE:
|
case WRAPPER_TYPE:
|
||||||
return sizeof(wrapper);
|
return sizeof(wrapper);
|
||||||
default:
|
default:
|
||||||
critical_error("Invalid header",(cell)pointer);
|
critical_error("Invalid header",(cell)this);
|
||||||
return 0; /* can't happen */
|
return 0; /* can't happen */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void factor_vm::primitive_size()
|
||||||
|
{
|
||||||
|
box_unsigned_cell(object_size(dpop()));
|
||||||
|
}
|
||||||
|
|
||||||
/* Push memory usage statistics in data heap */
|
/* Push memory usage statistics in data heap */
|
||||||
void factor_vm::primitive_data_room()
|
void factor_vm::primitive_data_room()
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
namespace factor
|
namespace factor
|
||||||
{
|
{
|
||||||
|
|
||||||
template<typename Array> cell array_capacity(Array *array)
|
template<typename Array> cell array_capacity(const Array *array)
|
||||||
{
|
{
|
||||||
#ifdef FACTOR_DEBUG
|
#ifdef FACTOR_DEBUG
|
||||||
assert(array->h.hi_tag() == Array::type_number);
|
assert(array->h.hi_tag() == Array::type_number);
|
||||||
|
|
|
@ -148,6 +148,7 @@ struct object {
|
||||||
header h;
|
header h;
|
||||||
|
|
||||||
cell size() const;
|
cell size() const;
|
||||||
|
cell binary_payload_start() const;
|
||||||
|
|
||||||
cell *slots() const { return (cell *)this; }
|
cell *slots() const { return (cell *)this; }
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ template<typename Visitor> struct slot_visitor {
|
||||||
void visit_slots(object *ptr)
|
void visit_slots(object *ptr)
|
||||||
{
|
{
|
||||||
cell *slot = (cell *)ptr;
|
cell *slot = (cell *)ptr;
|
||||||
cell *end = (cell *)((cell)ptr + parent->binary_payload_start(ptr));
|
cell *end = (cell *)((cell)ptr + ptr->binary_payload_start());
|
||||||
|
|
||||||
if(slot != end)
|
if(slot != end)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
namespace factor
|
namespace factor
|
||||||
{
|
{
|
||||||
|
|
||||||
inline static cell tuple_size(tuple_layout *layout)
|
inline static cell tuple_size(const tuple_layout *layout)
|
||||||
{
|
{
|
||||||
cell size = untag_fixnum(layout->size);
|
cell size = untag_fixnum(layout->size);
|
||||||
return sizeof(tuple) + size * sizeof(cell);
|
return sizeof(tuple) + size * sizeof(cell);
|
||||||
|
|
|
@ -223,7 +223,6 @@ struct factor_vm
|
||||||
void set_data_heap(data_heap *data_);
|
void set_data_heap(data_heap *data_);
|
||||||
void init_data_heap(cell young_size, cell aging_size, cell tenured_size);
|
void init_data_heap(cell young_size, cell aging_size, cell tenured_size);
|
||||||
void primitive_size();
|
void primitive_size();
|
||||||
cell binary_payload_start(object *pointer);
|
|
||||||
void primitive_data_room();
|
void primitive_data_room();
|
||||||
void begin_scan();
|
void begin_scan();
|
||||||
void end_scan();
|
void end_scan();
|
||||||
|
@ -576,7 +575,7 @@ struct factor_vm
|
||||||
template<typename Iterator> void do_slots(cell obj, Iterator &iter)
|
template<typename Iterator> void do_slots(cell obj, Iterator &iter)
|
||||||
{
|
{
|
||||||
cell scan = obj;
|
cell scan = obj;
|
||||||
cell payload_start = binary_payload_start((object *)obj);
|
cell payload_start = ((object *)obj)->binary_payload_start();
|
||||||
cell end = obj + payload_start;
|
cell end = obj + payload_start;
|
||||||
|
|
||||||
scan += sizeof(cell);
|
scan += sizeof(cell);
|
||||||
|
|
Loading…
Reference in New Issue