Encoding* Encoding::alias(STATE, const char* name, const char* original) { int index = find_index(state, original); if(index < 0) return nil<Encoding>(); Tuple* ref = encoding_reference(state, index, name); encoding_map(state)->store(state, encoding_symbol(state, name), ref); add_constant(state, name, from_index(state, index)); return as<Encoding>(from_index(state, index)); }
T* allocate(bool* needs_gc) { thread::SpinLock::LockGuard lg(lock_); if(free_list_ == (uintptr_t)-1) allocate_chunk(needs_gc); T* t = from_index(free_list_); free_list_ = t->next(); t->clear(); in_use_++; return t; }
uintptr_t allocate_index(bool* needs_gc) { utilities::thread::SpinLock::LockGuard lg(lock_); if(free_list_ == (uintptr_t)-1) allocate_chunk(needs_gc); uintptr_t current_index = free_list_; T* t = from_index(free_list_); free_list_ = t->next(); t->clear(); in_use_++; return current_index; }
Encoding* Encoding::find(STATE, const char* name) { int index = find_index(state, name); if(index < 0) return nil<Encoding>(); return as<Encoding>(from_index(state, index)); }