capi::Handle* ObjectHeader::handle(STATE) { HeaderWord orig = header; switch(orig.f.meaning) { case eAuxWordHandle: return state->memory()->capi_handles()->find_index(orig.f.aux_word); case eAuxWordInflated: return header_to_inflated_header(state, orig)->handle(state); default: return NULL; } }
uint32_t object_id(STATE) { // Pull this out into a local so that we don't see any concurrent // changes to header. HeaderWord tmp = header; switch(tmp.f.meaning) { case eAuxWordObjID: return tmp.f.aux_word; case eAuxWordInflated: return header_to_inflated_header(state, tmp)->object_id(state); default: return 0; } }
capi::Handle* ObjectHeader::handle(STATE) { HeaderWord tmp = header; if(tmp.f.inflated) { return header_to_inflated_header(tmp)->handle(state); } capi::Handle* h = NULL; switch(tmp.f.meaning) { case eAuxWordHandle: h = state->shared().global_handles()->find_index(state, tmp.f.aux_word); return h; default: return NULL; } }
void ObjectHeader::mark(ObjectMemory* om, unsigned int which) { for(;;) { HeaderWord orig = header; HeaderWord new_val = orig; new_val.f.Marked = which; if(header.atomic_set(orig, new_val)) { // Mark the inflated header so the GC can see it's used if(new_val.f.meaning == eAuxWordInflated) { header_to_inflated_header(om, new_val)->mark(om, which); } return; } } }
void ObjectHeader::clear_handle(STATE) { for(;;) { HeaderWord orig = header; if(orig.f.meaning == eAuxWordInflated) { header_to_inflated_header(state, orig)->clear_handle(state); return; } orig.f.meaning = eAuxWordHandle; HeaderWord new_val = orig; new_val.f.meaning = eAuxWordEmpty; new_val.f.aux_word = 0; if(header.atomic_set(orig, new_val)) return; } }
InflatedHeader* inflated_header(STATE) const { return header_to_inflated_header(state, header); }
InflatedHeader* inflated_header() const { return header_to_inflated_header(header); }