VM: new function visit_object to replace trace_object
parent
6b29c0ea00
commit
1d251f7b6a
|
@ -25,23 +25,24 @@ struct gc_workhorse : no_fixup {
|
|||
return obj;
|
||||
}
|
||||
|
||||
object* untagged = obj;
|
||||
/* is there another forwarding pointer? */
|
||||
while (untagged->forwarding_pointer_p())
|
||||
untagged = untagged->forwarding_pointer();
|
||||
|
||||
if (!policy.should_copy_p(untagged)) {
|
||||
policy.visited_object(untagged);
|
||||
return untagged;
|
||||
while (obj->forwarding_pointer_p()) {
|
||||
object* dest = obj->forwarding_pointer();
|
||||
obj = dest;
|
||||
}
|
||||
|
||||
cell size = untagged->size();
|
||||
if (!policy.should_copy_p(obj)) {
|
||||
policy.visited_object(obj);
|
||||
return obj;
|
||||
}
|
||||
|
||||
cell size = obj->size();
|
||||
object* newpointer = target->allot(size);
|
||||
if (!newpointer)
|
||||
throw must_start_gc_again();
|
||||
|
||||
memcpy(newpointer, untagged, size);
|
||||
untagged->forward_to(newpointer);
|
||||
memcpy(newpointer, obj, size);
|
||||
obj->forward_to(newpointer);
|
||||
|
||||
policy.promoted_object(newpointer);
|
||||
|
||||
|
@ -80,12 +81,6 @@ template <typename TargetGeneration, typename Policy> struct collector {
|
|||
decks_scanned(0),
|
||||
code_blocks_scanned(0) {}
|
||||
|
||||
void trace_object(object* ptr) {
|
||||
visitor.visit_slots(ptr);
|
||||
if (ptr->type() == ALIEN_TYPE)
|
||||
((alien*)ptr)->update_address();
|
||||
}
|
||||
|
||||
void trace_code_heap_roots(std::set<code_block*>* remembered_set) {
|
||||
std::set<code_block*>::const_iterator iter = remembered_set->begin();
|
||||
std::set<code_block*>::const_iterator end = remembered_set->end();
|
||||
|
|
|
@ -11,7 +11,7 @@ struct copying_collector : collector<TargetGeneration, Policy> {
|
|||
|
||||
void cheneys_algorithm() {
|
||||
while (scan && scan < this->target->here) {
|
||||
this->trace_object((object*)scan);
|
||||
this->visitor.visit_object((object*)scan);
|
||||
scan = this->target->next_object_after(scan);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -144,6 +144,7 @@ template <typename Fixup> struct slot_visitor {
|
|||
void visit_context_code_blocks();
|
||||
void visit_uninitialized_code_blocks();
|
||||
void visit_embedded_code_pointers(code_block* compiled);
|
||||
void visit_object(object* obj);
|
||||
void visit_mark_stack(std::vector<cell>* mark_stack);
|
||||
};
|
||||
|
||||
|
@ -536,6 +537,13 @@ void slot_visitor<Fixup>::visit_embedded_code_pointers(code_block* compiled) {
|
|||
}
|
||||
}
|
||||
|
||||
template <typename Fixup>
|
||||
void slot_visitor<Fixup>::visit_object(object *ptr) {
|
||||
visit_slots(ptr);
|
||||
if (ptr->type() == ALIEN_TYPE)
|
||||
((alien*)ptr)->update_address();
|
||||
}
|
||||
|
||||
/* Pops items from the mark stack and visits them until the stack is
|
||||
empty. Used when doing a full collection and when collecting to
|
||||
tenured space. */
|
||||
|
@ -553,9 +561,7 @@ void slot_visitor<Fixup>::visit_mark_stack(std::vector<cell>* mark_stack) {
|
|||
visit_embedded_code_pointers(compiled);
|
||||
} else {
|
||||
object* obj = (object*)ptr;
|
||||
visit_slots(obj);
|
||||
if (obj->type() == ALIEN_TYPE)
|
||||
((alien*)obj)->update_address();
|
||||
visit_object(obj);
|
||||
visit_object_code_block(obj);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue