Merge branch 'master' of git://factorcode.org/git/factor
commit
5f33a3e44b
|
|
@ -588,5 +588,4 @@ FUNCTION: short ffi_test_48 ( bool-field-test x ) ;
|
|||
! Regression: calling an undefined function would raise a protection fault
|
||||
FUNCTION: void this_does_not_exist ( ) ;
|
||||
|
||||
[ this_does_not_exist ] [ { "kernel-error" 10 f f } = ] must-fail-with
|
||||
|
||||
[ this_does_not_exist ] [ { "kernel-error" 9 f f } = ] must-fail-with
|
||||
|
|
|
|||
|
|
@ -38,13 +38,13 @@ inline cell log2(cell x)
|
|||
#else
|
||||
cell n = 0;
|
||||
#ifdef FACTOR_64
|
||||
if (x >= (u64)1 << 32) { x >>= 32; n += 32; }
|
||||
if (x >= (cell)1 << 32) { x >>= 32; n += 32; }
|
||||
#endif
|
||||
if (x >= (u32)1 << 16) { x >>= 16; n += 16; }
|
||||
if (x >= (u32)1 << 8) { x >>= 8; n += 8; }
|
||||
if (x >= (u32)1 << 4) { x >>= 4; n += 4; }
|
||||
if (x >= (u32)1 << 2) { x >>= 2; n += 2; }
|
||||
if (x >= (u32)1 << 1) { n += 1; }
|
||||
if (x >= (cell)1 << 16) { x >>= 16; n += 16; }
|
||||
if (x >= (cell)1 << 8) { x >>= 8; n += 8; }
|
||||
if (x >= (cell)1 << 4) { x >>= 4; n += 4; }
|
||||
if (x >= (cell)1 << 2) { x >>= 2; n += 2; }
|
||||
if (x >= (cell)1 << 1) { n += 1; }
|
||||
#endif
|
||||
return n;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -196,14 +196,14 @@ template<typename TargetGeneration, typename Policy> struct collector {
|
|||
{
|
||||
card_deck *decks = data->decks;
|
||||
card_deck *cards = data->cards;
|
||||
|
||||
|
||||
cell gen_start_card = addr_to_card(gen->start - data->start);
|
||||
|
||||
cell first_deck = card_deck_for_address(gen->start);
|
||||
cell last_deck = card_deck_for_address(gen->end);
|
||||
|
||||
|
||||
cell start = 0, binary_start = 0, end = 0;
|
||||
|
||||
|
||||
for(cell deck_index = first_deck; deck_index < last_deck; deck_index++)
|
||||
{
|
||||
if(decks[deck_index] & mask)
|
||||
|
|
@ -212,7 +212,7 @@ template<typename TargetGeneration, typename Policy> struct collector {
|
|||
|
||||
cell first_card = first_card_in_deck(deck_index);
|
||||
cell last_card = last_card_in_deck(deck_index);
|
||||
|
||||
|
||||
for(cell card_index = first_card; card_index < last_card; card_index++)
|
||||
{
|
||||
if(cards[card_index] & mask)
|
||||
|
|
@ -225,13 +225,9 @@ template<typename TargetGeneration, typename Policy> struct collector {
|
|||
binary_start = start + ((object *)start)->binary_payload_start();
|
||||
end = start + ((object *)start)->size();
|
||||
}
|
||||
|
||||
#ifdef FACTOR_DEBUG
|
||||
assert(addr_to_card(start - data->start) <= card_index);
|
||||
assert(start < card_end_address(card_index));
|
||||
#endif
|
||||
|
||||
scan_next_object: {
|
||||
scan_next_object: if(start < card_end_address(card_index))
|
||||
{
|
||||
trace_partial_objects(
|
||||
start,
|
||||
binary_start,
|
||||
|
|
@ -248,13 +244,13 @@ scan_next_object: {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
unmarker(&cards[card_index]);
|
||||
|
||||
|
||||
if(!start) return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
unmarker(&decks[deck_index]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -245,10 +245,14 @@ cell factor_vm::instances(cell type)
|
|||
each_object(accum);
|
||||
cell object_count = accum.objects.size();
|
||||
|
||||
gc_off = true;
|
||||
data_roots.push_back(accum.objects[0]);
|
||||
data_roots.push_back(object_count);
|
||||
|
||||
array *objects = allot_array(object_count,false_object);
|
||||
memcpy(objects->data(),&accum.objects[0],object_count * sizeof(cell));
|
||||
gc_off = false;
|
||||
|
||||
data_roots.pop_back();
|
||||
data_roots.pop_back();
|
||||
|
||||
return tag<array>(objects);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ struct data_root : public tagged<Type> {
|
|||
void push()
|
||||
{
|
||||
parent->data_roots.push_back((cell)this);
|
||||
parent->data_roots.push_back(1);
|
||||
}
|
||||
|
||||
explicit data_root(cell value_, factor_vm *parent_)
|
||||
|
|
@ -27,6 +28,10 @@ struct data_root : public tagged<Type> {
|
|||
|
||||
~data_root()
|
||||
{
|
||||
#ifdef FACTOR_DEBUG
|
||||
assert(parent->data_roots.back() == 1);
|
||||
#endif
|
||||
parent->data_roots.pop_back();
|
||||
#ifdef FACTOR_DEBUG
|
||||
assert(parent->data_roots.back() == (cell)this);
|
||||
#endif
|
||||
|
|
|
|||
12
vm/gc.cpp
12
vm/gc.cpp
|
|
@ -218,18 +218,18 @@ void factor_vm::primitive_compact_gc()
|
|||
true /* trace contexts? */);
|
||||
}
|
||||
|
||||
void factor_vm::inline_gc(cell *data_roots_base, cell data_roots_size)
|
||||
void factor_vm::inline_gc(cell data_roots_base, cell data_roots_size)
|
||||
{
|
||||
for(cell i = 0; i < data_roots_size; i++)
|
||||
data_roots.push_back((cell)&data_roots_base[i]);
|
||||
data_roots.push_back(data_roots_base);
|
||||
data_roots.push_back(data_roots_size);
|
||||
|
||||
primitive_minor_gc();
|
||||
|
||||
for(cell i = 0; i < data_roots_size; i++)
|
||||
data_roots.pop_back();
|
||||
data_roots.pop_back();
|
||||
data_roots.pop_back();
|
||||
}
|
||||
|
||||
VM_C_API void inline_gc(cell *data_roots_base, cell data_roots_size, factor_vm *parent)
|
||||
VM_C_API void inline_gc(cell data_roots_base, cell data_roots_size, factor_vm *parent)
|
||||
{
|
||||
parent->inline_gc(data_roots_base,data_roots_size);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,6 +53,6 @@ struct gc_state {
|
|||
void start_again(gc_op op_, factor_vm *parent);
|
||||
};
|
||||
|
||||
VM_C_API void inline_gc(cell *data_roots_base, cell data_roots_size, factor_vm *parent);
|
||||
VM_C_API void inline_gc(cell data_roots_base, cell data_roots_size, factor_vm *parent);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,9 +22,12 @@ void factor_vm::collect_nursery()
|
|||
collector.trace_cards(data->tenured,
|
||||
card_points_to_nursery,
|
||||
simple_unmarker(card_points_to_nursery));
|
||||
collector.trace_cards(data->aging,
|
||||
card_points_to_nursery,
|
||||
full_unmarker());
|
||||
if(data->aging->here != data->aging->start)
|
||||
{
|
||||
collector.trace_cards(data->aging,
|
||||
card_points_to_nursery,
|
||||
full_unmarker());
|
||||
}
|
||||
current_gc->event->ended_card_scan(collector.cards_scanned,collector.decks_scanned);
|
||||
|
||||
current_gc->event->started_code_scan();
|
||||
|
|
|
|||
|
|
@ -8,15 +8,18 @@ template<typename Visitor> struct slot_visitor {
|
|||
explicit slot_visitor<Visitor>(factor_vm *parent_, Visitor visitor_) :
|
||||
parent(parent_), visitor(visitor_) {}
|
||||
|
||||
cell visit_pointer(cell pointer)
|
||||
{
|
||||
object *untagged = untag<object>(pointer);
|
||||
untagged = visitor(untagged);
|
||||
return RETAG(untagged,TAG(pointer));
|
||||
}
|
||||
|
||||
void visit_handle(cell *handle)
|
||||
{
|
||||
cell pointer = *handle;
|
||||
|
||||
if(immediate_p(pointer)) return;
|
||||
|
||||
object *untagged = untag<object>(pointer);
|
||||
untagged = visitor(untagged);
|
||||
*handle = RETAG(untagged,TAG(pointer));
|
||||
if(!immediate_p(pointer))
|
||||
*handle = visit_pointer(pointer);
|
||||
}
|
||||
|
||||
void visit_slots(object *ptr, cell payload_start)
|
||||
|
|
@ -47,8 +50,13 @@ template<typename Visitor> struct slot_visitor {
|
|||
std::vector<cell>::const_iterator iter = parent->data_roots.begin();
|
||||
std::vector<cell>::const_iterator end = parent->data_roots.end();
|
||||
|
||||
for(; iter < end; iter++)
|
||||
visit_handle((cell *)(*iter));
|
||||
while(iter < end)
|
||||
{
|
||||
cell start = *iter++;
|
||||
cell len = *iter++;
|
||||
for(cell index = 0; index < len; index++)
|
||||
visit_handle((cell *)start + index);
|
||||
}
|
||||
}
|
||||
|
||||
void visit_bignum_roots()
|
||||
|
|
|
|||
|
|
@ -281,7 +281,7 @@ struct factor_vm
|
|||
void primitive_minor_gc();
|
||||
void primitive_full_gc();
|
||||
void primitive_compact_gc();
|
||||
void inline_gc(cell *data_roots_base, cell data_roots_size);
|
||||
void inline_gc(cell data_roots_base, cell data_roots_size);
|
||||
void primitive_enable_gc_events();
|
||||
void primitive_disable_gc_events();
|
||||
object *allot_object(header header, cell size);
|
||||
|
|
|
|||
Loading…
Reference in New Issue