Object* ObjectMemory::new_object_fast(Class* cls, size_t bytes, object_type type) { if(Object* obj = young_->raw_allocate(bytes, &collect_young_now)) { if(collect_young_now) state->interrupts.set_perform_gc(); obj->init_header(cls, YoungObjectZone, type); obj->clear_fields(bytes); return obj; } else { return new_object_typed(cls, bytes, type); } }
T* new_object_variable(STATE, Class* cls, size_t fields, size_t& bytes) { bytes = sizeof(T) + (fields * sizeof(Object*)); return static_cast<T*>(new_object_typed(state, cls, bytes, T::type)); }
T* new_object_bytes(STATE, Class* cls, size_t& bytes) { bytes = ObjectHeader::align(sizeof(T) + bytes); T* obj = static_cast<T*>(new_object_typed(state, cls, bytes, T::type)); return obj; }
T* new_object_bytes(Class* cls, size_t& bytes) { bytes = ObjectHeader::align(sizeof(T) + bytes); return static_cast<T*>(new_object_typed(cls, bytes, T::type)); }
T* new_object(Class *cls) { return static_cast<T*>(new_object_typed(cls, sizeof(T), T::type)); }
T* new_struct(Class* cls, size_t bytes = 0) { T* obj = reinterpret_cast<T*>(new_object_typed(cls, sizeof(T) + bytes, T::type)); return obj; }
T* new_object(Class *cls) { return reinterpret_cast<T*>(new_object_typed(cls, sizeof(T), T::type)); }
T* new_object_variable(Class* cls, size_t fields, size_t& bytes) { bytes = T::fields_offset + (fields * sizeof(Object*)); return static_cast<T*>(new_object_typed(cls, bytes, T::type)); }
T* new_object_variable(Class* cls, size_t fields, size_t& bytes) { bytes = sizeof(T) + (fields * sizeof(Object*)); return reinterpret_cast<T*>(new_object_typed(cls, bytes, T::type)); }
T* new_object_bytes(Class* cls, size_t& bytes) { bytes = ObjectHeader::align(sizeof(T) + bytes); T* obj = reinterpret_cast<T*>(new_object_typed(cls, bytes, T::type)); return obj; }
Object* VM::new_object_from_type(Class* cls, TypeInfo* ti) { return new_object_typed(cls, ti->instance_size, ti->type); }