From b571e6fb0d5201af5edea797e81e7cbe132c1560 Mon Sep 17 00:00:00 2001 From: slava Date: Wed, 1 Nov 2006 19:29:58 +0000 Subject: [PATCH] Remove unused environment slot and simply room primitive --- library/compiler/x86/intrinsics.factor | 4 +--- library/kernel.factor | 2 +- library/tools/memory.factor | 2 +- vm/code_gc.c | 4 ++-- vm/data_gc.c | 24 ++++++------------------ vm/factor.c | 1 - vm/run.h | 5 ++--- vm/types.c | 12 ------------ vm/types.h | 1 - 9 files changed, 13 insertions(+), 42 deletions(-) diff --git a/library/compiler/x86/intrinsics.factor b/library/compiler/x86/intrinsics.factor index 6db3bbaed5..bd5f0bdfb0 100644 --- a/library/compiler/x86/intrinsics.factor +++ b/library/compiler/x86/intrinsics.factor @@ -66,12 +66,10 @@ IN: compiler { +clobber+ { "n" } } } define-intrinsic -: card-offset 1 getenv ; inline - : generate-write-barrier ( -- ) #! Mark the card pointed to by vreg. "obj" operand card-bits SHR - "obj" operand card-offset ADD rel-absolute-cell rel-cards + "obj" operand HEX: ffff ADD rel-absolute-cell rel-cards "obj" operand [] card-mark OR ; \ set-slot [ diff --git a/library/kernel.factor b/library/kernel.factor index 18564ec447..a5906f3dfc 100644 --- a/library/kernel.factor +++ b/library/kernel.factor @@ -92,7 +92,7 @@ IN: kernel-internals : num-tags 8 ; inline : tag-bits 3 ; inline -: cell ( -- n ) 17 getenv ; foldable +: cell ( -- n ) 1 getenv ; foldable : fixnum-tag BIN: 000 ; inline : bignum-tag BIN: 001 ; inline diff --git a/library/tools/memory.factor b/library/tools/memory.factor index 552ad797ae..e97231e007 100644 --- a/library/tools/memory.factor +++ b/library/tools/memory.factor @@ -28,7 +28,7 @@ strings styles vectors words ; : room. ( -- ) [ { "" "Total" "Used" "Free" } , - data-room 0 [ + data-room 2 group 0 [ "Generation " pick number>string append >r first2 r> total/used/free, 1+ ] reduce drop diff --git a/vm/code_gc.c b/vm/code_gc.c index 6bc38c0374..139476929d 100644 --- a/vm/code_gc.c +++ b/vm/code_gc.c @@ -257,8 +257,8 @@ void recursive_mark(CELL xt) /* Push the free space and total size of the code heap */ void primitive_code_room(void) { - box_unsigned_cell(heap_free_space(&compiling)); - box_unsigned_cell(compiling.limit - compiling.base); + dpush(tag_fixnum(heap_free_space(&compiling) / 1024)); + dpush(tag_fixnum((compiling.limit - compiling.base) / 1024); } /* Perform a code GC */ diff --git a/vm/data_gc.c b/vm/data_gc.c index 4e64a14472..b35a774e11 100644 --- a/vm/data_gc.c +++ b/vm/data_gc.c @@ -82,29 +82,17 @@ void primitive_size(void) /* Push memory usage statistics in data heap */ void primitive_data_room(void) { + F_ARRAY *a = allot_array(ARRAY_TYPE,gen_count * 2,F); int gen; - box_unsigned_cell(cards_end - cards); - box_unsigned_cell(prior.limit - prior.base); - + dpush(tag_fixnum((cards_end - cards) >> 10)); + dpush(tag_fixnum((prior.limit - prior.base) >> 10)); + for(gen = 0; gen < gen_count; gen++) { F_ZONE *z = &generations[gen]; - CELL used = allot_cell(z->limit - z->here); - REGISTER_ROOT(used); - CELL total = allot_cell(z->limit - z->base); - UNREGISTER_ROOT(used); - CELL pair = allot_array_2(used,total); - REGISTER_ROOT(pair); - } - - F_ARRAY *a = allot_array(ARRAY_TYPE,gen_count,F); - - for(gen = gen_count - 1; gen >= 0; gen--) - { - CELL pair; - UNREGISTER_ROOT(pair); - put(AREF(a,gen),pair); + put(AREF(a,gen * 2),tag_fixnum((z->limit - z->here) >> 10)); + put(AREF(a,gen * 2 + 1),tag_fixnum((z->limit - z->base) >> 10)); } dpush(tag_object(a)); diff --git a/vm/factor.c b/vm/factor.c index eec21c49e1..8551bbe79c 100644 --- a/vm/factor.c +++ b/vm/factor.c @@ -23,7 +23,6 @@ void init_factor(const char* image, userenv[CPU_ENV] = tag_object(from_char_string(FACTOR_CPU_STRING)); userenv[OS_ENV] = tag_object(from_char_string(FACTOR_OS_STRING)); userenv[GEN_ENV] = tag_fixnum(gen_count); - userenv[CARD_OFF_ENV] = allot_cell(cards_offset); userenv[IMAGE_ENV] = tag_object(from_char_string(image)); userenv[CELL_SIZE_ENV] = tag_fixnum(sizeof(CELL)); } diff --git a/vm/run.h b/vm/run.h index 4199f504e4..5888b0c9ea 100644 --- a/vm/run.h +++ b/vm/run.h @@ -12,8 +12,8 @@ CELL callframe_end; #define USER_ENV 32 -#define CARD_OFF_ENV 1 /* for compiling set-slot */ -#define NLX_VECTOR_ENV 2 /* non-local exit hook */ +#define CELL_SIZE_ENV 1 /* sizeof(CELL) */ +#define NLX_VECTOR_ENV 2 /* non-local exit hook, used by library only */ #define NAMESTACK_ENV 3 /* used by library only */ #define GLOBAL_ENV 4 #define BREAK_ENV 5 @@ -28,7 +28,6 @@ CELL callframe_end; #define OUT_ENV 14 #define GEN_ENV 15 /* set to gen_count */ #define IMAGE_ENV 16 /* image name */ -#define CELL_SIZE_ENV 17 /* sizeof(CELL) */ /* TAGGED user environment data; see getenv/setenv prims */ DLLEXPORT CELL userenv[USER_ENV]; diff --git a/vm/types.c b/vm/types.c index b1d92917e8..9f98dd259b 100644 --- a/vm/types.c +++ b/vm/types.c @@ -65,18 +65,6 @@ void primitive_byte_array(void) dpush(tag_object(allot_byte_array(size))); } -CELL allot_array_2(CELL v1, CELL v2) -{ - REGISTER_ROOT(v1); - REGISTER_ROOT(v2); - F_ARRAY *a = allot_array_internal(ARRAY_TYPE,2); - UNREGISTER_ROOT(v2); - UNREGISTER_ROOT(v1); - put(AREF(a,0),v1); - put(AREF(a,1),v2); - return tag_object(a); -} - CELL allot_array_4(CELL v1, CELL v2, CELL v3, CELL v4) { REGISTER_ROOT(v1); diff --git a/vm/types.h b/vm/types.h index 6cf001055f..d93f9cf53f 100644 --- a/vm/types.h +++ b/vm/types.h @@ -31,7 +31,6 @@ F_ARRAY *allot_array_internal(CELL type, F_FIXNUM capacity); F_ARRAY *allot_array(CELL type, F_FIXNUM capacity, CELL fill); F_ARRAY *allot_byte_array(F_FIXNUM size); -CELL allot_array_2(CELL v1, CELL v2); CELL allot_array_4(CELL v1, CELL v2, CELL v3, CELL v4); void primitive_array(void);