From 0f34d6ececc35eb683979e50ce5a1f18cdcd74a5 Mon Sep 17 00:00:00 2001 From: slava Date: Tue, 13 Jun 2006 20:02:09 +0000 Subject: [PATCH] add-literal fix --- TODO.FACTOR.txt | 11 ++++++++++- library/bootstrap/primitives.factor | 3 +-- library/collections/growable.factor | 2 +- library/compiler/generator/assembler.factor | 4 ---- library/compiler/generator/assembler.facts | 10 +++------- library/compiler/inference/known-words.factor | 4 +--- library/test/collections/strings.factor | 2 +- vm/compiler.c | 18 ++++++++---------- vm/compiler.h | 3 +-- vm/memory.h | 3 +++ vm/primitives.c | 3 +-- 11 files changed, 30 insertions(+), 33 deletions(-) diff --git a/TODO.FACTOR.txt b/TODO.FACTOR.txt index d5ccf869b6..2c3a9d2e16 100644 --- a/TODO.FACTOR.txt +++ b/TODO.FACTOR.txt @@ -1,4 +1,9 @@ -- UI word wrap problem +- crash: + - start UI + - redefine new-size + - recompile all + - full gc + - crash! - unix i/o: problems with passing f to syscalls - if a primitive throws an error, :c doesn't show the call frame there @@ -36,6 +41,7 @@ - fix remaining HTML stream issues - need to present $list in a useful way - better line spacing in ui and html - related issue + - get rid of style stack + fix compiled gc check - there was a performance hit, investigate @@ -57,6 +63,8 @@ + ui: +- { } H{ } [ ] tabular-output -- excess newline +- multiple listener-run-files is broken - word wrap in UI broken again - table line styles - x11 input methods @@ -65,6 +73,7 @@ - browse generic words and classes - need actions for reloading the source file and opening word in jEdit - highlight showing panes in originating list + - single set of tabs across the top - toggle/radio buttons/tabs or something - make-frame should compile - speed up ideas: diff --git a/library/bootstrap/primitives.factor b/library/bootstrap/primitives.factor index 8325da3bbb..b99558554e 100644 --- a/library/bootstrap/primitives.factor +++ b/library/bootstrap/primitives.factor @@ -150,8 +150,7 @@ call { "cd" "io" } { "compiled-offset" "assembler" } { "set-compiled-offset" "assembler" } - { "literal-top" "assembler" } - { "set-literal-top" "assembler" } + { "add-literal" "assembler" } { "address" "memory" } { "dlopen" "alien" } { "dlsym" "alien" } diff --git a/library/collections/growable.factor b/library/collections/growable.factor index 4c9d13ebec..3f9da2eda7 100644 --- a/library/collections/growable.factor +++ b/library/collections/growable.factor @@ -15,7 +15,7 @@ GENERIC: set-fill : expand ( len seq -- ) [ underlying resize ] keep set-underlying ; inline -: new-size ( n -- n ) 3 * dup 50 < [ drop 50 ] when ; +: new-size ( n -- n ) 1+ 3 * ; inline : ensure ( n seq -- ) 2dup length >= [ diff --git a/library/compiler/generator/assembler.factor b/library/compiler/generator/assembler.factor index 9329b5d448..4cfa99e9c5 100644 --- a/library/compiler/generator/assembler.factor +++ b/library/compiler/generator/assembler.factor @@ -16,10 +16,6 @@ math memory namespaces ; : compile-aligned ( n -- ) compiled-offset 8 align set-compiled-offset ; inline -: add-literal ( obj -- lit# ) - address literal-top [ set-compiled-cell ] keep - dup cell + set-literal-top ; - : assemble-1 ( n -- ) compiled-offset set-compiled-1 compiled-offset 1+ set-compiled-offset ; inline diff --git a/library/compiler/generator/assembler.facts b/library/compiler/generator/assembler.facts index 260ed1f263..fa00507a5e 100644 --- a/library/compiler/generator/assembler.facts +++ b/library/compiler/generator/assembler.facts @@ -9,13 +9,9 @@ HELP: set-compiled-offset "( n -- )" { $values { "n" "an address" } } { $description "Sets the pointer to the top of the code heap where new code can be compiled." } ; -HELP: literal-top "( -- n )" -{ $values { "n" "an address" } } -{ $description "Outputs a pointer to the top of the literal data area. The compiler deposits references made to heap-allocated objects from compiled code in this area." } ; - -HELP: set-literal-top "( -- n )" -{ $values { "n" "an address" } } -{ $description "Sets the pointer to the top of the literal data area. The compiler deposits references made to heap-allocated objects from compiled code in this area." } ; +HELP: add-literal "( obj -- n )" +{ $values { "obj" "an object" } { "n" "an address" } } +{ $description "Adds a pointer to the object to the compiled literal area and outputs a pointer to a pointer to the object." } ; HELP: flush-icache "( -- )" { $description "Flushes the CPUs instruction cache on PowerPC, and does nothing on other architectures. PowerPC CPUs do not automatically invalidate the cache when memory contents change, so the compiler must do this explicitly." } ; diff --git a/library/compiler/inference/known-words.factor b/library/compiler/inference/known-words.factor index a463400a20..b12a8860aa 100644 --- a/library/compiler/inference/known-words.factor +++ b/library/compiler/inference/known-words.factor @@ -293,9 +293,7 @@ sequences strings vectors words prettyprint ; \ set-compiled-offset [ [ integer ] [ ] ] "infer-effect" set-word-prop -\ literal-top [ [ ] [ integer ] ] "infer-effect" set-word-prop - -\ set-literal-top [ [ integer ] [ ] ] "infer-effect" set-word-prop +\ add-literal [ [ object ] [ integer ] ] "infer-effect" set-word-prop \ address [ [ object ] [ integer ] ] "infer-effect" set-word-prop diff --git a/library/test/collections/strings.factor b/library/test/collections/strings.factor index 3487573b14..a82b9d5d1a 100644 --- a/library/test/collections/strings.factor +++ b/library/test/collections/strings.factor @@ -53,7 +53,7 @@ unit-test unit-test [ { "a" "b" "c" "d" "e" "f" } ] -[ "aXXbXXcXXdXXeXXf" "XX" split ] unit-test +[ "aXbYcXdYeXf" "XY" split ] unit-test [ "Hello world" t ] [ "Hello world\n" "\n" ?tail ] unit-test [ "Hello world" f ] [ "Hello world" "\n" ?tail ] unit-test diff --git a/vm/compiler.c b/vm/compiler.c index 47ea344659..0fc2c8a2af 100644 --- a/vm/compiler.c +++ b/vm/compiler.c @@ -25,17 +25,15 @@ void primitive_set_compiled_offset(void) } } -void primitive_literal_top(void) +void primitive_add_literal(void) { - box_unsigned_cell(literal_top); -} - -void primitive_set_literal_top(void) -{ - CELL offset = unbox_unsigned_cell(); - if(offset >= literal_max) - critical_error("Too many compiled literals",offset); - literal_top = offset; + CELL object = dpeek(); + CELL offset = literal_top; + put(literal_top,object); + literal_top += CELLS; + if(literal_top >= literal_max) + critical_error("Too many compiled literals",literal_top); + drepl(tag_cell(offset)); } void primitive_flush_icache(void) diff --git a/vm/compiler.h b/vm/compiler.h index 2c822d3d06..ba6d882e23 100644 --- a/vm/compiler.h +++ b/vm/compiler.h @@ -16,8 +16,7 @@ CELL literal_max; void init_compiler(CELL size); void primitive_compiled_offset(void); void primitive_set_compiled_offset(void); -void primitive_literal_top(void); -void primitive_set_literal_top(void); +void primitive_add_literal(void); void collect_literals(void); #ifdef FACTOR_PPC diff --git a/vm/memory.h b/vm/memory.h index 3de757c035..517785b65c 100644 --- a/vm/memory.h +++ b/vm/memory.h @@ -85,6 +85,9 @@ INLINE CELL tag_header(CELL cell) INLINE CELL untag_header(CELL cell) { + /* if((cell & TAG_MASK) != OBJECT_TYPE) + critical_error("Corrupt object header",cell); */ + return cell >> TAG_BITS; } diff --git a/vm/primitives.c b/vm/primitives.c index 2f34c83496..72399eb218 100644 --- a/vm/primitives.c +++ b/vm/primitives.c @@ -123,8 +123,7 @@ void* primitives[] = { primitive_cd, primitive_compiled_offset, primitive_set_compiled_offset, - primitive_literal_top, - primitive_set_literal_top, + primitive_add_literal, primitive_address, primitive_dlopen, primitive_dlsym,