31 size_t size_type_instance, size_page_allocated;
33 assert( POLAR_IS_MEMORY_POOL_PAGE_CLASS(self) );
35 size_type_instance = POLAR_RUNTIME_OBJECT_CLASS(self)->type_definition->size_type_instance;
37 if( size_page_desired != (
size_t)-1 )
39 assert( size_page_desired >= size_type_instance );
43 size_page_desired = size_type_instance;
50 result->page_size = size_page_allocated;
51 polar_runtime_object_preallocated_init(result, POLAR_RUNTIME_OBJECT_CLASS(self)->id_type_class, NO);
55 POLAR_RUNTIME_ERROR->memory_exhausted(POLAR_RUNTIME_OBJECT_CLASS(self)->type_definition->size_type_instance);
69 POLAR_RUNTIME_OBJECT_CLASS(superclass_polar_memory_pool_page)->init( (
polar_runtime_object *)self );
74 self->page_break = ( (
char *)self + OBJC_SIZE_ALIGN(size_instance, OBJC_SIZEOF_POINTER) );
80POLAR_FUNCTION_INTERNAL
void
89 return polar_memory_pool_page_allocate_sized(self, (
size_t)-1);
92POLAR_FUNCTION_INTERNAL
void
95 size_t count_bytes_committed_old, size_instance;
98 size_instance = OBJC_SIZE_ALIGN(size_instance, OBJC_SIZEOF_POINTER);
100 count_bytes_committed_old = polar_memory_pool_page_get_bytes_committed(self) - size_instance;
101 self->page_break = ( (
char *)self + size_instance );
103 objc_memzero( self->page_break, count_bytes_committed_old );
106POLAR_FUNCTION_INTERNAL
void
110 superclass_polar_memory_pool_page = POLAR_RUNTIME_OBJECT_CLASS(self)->class_superclass;
116 (polar_func_runtime_object_deallocate)_polar_memory_pool_page_deallocate;
119 (polar_func_runtime_object_allocate)_polar_memory_pool_page_allocate;
121 self->clear = _polar_memory_pool_page_clear;
126 .name_type =
"polar_memory_pool_page",
129 .type_class_init = (polar_func_runtime_object_class_lifecycle)_polar_memory_pool_page_class_init
134POLAR_FUNCTION_INTERNAL OBJC_FUNCTION_CONSTANT polar_internal_type
135polar_memory_pool_page_get_type(
void )
137 static polar_internal_type pt_polar_memory_pool_page = POLAR_INTERNAL_TYPE_INVALID;
139 if( pt_polar_memory_pool_page != POLAR_INTERNAL_TYPE_INVALID )
140 return pt_polar_memory_pool_page;
142 pt_polar_memory_pool_page = polar_internal_type_init( POLAR_TYPE_LIST_NODE, &class_polar_memory_pool_page,
143 &pti_polar_memory_pool_page );
145 return pt_polar_memory_pool_page;
149polar_memory_pool_page_new(
size_t size_page_desired )
156 return polar_memory_pool_page_allocate_sized(type_class, size_page_desired );
159POLAR_FUNCTION_INTERNAL OBJC_FUNCTION_HOTSPOT
void *
164 assert( POLAR_IS_MEMORY_POOL_PAGE(self) );
165 assert( count_bytes_increment > 0 );
169 if( polar_memory_pool_page_test_fit(self, count_bytes_increment) )
171 result = self->page_break;
172 self->page_break += count_bytes_increment;
Definition polar-internal-type.h:34
Definition polar-memory-pool-page.h:31
Definition polar-memory-pool-page.h:24
Definition polar-runtime-object.h:36
Definition polar-runtime-object.h:31