void VariableScope::Info::visit(Object* obj, ObjectVisitor& visit) { auto_visit(obj, visit); VariableScope* vs = as<VariableScope>(obj); if(!vs->isolated()) { Object** ary = vs->stack_locals(); if(Fiber* fib = try_as<Fiber>(vs->fiber())) { FiberData* data = fib->data(); AddressDisplacement dis(data->data_offset(), data->data_lower_bound(), data->data_upper_bound()); ary = dis.displace(ary); } size_t locals = vs->number_of_locals(); for(size_t i = 0; i < locals; i++) { visit.call(ary[i]); } } }
void VariableScope::Info::mark(Object* obj, ObjectMark& mark) { auto_mark(obj, mark); VariableScope* vs = as<VariableScope>(obj); vs->fixup(); if(!vs->isolated()) { Object** ary = vs->stack_locals(); if(Fiber* fib = try_as<Fiber>(vs->fiber())) { FiberData* data = fib->data(); AddressDisplacement dis(data->data_offset(), data->data_lower_bound(), data->data_upper_bound()); ary = dis.displace(ary); } size_t locals = vs->number_of_locals(); for(size_t i = 0; i < locals; i++) { Object* tmp = mark.call(ary[i]); if(tmp) { ary[i] = tmp; } } } }
Object* VariableScope::get_local(int pos) { Object** ary = locals_; if(Fiber* fib = try_as<Fiber>(fiber_)) { FiberData* data = fib->data(); if(data) { AddressDisplacement dis(data->data_offset(), data->data_lower_bound(), data->data_upper_bound()); ary = dis.displace(ary); } } return ary[pos]; }
void FiberStacks::gc_scan(GarbageCollector* gc) { for(Datas::iterator i = datas_.begin(); i != datas_.end(); ++i) { FiberData* data = *i; if(data->dead_p()) continue; AddressDisplacement dis(data->data_offset(), data->data_lower_bound(), data->data_upper_bound()); if(CallFrame* cf = data->call_frame()) { gc->walk_call_frame(cf, &dis); } gc->scan(data->variable_root_buffers(), false, &dis); } }