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; } } } }
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]); } } }
VariableScope* StackVariables::create_heap_alias(STATE, CallFrame* call_frame, bool full) { if(on_heap_) return on_heap_; MachineCode* mcode = call_frame->compiled_code->machine_code(); VariableScope* scope = state->memory()->new_object<VariableScope>(state, G(variable_scope)); if(parent_) { scope->parent(state, parent_); } else { scope->parent(state, nil<VariableScope>()); } scope->self(state, self_); scope->block(state, block_); scope->module(state, module_); scope->method(state, call_frame->compiled_code); scope->heap_locals(state, nil<Tuple>()); scope->last_match(state, last_match_); scope->fiber(state, state->vm()->thread()->current_fiber()); scope->number_of_locals(mcode->number_of_locals); scope->isolated(0); scope->flags(call_frame->flags); scope->_lock_.init(); if(!full) { scope->isolated(1); scope->heap_locals(state, Tuple::create(state, mcode->number_of_locals)); for(int i = 0; i < scope->number_of_locals(); i++) { scope->set_local(state, i, locals_[i]); } } scope->locals(locals_); scope->dynamic_locals(state, nil<LookupTable>()); on_heap_ = scope; return scope; }
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(); 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(); 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; } } } }