From e26ef02638b428d5b4104440b8eb5f28919193ec Mon Sep 17 00:00:00 2001 From: Vincent Geddes Date: Fri, 5 Sep 2008 20:47:17 +0200 Subject: [PATCH] Removed the notion of a "large" context. For simplicity, all contexts are now the same size --- src/st-generator.c | 2 -- src/st-machine.c | 4 +--- src/st-memory.c | 34 +++++++++------------------------- src/st-memory.h | 7 +++---- src/st-object.h | 17 +---------------- src/st-primitives.c | 2 +- 6 files changed, 15 insertions(+), 51 deletions(-) diff --git a/src/st-generator.c b/src/st-generator.c index d63b0a6..71b0918 100644 --- a/src/st-generator.c +++ b/src/st-generator.c @@ -1384,7 +1384,6 @@ st_generate_method (st_oop class, st_node *node, st_compiler_error *error) ST_METHOD_HEADER (method) = st_smi_new (0); st_method_set_arg_count (method, argcount); st_method_set_temp_count (method, tempcount); - st_method_set_large_context (method, (code.max_stack_depth + argcount + tempcount) > 12); st_method_set_primitive_index (method, node->method.primitive); if (node->method.primitive >= 0) { @@ -1691,7 +1690,6 @@ st_print_method (st_oop method) printf ("flags: %i; ", st_method_get_flags (method)); printf ("arg-count: %i; ", st_method_get_arg_count (method)); printf ("temp-count: %i; ", st_method_get_temp_count (method)); - printf ("large-context: %i; ", st_method_get_large_context (method)); printf ("primitive: %i;\n", st_method_get_primitive_index (method)); printf ("\n"); diff --git a/src/st-machine.c b/src/st-machine.c index bc9eb75..09deea0 100644 --- a/src/st-machine.c +++ b/src/st-machine.c @@ -51,10 +51,9 @@ method_context_new (st_machine *machine) st_oop *stack; bool large; - large = st_method_get_large_context (machine->new_method); temp_count = st_method_get_arg_count (machine->new_method) + st_method_get_temp_count (machine->new_method); - context = st_memory_allocate_context (large); + context = st_memory_allocate_context (); ST_CONTEXT_PART_SENDER (context) = machine->context; ST_CONTEXT_PART_IP (context) = st_smi_new (0); @@ -89,7 +88,6 @@ block_context_new (st_machine *machine, st_uint initial_ip, st_uint argcount) } st_object_initialize_header (context, ST_BLOCK_CONTEXT_CLASS); - st_object_set_large_context (context, true); if (ST_OBJECT_CLASS (machine->context) == ST_BLOCK_CONTEXT_CLASS) home = ST_BLOCK_CONTEXT_HOME (machine->context); diff --git a/src/st-memory.c b/src/st-memory.c index 634e93b..b38e793 100644 --- a/src/st-memory.c +++ b/src/st-memory.c @@ -161,7 +161,6 @@ st_memory_new (void) memory->offsets = NULL; memory->free_context = 0; - memory->free_context_large = 0; memory->ht = st_identity_hashtable_new (); @@ -208,32 +207,23 @@ st_memory_allocate (st_uint size) } st_oop -st_memory_allocate_context (bool large) +st_memory_allocate_context (void) { st_oop context; - if (large) { - if (ST_LIKELY (memory->free_context_large)) { - context = memory->free_context_large; - memory->free_context_large = ST_CONTEXT_PART_SENDER (memory->free_context_large); + if (ST_LIKELY (memory->free_context)) { + context = memory->free_context; + memory->free_context = ST_CONTEXT_PART_SENDER (memory->free_context); return context; - } - } else { - if (ST_LIKELY (memory->free_context)) { - context = memory->free_context; - memory->free_context = ST_CONTEXT_PART_SENDER (memory->free_context); - return context; - } } - context = st_memory_allocate (ST_SIZE_OOPS (struct st_method_context) + (large ? 32 : 12)); + context = st_memory_allocate (ST_SIZE_OOPS (struct st_method_context) + 32); if (context == 0) { st_memory_perform_gc (); - context = st_memory_allocate (ST_SIZE_OOPS (struct st_method_context) + (large ? 32 : 12)); + context = st_memory_allocate (ST_SIZE_OOPS (struct st_method_context) + 32); st_assert (context != 0); } st_object_initialize_header (context, ST_METHOD_CONTEXT_CLASS); - st_object_set_large_context (context, large); return context; } @@ -241,13 +231,8 @@ st_memory_allocate_context (bool large) void st_memory_recycle_context (st_oop context) { - if (st_object_large_context (context)) { - ST_CONTEXT_PART_SENDER (context) = memory->free_context_large; - memory->free_context_large = context; - } else { - ST_CONTEXT_PART_SENDER (context) = memory->free_context; - memory->free_context = context; - } + ST_CONTEXT_PART_SENDER (context) = memory->free_context; + memory->free_context = context; } static inline bool @@ -324,7 +309,7 @@ object_size (st_oop object) abort (); break; case ST_FORMAT_CONTEXT: - return ST_SIZE_OOPS (struct st_header) + st_object_instance_size (object) + (st_object_large_context (object) ? 32 : 12); + return ST_SIZE_OOPS (struct st_header) + st_object_instance_size (object) + 32; } /* should not reach */ abort (); @@ -614,7 +599,6 @@ garbage_collect (void) /* clear context pool */ memory->free_context = 0; - memory->free_context_large = 0; memory->bytes_allocated += memory->counter; diff --git a/src/st-memory.h b/src/st-memory.h index db4c961..516ecb9 100644 --- a/src/st-memory.h +++ b/src/st-memory.h @@ -56,7 +56,6 @@ typedef struct st_memory st_uint counter; /* free context pool */ - st_oop free_context_large; st_oop free_context; /* statistics */ @@ -74,11 +73,11 @@ void st_memory_add_root (st_oop object); void st_memory_remove_root (st_oop object); st_oop st_memory_allocate (st_uint size); -st_oop st_memory_allocate_context (bool large); +st_oop st_memory_allocate_context (void); void st_memory_recycle_context (st_oop context); -void st_memory_perform_gc (void); +void st_memory_perform_gc (void); -st_oop st_memory_remap_reference (st_oop reference); +st_oop st_memory_remap_reference (st_oop reference); #endif /* __ST_MEMORY__ */ diff --git a/src/st-object.h b/src/st-object.h index 9045975..5265c9e 100644 --- a/src/st-object.h +++ b/src/st-object.h @@ -63,19 +63,16 @@ enum { _ST_OBJECT_UNUSED_BITS = 15, _ST_OBJECT_HASH_BITS = 1, - _ST_OBJECT_LARGE_BITS = 1, _ST_OBJECT_SIZE_BITS = 8, _ST_OBJECT_FORMAT_BITS = 6, _ST_OBJECT_FORMAT_SHIFT = ST_TAG_SIZE, _ST_OBJECT_SIZE_SHIFT = _ST_OBJECT_FORMAT_BITS + _ST_OBJECT_FORMAT_SHIFT, - _ST_OBJECT_LARGE_SHIFT = _ST_OBJECT_SIZE_BITS + _ST_OBJECT_SIZE_SHIFT, - _ST_OBJECT_HASH_SHIFT = _ST_OBJECT_LARGE_BITS + _ST_OBJECT_LARGE_SHIFT, + _ST_OBJECT_HASH_SHIFT = _ST_OBJECT_SIZE_BITS + _ST_OBJECT_SIZE_SHIFT, _ST_OBJECT_UNUSED_SHIFT = _ST_OBJECT_HASH_BITS + _ST_OBJECT_HASH_SHIFT, _ST_OBJECT_FORMAT_MASK = ST_NTH_MASK (_ST_OBJECT_FORMAT_BITS), _ST_OBJECT_SIZE_MASK = ST_NTH_MASK (_ST_OBJECT_SIZE_BITS), - _ST_OBJECT_LARGE_MASK = ST_NTH_MASK (_ST_OBJECT_LARGE_BITS), _ST_OBJECT_HASH_MASK = ST_NTH_MASK (_ST_OBJECT_HASH_BITS), _ST_OBJECT_UNUSED_MASK = ST_NTH_MASK (_ST_OBJECT_UNUSED_BITS), }; @@ -114,18 +111,6 @@ st_object_format (st_oop object) } static inline void -st_object_set_large_context (st_oop object, bool is_large) -{ - _ST_OBJECT_SET_BITFIELD (ST_OBJECT_MARK (object), LARGE, is_large); -} - -static inline bool -st_object_large_context (st_oop object) -{ - return _ST_OBJECT_GET_BITFIELD (ST_OBJECT_MARK (object), LARGE); -} - -static inline void st_object_set_hashed (st_oop object, bool hashed) { _ST_OBJECT_SET_BITFIELD (ST_OBJECT_MARK (object), HASH, hashed); diff --git a/src/st-primitives.c b/src/st-primitives.c index 032a007..3f2dc0e 100644 --- a/src/st-primitives.c +++ b/src/st-primitives.c @@ -1548,7 +1548,7 @@ Object_perform_withArguments (st_machine *machine) method = ST_METHOD_CONTEXT_METHOD (machine->context); array_size = st_smi_value (st_arrayed_object_size (array)); - set_success (machine, (machine->sp + array_size - 1) < (st_method_get_large_context (method) ? 32 : 12)); + set_success (machine, (machine->sp + array_size - 1) < 32); if (machine->success) { -- 2.11.4.GIT