diff --git a/TODO.FACTOR.txt b/TODO.FACTOR.txt index a41171fab5..080cfec5b2 100644 --- a/TODO.FACTOR.txt +++ b/TODO.FACTOR.txt @@ -11,9 +11,6 @@ - print warning on null class - optimize away dispatch -- move tuple to generic vocab - -- vectors: ensure its ok with bignum indices - code gc - ppc register decls @@ -50,6 +47,7 @@ + kernel: +- vectors: ensure its ok with bignum indices - cat, reverse-cat primitives - generational gc - make see work with union, builtin, predicate @@ -57,3 +55,4 @@ - proper ordering for classes - make-vector and make-string should not need a reverse step - worddef props +- automatically recompiling defs diff --git a/library/generic/tuple.factor b/library/generic/tuple.factor index a6256c775b..88caf5008d 100644 --- a/library/generic/tuple.factor +++ b/library/generic/tuple.factor @@ -4,6 +4,8 @@ IN: generic USING: words parser kernel namespaces lists strings kernel-internals math hashtables errors vectors ; +BUILTIN: tuple 18 + : class ( obj -- class ) #! The class of an object. dup tuple? [ 2 slot ] [ type builtin-type ] ifte ; diff --git a/library/kernel.factor b/library/kernel.factor index 84d6346898..c1288ede4e 100644 --- a/library/kernel.factor +++ b/library/kernel.factor @@ -7,8 +7,6 @@ IN: kernel-internals USING: generic kernel vectors ; #! call it directly. vector-array array-nth call ; -BUILTIN: tuple 18 - IN: kernel GENERIC: hashcode ( obj -- n ) diff --git a/library/ui/buttons.factor b/library/ui/buttons.factor index a76773f3a9..8cd8c0968c 100644 --- a/library/ui/buttons.factor +++ b/library/ui/buttons.factor @@ -3,6 +3,9 @@ IN: gadgets USING: generic kernel lists math namespaces sdl ; +: button-down? ( n -- ? ) + my-hand hand-buttons contains? ; + : button-pressed ( button -- ) dup f bevel-up? set-paint-property redraw ; diff --git a/library/ui/gestures.factor b/library/ui/gestures.factor index 0d67c536e7..a126c17a3f 100644 --- a/library/ui/gestures.factor +++ b/library/ui/gestures.factor @@ -76,6 +76,3 @@ SYMBOL: button-down [ 2dup child? [ gain-focus ] hierarchy-gesture ] each-parent 2drop ; - -: button-down? ( n -- ? ) - my-hand hand-buttons contains? ; diff --git a/native/array.c b/native/array.c index 37029970ba..27f46114ce 100644 --- a/native/array.c +++ b/native/array.c @@ -100,5 +100,5 @@ void collect_array(F_ARRAY* array) int i = 0; CELL capacity = untag_fixnum_fast(array->capacity); for(i = 0; i < capacity; i++) - copy_object((void*)AREF(array,i)); + copy_handle((void*)AREF(array,i)); } diff --git a/native/bignum.c b/native/bignum.c index c077eddaef..1e9b9b5e24 100644 --- a/native/bignum.c +++ b/native/bignum.c @@ -240,7 +240,7 @@ void primitive_bignum_not(void) void copy_bignum_constants(void) { - copy_object(&bignum_zero); - copy_object(&bignum_pos_one); - copy_object(&bignum_neg_one); + COPY_OBJECT(bignum_zero); + COPY_OBJECT(bignum_pos_one); + COPY_OBJECT(bignum_neg_one); } diff --git a/native/compiler.c b/native/compiler.c index 70596ee2aa..67794e1167 100644 --- a/native/compiler.c +++ b/native/compiler.c @@ -28,5 +28,5 @@ void collect_literals(void) { CELL i; for(i = compiling.base; i < literal_top; i += CELLS) - copy_object((CELL*)i); + copy_handle((CELL*)i); } diff --git a/native/factor.h b/native/factor.h index 1dfe205034..7613978d84 100644 --- a/native/factor.h +++ b/native/factor.h @@ -3,6 +3,8 @@ #if defined(i386) || defined(__i386) || defined(__i386__) || defined(WIN32) #define FACTOR_X86 +#elif defined(__POWERPC__) || defined(__ppc__) || defined(_ARCH_PPC) + #define FACTOR_PPC #endif #if defined(WIN32) @@ -19,8 +21,10 @@ typedef unsigned long int CELL; CELL ds_bot; /* raw pointer to datastack top */ -#ifdef FACTOR_X86 +#if defined(FACTOR_X86) register CELL ds asm("esi"); +#elif defined(FACTOR_PPC) + register CELL ds asm("r14"); #else CELL ds; #endif @@ -29,10 +33,25 @@ CELL ds_bot; CELL cs_bot; /* raw pointer to callstack top */ -DLLEXPORT CELL cs; +#if defined(FACTOR_PPC) + register CELL cs asm("r15"); +#else + DLLEXPORT CELL cs; +#endif /* TAGGED currently executing quotation */ -CELL callframe; +#if defined(FACTOR_PPC) + register CELL callframe asm("r16"); +#else + CELL callframe; +#endif + +/* TAGGED pointer to currently executing word */ +#if defined(FACTOR_PPC) + register CELL executing asm("r17"); +#else + CELL executing; +#endif #include #include diff --git a/native/ffi.c b/native/ffi.c index 23c6df76e7..56bdeb31c2 100644 --- a/native/ffi.c +++ b/native/ffi.c @@ -160,7 +160,7 @@ void fixup_dll(DLL* dll) void collect_dll(DLL* dll) { - copy_object(&dll->path); + COPY_OBJECT(dll->path); } void fixup_alien(ALIEN* alien) diff --git a/native/gc.c b/native/gc.c index 65c294f51a..4be118f710 100644 --- a/native/gc.c +++ b/native/gc.c @@ -17,20 +17,20 @@ void collect_roots(void) CELL ptr; /*T must be the first in the heap */ - copy_object(&T); + COPY_OBJECT(T); /* the bignum 0 1 -1 constants must be the next three */ copy_bignum_constants(); - copy_object(&callframe); - copy_object(&executing); + COPY_OBJECT(callframe); + COPY_OBJECT(executing); for(ptr = ds_bot; ptr <= ds; ptr += CELLS) - copy_object((void*)ptr); + copy_handle((CELL*)ptr); for(ptr = cs_bot; ptr <= cs; ptr += CELLS) - copy_object((void*)ptr); + copy_handle((CELL*)ptr); for(i = 0; i < USER_ENV; i++) - copy_object(&userenv[i]); + copy_handle(&userenv[i]); } /* @@ -106,7 +106,7 @@ INLINE CELL collect_next(CELL scan) else { size = CELLS; - copy_object((CELL*)scan); + copy_handle((CELL*)scan); } return scan + size; diff --git a/native/gc.h b/native/gc.h index 00c3d1046b..97691aa40e 100644 --- a/native/gc.h +++ b/native/gc.h @@ -16,30 +16,31 @@ INLINE void* copy_untagged_object(void* pointer, CELL size) CELL copy_object_impl(CELL pointer); -INLINE void copy_object(CELL* handle) +INLINE CELL copy_object(CELL pointer) { - CELL pointer = *handle; CELL tag; CELL header; - CELL newpointer; if(pointer == F) - return; + return F; tag = TAG(pointer); if(tag == FIXNUM_TYPE) - return; - - if(headerp(pointer)) - critical_error("Asked to copy header",pointer); + return pointer; header = get(UNTAG(pointer)); if(TAG(header) == GC_COLLECTED) - newpointer = UNTAG(header); + return RETAG(UNTAG(header),tag); else - newpointer = copy_object_impl(pointer); - *handle = RETAG(newpointer,tag); + return RETAG(copy_object_impl(pointer),tag); +} + +#define COPY_OBJECT(lvalue) lvalue = copy_object(lvalue) + +INLINE void copy_handle(CELL* handle) +{ + COPY_OBJECT(*handle); } void collect_roots(void); diff --git a/native/hashtable.c b/native/hashtable.c index 25ce2e72bc..f30eb71f11 100644 --- a/native/hashtable.c +++ b/native/hashtable.c @@ -29,5 +29,5 @@ void fixup_hashtable(F_HASHTABLE* hashtable) void collect_hashtable(F_HASHTABLE* hashtable) { - copy_object(&hashtable->array); + COPY_OBJECT(hashtable->array); } diff --git a/native/port.c b/native/port.c index ea43fbf3bb..a003c4be0b 100644 --- a/native/port.c +++ b/native/port.c @@ -57,11 +57,11 @@ void fixup_port(F_PORT* port) void collect_port(F_PORT* port) { - copy_object(&port->buffer); - copy_object(&port->line); - copy_object(&port->client_host); - copy_object(&port->client_port); - copy_object(&port->io_error); + COPY_OBJECT(port->buffer); + COPY_OBJECT(port->line); + COPY_OBJECT(port->client_host); + COPY_OBJECT(port->client_port); + COPY_OBJECT(port->io_error); } #ifdef WIN32 diff --git a/native/run.h b/native/run.h index 1461354704..968bee595e 100644 --- a/native/run.h +++ b/native/run.h @@ -26,9 +26,6 @@ jmp_buf toplevel; sigjmp_buf toplevel; #endif -/* TAGGED pointer to currently executing word */ -CELL executing; - /* TAGGED user environment data; see getenv/setenv prims */ CELL userenv[USER_ENV]; diff --git a/native/sbuf.c b/native/sbuf.c index b0998c2a39..92bf7f46b7 100644 --- a/native/sbuf.c +++ b/native/sbuf.c @@ -190,5 +190,5 @@ void fixup_sbuf(F_SBUF* sbuf) void collect_sbuf(F_SBUF* sbuf) { - copy_object(&sbuf->string); + COPY_OBJECT(sbuf->string); } diff --git a/native/unix/io.c b/native/unix/io.c index 29b771e24e..97953dd2a3 100644 --- a/native/unix/io.c +++ b/native/unix/io.c @@ -291,13 +291,13 @@ void collect_io_tasks(void) for(i = 0; i < FD_SETSIZE; i++) { - copy_object(&read_io_tasks[i].port); - copy_object(&read_io_tasks[i].callbacks); + COPY_OBJECT(read_io_tasks[i].port); + COPY_OBJECT(read_io_tasks[i].callbacks); } for(i = 0; i < FD_SETSIZE; i++) { - copy_object(&write_io_tasks[i].port); - copy_object(&write_io_tasks[i].callbacks); + COPY_OBJECT(write_io_tasks[i].port); + COPY_OBJECT(write_io_tasks[i].callbacks); } } diff --git a/native/vector.c b/native/vector.c index e75b6b4ffc..db153f905c 100644 --- a/native/vector.c +++ b/native/vector.c @@ -29,5 +29,5 @@ void fixup_vector(F_VECTOR* vector) void collect_vector(F_VECTOR* vector) { - copy_object(&vector->array); + COPY_OBJECT(vector->array); } diff --git a/native/word.c b/native/word.c index 297f9a9239..665c6e5b45 100644 --- a/native/word.c +++ b/native/word.c @@ -57,6 +57,6 @@ void fixup_word(F_WORD* word) void collect_word(F_WORD* word) { - copy_object(&word->parameter); - copy_object(&word->plist); + COPY_OBJECT(word->parameter); + COPY_OBJECT(word->plist); }