]> gitweb.factorcode.org Git - factor.git/commitdiff
bootstrap.image.primitives: new vocab to make primitive declarations better
authorBjörn Lindqvist <bjourne@gmail.com>
Tue, 29 Mar 2016 13:41:58 +0000 (15:41 +0200)
committerBjörn Lindqvist <bjourne@gmail.com>
Tue, 29 Mar 2016 21:52:29 +0000 (23:52 +0200)
basis/bootstrap/image/primitives/primitives-docs.factor [new file with mode: 0644]
basis/bootstrap/image/primitives/primitives.factor [new file with mode: 0644]
core/bootstrap/primitives-docs.factor
core/bootstrap/primitives.factor

diff --git a/basis/bootstrap/image/primitives/primitives-docs.factor b/basis/bootstrap/image/primitives/primitives-docs.factor
new file mode 100644 (file)
index 0000000..7d92f38
--- /dev/null
@@ -0,0 +1,12 @@
+USING: assocs help.markup help.syntax strings ;
+IN: bootstrap.image.primitives
+
+HELP: all-primitives
+{ $description "A constant " { $link assoc } " containing all primitives. Keys are vocab names and values are sequences of tuples declaring words. The format of the tuples are { name effect vm-func }. If 'vm-func' is a " { $link string } " then the primitive will call a function implemented in C++ code. If 'vm-func' is " { $link f } " then it is a sub-primitive and implemented in one of the files in 'basis/bootstrap/assembler/'." } ;
+
+ARTICLE: "bootstrap.image.primitives" "Bootstrap primitives"
+"This vocab contains utilities for declaring primitives to be added to the bootstrap image. It is used by " { $vocab-link "bootstrap.primitives" }
+$nl
+{ $link all-primitives } " is an assoc where all primitives are declared." ;
+
+ABOUT: "bootstrap.image.primitives"
diff --git a/basis/bootstrap/image/primitives/primitives.factor b/basis/bootstrap/image/primitives/primitives.factor
new file mode 100644 (file)
index 0000000..8991655
--- /dev/null
@@ -0,0 +1,417 @@
+USING: alien.strings assocs io.encodings.ascii kernel kernel.private
+locals quotations sequences words ;
+IN: bootstrap.image.primitives
+
+CONSTANT: all-primitives {
+    {
+        "alien"
+        {
+            { "<callback>" ( word return-rewind -- alien ) "primitive_callback" }
+            { "<displaced-alien>" ( displacement c-ptr -- alien ) "primitive_displaced_alien" }
+            { "alien-address" ( c-ptr -- addr ) "primitive_alien_address" }
+            { "free-callback" ( alien -- ) "primitive_free_callback" }
+        }
+    }
+    {
+        "alien.private"
+        {
+            { "current-callback" ( -- n ) "primitive_current_callback" }
+        }
+    }
+    {
+        "alien.accessors"
+        {
+            { "alien-cell" ( c-ptr n -- value ) "primitive_alien_cell" }
+            { "alien-double" ( c-ptr n -- value ) "primitive_alien_double" }
+            { "alien-float" ( c-ptr n -- value ) "primitive_alien_float" }
+
+            { "alien-signed-1" ( c-ptr n -- value ) "primitive_alien_signed_1" }
+            { "alien-signed-2" ( c-ptr n -- value ) "primitive_alien_signed_2" }
+            { "alien-signed-4" ( c-ptr n -- value ) "primitive_alien_signed_4" }
+            { "alien-signed-8" ( c-ptr n -- value ) "primitive_alien_signed_8" }
+            { "alien-signed-cell" ( c-ptr n -- value ) "primitive_alien_signed_cell" }
+
+            { "alien-unsigned-1" ( c-ptr n -- value ) "primitive_alien_unsigned_1" }
+            { "alien-unsigned-2" ( c-ptr n -- value ) "primitive_alien_unsigned_2" }
+            { "alien-unsigned-4" ( c-ptr n -- value ) "primitive_alien_unsigned_4" }
+            { "alien-unsigned-8" ( c-ptr n -- value ) "primitive_alien_unsigned_8" }
+            { "alien-unsigned-cell" ( c-ptr n -- value ) "primitive_alien_unsigned_cell" }
+
+            { "set-alien-cell" ( value c-ptr n -- ) "primitive_set_alien_cell" }
+            { "set-alien-double" ( value c-ptr n -- ) "primitive_set_alien_double" }
+            { "set-alien-float" ( value c-ptr n -- ) "primitive_set_alien_float" }
+
+            { "set-alien-signed-1" ( value c-ptr n -- ) "primitive_set_alien_signed_1" }
+            { "set-alien-signed-2" ( value c-ptr n -- ) "primitive_set_alien_signed_2" }
+            { "set-alien-signed-4" ( value c-ptr n -- ) "primitive_set_alien_signed_4" }
+            { "set-alien-signed-8" ( value c-ptr n -- ) "primitive_set_alien_signed_8" }
+            { "set-alien-signed-cell" ( value c-ptr n -- ) "primitive_set_alien_signed_cell" }
+
+            { "set-alien-unsigned-1" ( value c-ptr n -- ) "primitive_set_alien_unsigned_1" }
+            { "set-alien-unsigned-2" ( value c-ptr n -- ) "primitive_set_alien_unsigned_2" }
+            { "set-alien-unsigned-4" ( value c-ptr n -- ) "primitive_set_alien_unsigned_4" }
+            { "set-alien-unsigned-8" ( value c-ptr n -- ) "primitive_set_alien_unsigned_8" }
+            { "set-alien-unsigned-cell" ( value c-ptr n -- ) "primitive_set_alien_unsigned_cell" }
+        }
+    }
+    {
+        "alien.libraries"
+        {
+            { "(dlopen)" ( path -- dll ) "primitive_dlopen" }
+            { "(dlsym)" ( name dll -- alien ) "primitive_dlsym" }
+            { "(dlsym-raw)" ( name dll -- alien ) "primitive_dlsym_raw" }
+            { "dlclose" ( dll -- ) "primitive_dlclose" }
+            { "dll-valid?" ( dll -- ? ) "primitive_dll_validp" }
+        }
+    }
+    {
+        "arrays"
+        {
+            { "<array>" ( n elt -- array ) "primitive_array" }
+            { "resize-array" ( n array -- new-array ) "primitive_resize_array" }
+        }
+    }
+    {
+        "byte-arrays"
+        {
+            { "(byte-array)" ( n -- byte-array ) "primitive_uninitialized_byte_array" }
+            { "<byte-array>" ( n -- byte-array ) "primitive_byte_array" }
+            {
+                "resize-byte-array" ( n byte-array -- new-byte-array )
+                "primitive_resize_byte_array"
+            }
+        }
+    }
+    {
+        "classes.tuple.private"
+        {
+            { "<tuple-boa>" ( slots... layout -- tuple ) "primitive_tuple_boa" }
+            { "<tuple>" ( layout -- tuple ) "primitive_tuple" }
+        }
+    }
+    {
+        "compiler.units"
+        {
+            {
+                "modify-code-heap" ( alist update-existing? reset-pics? -- )
+                "primitive_modify_code_heap"
+            }
+        }
+    }
+    {
+        "generic.single.private"
+        {
+            { "inline-cache-miss" ( generic methods index cache -- ) f }
+            { "inline-cache-miss-tail" ( generic methods index cache -- ) f }
+            { "lookup-method" ( object methods -- method ) "primitive_lookup_method" }
+            { "mega-cache-lookup" ( methods index cache -- ) f }
+            { "mega-cache-miss" ( methods index cache -- method ) "primitive_mega_cache_miss" }
+        }
+    }
+    {
+        "io.files.private"
+        {
+            { "(exists?)" ( path -- ? ) "primitive_existsp" }
+        }
+    }
+    {
+        "io.streams.c"
+        {
+            { "(fopen)" ( path mode -- alien ) "primitive_fopen" }
+            { "fclose" ( alien -- ) "primitive_fclose" }
+            { "fflush" ( alien -- ) "primitive_fflush" }
+            { "fgetc" ( alien -- byte/f ) "primitive_fgetc" }
+            { "fputc" ( byte alien -- ) "primitive_fputc" }
+            { "fread-unsafe" ( n buf alien -- count ) "primitive_fread" }
+            { "fseek" ( alien offset whence -- ) "primitive_fseek" }
+            { "ftell" ( alien -- n ) "primitive_ftell" }
+            { "fwrite" ( data length alien -- ) "primitive_fwrite" }
+        }
+    }
+    {
+        "kernel"
+        {
+            { "(clone)" ( obj -- newobj ) "primitive_clone" }
+            { "<wrapper>" ( obj -- wrapper ) "primitive_wrapper" }
+            { "callstack>array" ( callstack -- array ) "primitive_callstack_to_array" }
+            { "die" ( -- ) "primitive_die" }
+            { "drop" ( x -- ) f }
+            { "2drop" ( x y -- ) f }
+            { "3drop" ( x y z -- ) f }
+            { "4drop" ( w x y z -- ) f }
+            { "dup" ( x -- x x ) f }
+            { "2dup" ( x y -- x y x y ) f }
+            { "3dup" ( x y z -- x y z x y z ) f }
+            { "4dup" ( w x y z -- w x y z w x y z ) f }
+            { "rot" ( x y z -- y z x ) f }
+            { "-rot" ( x y z -- z x y ) f }
+            { "dupd" ( x y -- x x y ) f }
+            { "swapd" ( x y z -- y x z ) f }
+            { "nip" ( x y -- y ) f }
+            { "2nip" ( x y z -- z ) f }
+            { "over" ( x y -- x y x ) f }
+            { "pick" ( x y z -- x y z x ) f }
+            { "swap" ( x y -- y x ) f }
+            { "eq?" ( obj1 obj2 -- ? ) f }
+        }
+    }
+    {
+        "kernel.private"
+        {
+            { "(call)" ( quot -- ) f }
+            { "(execute)" ( word -- ) f }
+            { "c-to-factor" ( -- ) f }
+            { "fpu-state" ( -- ) f }
+            { "lazy-jit-compile" ( -- ) f }
+            { "leaf-signal-handler" ( -- ) f }
+            { "set-callstack" ( callstack -- * ) f }
+            { "set-fpu-state" ( -- ) f }
+            { "signal-handler" ( -- ) f }
+            { "tag" ( object -- n ) f }
+            { "unwind-native-frames" ( -- ) f }
+
+            { "callstack-for" ( context -- array ) "primitive_callstack_for" }
+            { "datastack-for" ( context -- array ) "primitive_datastack_for" }
+            { "retainstack-for" ( context -- array ) "primitive_retainstack_for" }
+            { "(identity-hashcode)" ( obj -- code ) "primitive_identity_hashcode" }
+            { "become" ( old new -- ) "primitive_become" }
+            { "callstack-bounds" ( -- start end ) "primitive_callstack_bounds" }
+            { "check-datastack" ( array in# out# -- ? ) "primitive_check_datastack" }
+            { "compute-identity-hashcode" ( obj -- ) "primitive_compute_identity_hashcode" }
+            { "context-object" ( n -- obj ) "primitive_context_object" }
+            {
+                "innermost-frame-executing" ( callstack -- obj )
+                "primitive_innermost_stack_frame_executing"
+            }
+            {
+                "innermost-frame-scan" ( callstack -- n )
+                "primitive_innermost_stack_frame_scan"
+            }
+            { "set-context-object" ( obj n -- ) "primitive_set_context_object" }
+            { "set-datastack" ( array -- ) "primitive_set_datastack" }
+            {
+                "set-innermost-frame-quotation" ( n callstack -- )
+                "primitive_set_innermost_stack_frame_quotation"
+            }
+            { "set-retainstack" ( array -- ) "primitive_set_retainstack" }
+            { "set-special-object" ( obj n -- ) "primitive_set_special_object" }
+            { "special-object" ( n -- obj ) "primitive_special_object" }
+            { "strip-stack-traces" ( -- ) "primitive_strip_stack_traces" }
+            { "unimplemented" ( -- * ) "primitive_unimplemented" }
+        }
+    }
+    {
+        "locals.backend"
+        {
+            { "drop-locals" ( n -- ) f }
+            { "get-local" ( n -- obj ) f }
+            { "load-local" ( obj -- ) f }
+            { "load-locals" ( ... n -- ) "primitive_load_locals" }
+        }
+    }
+    {
+        "math"
+        {
+            { "bits>double" ( n -- x ) "primitive_bits_double" }
+            { "bits>float" ( n -- x ) "primitive_bits_float" }
+            { "double>bits" ( x -- n ) "primitive_double_bits" }
+            { "float>bits" ( x -- n ) "primitive_float_bits" }
+        }
+    }
+    {
+        "math.parser.private"
+        {
+            {
+                "(format-float)" ( n fill width precision format locale -- byte-array )
+                "primitive_format_float"
+            }
+        }
+    }
+    {
+        "math.private"
+        {
+            { "both-fixnums?" ( x y -- ? ) f }
+            { "fixnum+fast" ( x y -- z ) f }
+            { "fixnum-fast" ( x y -- z ) f }
+            { "fixnum*fast" ( x y -- z ) f }
+            { "fixnum-bitand" ( x y -- z ) f }
+            { "fixnum-bitor" ( x y -- z ) f }
+            { "fixnum-bitxor" ( x y -- z ) f }
+            { "fixnum-bitnot" ( x -- y ) f }
+            { "fixnum-mod" ( x y -- z ) f }
+            { "fixnum-shift-fast" ( x y -- z ) f }
+            { "fixnum/i-fast" ( x y -- z ) f }
+            { "fixnum/mod-fast" ( x y -- z w ) f }
+            { "fixnum+" ( x y -- z ) f }
+            { "fixnum-" ( x y -- z ) f }
+            { "fixnum*" ( x y -- z ) f }
+            { "fixnum<" ( x y -- ? ) f }
+            { "fixnum<=" ( x y -- z ) f }
+            { "fixnum>" ( x y -- ? ) f }
+            { "fixnum>=" ( x y -- ? ) f }
+
+            { "bignum*" ( x y -- z ) "primitive_bignum_multiply" }
+            { "bignum+" ( x y -- z ) "primitive_bignum_add" }
+            { "bignum-" ( x y -- z ) "primitive_bignum_subtract" }
+            { "bignum-bit?" ( x n -- ? ) "primitive_bignum_bitp" }
+            { "bignum-bitand" ( x y -- z ) "primitive_bignum_and" }
+            { "bignum-bitnot" ( x -- y ) "primitive_bignum_not" }
+            { "bignum-bitor" ( x y -- z ) "primitive_bignum_or" }
+            { "bignum-bitxor" ( x y -- z ) "primitive_bignum_xor" }
+            { "bignum-log2" ( x -- n ) "primitive_bignum_log2" }
+            { "bignum-mod" ( x y -- z ) "primitive_bignum_mod" }
+            { "bignum-gcd" ( x y -- z ) "primitive_bignum_gcd" }
+            { "bignum-shift" ( x y -- z ) "primitive_bignum_shift" }
+            { "bignum/i" ( x y -- z ) "primitive_bignum_divint" }
+            { "bignum/mod" ( x y -- z w ) "primitive_bignum_divmod" }
+            { "bignum<" ( x y -- ? ) "primitive_bignum_less" }
+            { "bignum<=" ( x y -- ? ) "primitive_bignum_lesseq" }
+            { "bignum=" ( x y -- ? ) "primitive_bignum_eq" }
+            { "bignum>" ( x y -- ? ) "primitive_bignum_greater" }
+            { "bignum>=" ( x y -- ? ) "primitive_bignum_greatereq" }
+            { "bignum>fixnum" ( x -- y ) "primitive_bignum_to_fixnum" }
+            { "bignum>fixnum-strict" ( x -- y ) "primitive_bignum_to_fixnum_strict" }
+            { "fixnum-shift" ( x y -- z ) "primitive_fixnum_shift" }
+            { "fixnum/i" ( x y -- z ) "primitive_fixnum_divint" }
+            { "fixnum/mod" ( x y -- z w ) "primitive_fixnum_divmod" }
+            { "fixnum>bignum" ( x -- y ) "primitive_fixnum_to_bignum" }
+            { "fixnum>float" ( x -- y ) "primitive_fixnum_to_float" }
+            { "float*" ( x y -- z ) "primitive_float_multiply" }
+            { "float+" ( x y -- z ) "primitive_float_add" }
+            { "float-" ( x y -- z ) "primitive_float_subtract" }
+            { "float-u<" ( x y -- ? ) "primitive_float_less" }
+            { "float-u<=" ( x y -- ? ) "primitive_float_lesseq" }
+            { "float-u>" ( x y -- ? ) "primitive_float_greater" }
+            { "float-u>=" ( x y -- ? ) "primitive_float_greatereq" }
+            { "float/f" ( x y -- z ) "primitive_float_divfloat" }
+            { "float<" ( x y -- ? ) "primitive_float_less" }
+            { "float<=" ( x y -- ? ) "primitive_float_lesseq" }
+            { "float=" ( x y -- ? ) "primitive_float_eq" }
+            { "float>" ( x y -- ? ) "primitive_float_greater" }
+            { "float>=" ( x y -- ? ) "primitive_float_greatereq" }
+            { "float>bignum" ( x -- y ) "primitive_float_to_bignum" }
+            { "float>fixnum" ( x -- y ) "primitive_float_to_fixnum" }
+        }
+    }
+    {
+        "memory"
+        {
+            { "all-instances" ( -- array ) "primitive_all_instances" }
+            { "compact-gc" ( -- ) "primitive_compact_gc" }
+            { "gc" ( -- ) "primitive_full_gc" }
+            { "minor-gc" ( -- ) "primitive_minor_gc" }
+            { "size" ( obj -- n ) "primitive_size" }
+        }
+    }
+    {
+        "memory.private"
+        {
+            { "(save-image)" ( path1 path2 then-die? -- ) "primitive_save_image" }
+        }
+    }
+    {
+        "quotations"
+        {
+            { "jit-compile" ( quot -- ) "primitive_jit_compile" }
+            { "quotation-code" ( quot -- start end ) "primitive_quotation_code" }
+            { "quotation-compiled?" ( quot -- ? ) "primitive_quotation_compiled_p" }
+        }
+    }
+    {
+        "quotations.private"
+        {
+            { "array>quotation" ( array -- quot ) "primitive_array_to_quotation" }
+        }
+    }
+    {
+        "slots.private"
+        {
+            { "set-slot" ( value obj n -- ) "primitive_set_slot" }
+            { "slot" ( obj m -- value ) f }
+        }
+    }
+    {
+        "strings"
+        {
+            { "<string>" ( n ch -- string ) "primitive_string" }
+            { "resize-string" ( n str -- newstr ) "primitive_resize_string" }
+        }
+    }
+    {
+        "strings.private"
+        {
+            { "set-string-nth-fast" ( ch n string -- ) "primitive_set_string_nth_fast" }
+            { "string-nth-fast" ( n string -- ch ) f }
+        }
+    }
+    {
+        "system"
+        {
+            { "(exit)" ( n -- * ) "primitive_exit" }
+            { "nano-count" ( -- ns ) "primitive_nano_count" }
+        }
+    }
+    {
+        "threads.private"
+        {
+            { "(sleep)" ( nanos -- ) "primitive_sleep" }
+            { "(set-context)" ( obj context -- obj' ) f }
+            { "(set-context-and-delete)" ( obj context -- * ) f }
+            { "(start-context)" ( obj quot -- obj' ) f }
+            { "(start-context-and-delete)" ( obj quot -- * ) f }
+            { "context-object-for" ( n context -- obj ) "primitive_context_object_for" }
+        }
+    }
+    {
+        "tools.dispatch.private"
+        {
+            { "dispatch-stats" ( -- stats ) "primitive_dispatch_stats" }
+            { "reset-dispatch-stats" ( -- ) "primitive_reset_dispatch_stats" }
+        }
+    }
+    {
+        "tools.memory.private"
+        {
+            { "(callback-room)" ( -- allocator-room ) "primitive_callback_room" }
+            { "(code-blocks)" ( -- array ) "primitive_code_blocks" }
+            { "(code-room)" ( -- allocator-room ) "primitive_code_room" }
+            { "(data-room)" ( -- data-room ) "primitive_data_room" }
+            { "disable-gc-events" ( -- events ) "primitive_disable_gc_events" }
+            { "enable-gc-events" ( -- ) "primitive_enable_gc_events" }
+        }
+    }
+    {
+        "tools.profiler.sampling.private"
+        {
+            { "profiling" ( ? -- ) "primitive_sampling_profiler" }
+            { "(get-samples)" ( -- samples/f ) "primitive_get_samples" }
+            { "(clear-samples)" ( -- ) "primitive_clear_samples" }
+        }
+    }
+    {
+        "words"
+        {
+            { "word-code" ( word -- start end ) "primitive_word_code" }
+            { "word-optimized?" ( word -- ? ) "primitive_word_optimized_p" }
+        }
+    }
+    {
+        "words.private"
+        {
+            { "(word)" ( name vocab hashcode -- word ) "primitive_word" }
+        }
+    }
+}
+
+: primitive-quot ( word vm-func -- quot )
+    [ nip ascii string>alien [ do-primitive ] curry ] [ 1quotation ] if* ;
+
+: primitive-word ( name vocab -- word )
+    create-word dup t "primitive" set-word-prop ;
+
+:: create-primitive ( vocab word effect vm-func -- )
+    word vocab primitive-word
+    dup vm-func primitive-quot effect define-declared ;
+
+: create-primitives ( assoc -- )
+    [ [ first3 create-primitive ] with each ] assoc-each ;
index 06d464dfbf453310f6e31c9a301e385d066f4217..cc051e3a13aae6df32c4ec34bf4efb431d7a2552 100644 (file)
@@ -1,7 +1,7 @@
 USING: bootstrap.image.private effects help.markup help.syntax strings ;
 IN: bootstrap.primitives
 
-HELP: make-sub-primitive
-{ $values { "word" string } { "vocab" string } { "effect" effect } }
-{ $description "Defines a sub primitive word." }
-{ $see-also define-sub-primitive } ;
+ARTICLE: "bootstrap.primitives" "Bootstrap primitives"
+"A script file run to create the bootstrap image. Also see the vocab " { $link "bootstrap.image.primitives" } "." ;
+
+ABOUT: "bootstrap.primitives"
index 6e95f70b2ab3f740946e1303b046c783ffba448e..5e175373eb6162ee0a7a9c3fb7b949e04e429238 100755 (executable)
@@ -1,14 +1,15 @@
 ! Copyright (C) 2004, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien.strings arrays assocs bootstrap.image.private classes
-classes.builtin classes.intersection classes.predicate classes.private
-classes.singleton classes.tuple classes.tuple.private classes.union
-combinators compiler.units io io.encodings.ascii kernel kernel.private
-layouts make math math.private namespaces parser quotations sequences
-slots source-files splitting vocabs vocabs.loader words ;
+USING: arrays assocs bootstrap.image.primitives
+bootstrap.image.private classes classes.builtin classes.intersection
+classes.predicate classes.private classes.singleton classes.tuple
+classes.tuple.private classes.union combinators compiler.units io
+kernel kernel.private layouts make math math.private namespaces parser
+quotations sequences slots source-files splitting vocabs vocabs.loader
+words ;
 IN: bootstrap.primitives
 
-"Creating primitives and basic runtime structures..." print flush
+"Creating primitives and basic runtime structures..." print flush
 
 H{ } clone sub-primitives set
 
@@ -319,249 +320,8 @@ tuple
 } cleave
 ( quot1 quot2 -- compose ) define-declared
 
-! Sub-primitive words
-: make-sub-primitive ( word vocab effect -- )
-    [
-        create-word
-        dup t "primitive" set-word-prop
-        dup 1quotation
-    ] dip define-declared ;
-
-{
-    { "mega-cache-lookup" "generic.single.private" ( methods index cache -- ) }
-    { "inline-cache-miss" "generic.single.private" ( generic methods index cache -- ) }
-    { "inline-cache-miss-tail" "generic.single.private" ( generic methods index cache -- ) }
-    { "drop" "kernel" ( x -- ) }
-    { "2drop" "kernel" ( x y -- ) }
-    { "3drop" "kernel" ( x y z -- ) }
-    { "4drop" "kernel" ( w x y z -- ) }
-    { "dup" "kernel" ( x -- x x ) }
-    { "2dup" "kernel" ( x y -- x y x y ) }
-    { "3dup" "kernel" ( x y z -- x y z x y z ) }
-    { "4dup" "kernel" ( w x y z -- w x y z w x y z ) }
-    { "rot" "kernel" ( x y z -- y z x ) }
-    { "-rot" "kernel" ( x y z -- z x y ) }
-    { "dupd" "kernel" ( x y -- x x y ) }
-    { "swapd" "kernel" ( x y z -- y x z ) }
-    { "nip" "kernel" ( x y -- y ) }
-    { "2nip" "kernel" ( x y z -- z ) }
-    { "over" "kernel" ( x y -- x y x ) }
-    { "pick" "kernel" ( x y z -- x y z x ) }
-    { "swap" "kernel" ( x y -- y x ) }
-    { "eq?" "kernel" ( obj1 obj2 -- ? ) }
-    { "tag" "kernel.private" ( object -- n ) }
-    { "(execute)" "kernel.private" ( word -- ) }
-    { "(call)" "kernel.private" ( quot -- ) }
-    { "fpu-state" "kernel.private" ( -- ) }
-    { "set-fpu-state" "kernel.private" ( -- ) }
-    { "signal-handler" "kernel.private" ( -- ) }
-    { "leaf-signal-handler" "kernel.private" ( -- ) }
-    { "unwind-native-frames" "kernel.private" ( -- ) }
-    { "set-callstack" "kernel.private" ( callstack -- * ) }
-    { "lazy-jit-compile" "kernel.private" ( -- ) }
-    { "c-to-factor" "kernel.private" ( -- ) }
-    { "slot" "slots.private" ( obj m -- value ) }
-    { "get-local" "locals.backend" ( n -- obj ) }
-    { "load-local" "locals.backend" ( obj -- ) }
-    { "drop-locals" "locals.backend" ( n -- ) }
-    { "both-fixnums?" "math.private" ( x y -- ? ) }
-    { "fixnum+fast" "math.private" ( x y -- z ) }
-    { "fixnum-fast" "math.private" ( x y -- z ) }
-    { "fixnum*fast" "math.private" ( x y -- z ) }
-    { "fixnum-bitand" "math.private" ( x y -- z ) }
-    { "fixnum-bitor" "math.private" ( x y -- z ) }
-    { "fixnum-bitxor" "math.private" ( x y -- z ) }
-    { "fixnum-bitnot" "math.private" ( x -- y ) }
-    { "fixnum-mod" "math.private" ( x y -- z ) }
-    { "fixnum-shift-fast" "math.private" ( x y -- z ) }
-    { "fixnum/i-fast" "math.private" ( x y -- z ) }
-    { "fixnum/mod-fast" "math.private" ( x y -- z w ) }
-    { "fixnum+" "math.private" ( x y -- z ) }
-    { "fixnum-" "math.private" ( x y -- z ) }
-    { "fixnum*" "math.private" ( x y -- z ) }
-    { "fixnum<" "math.private" ( x y -- ? ) }
-    { "fixnum<=" "math.private" ( x y -- z ) }
-    { "fixnum>" "math.private" ( x y -- ? ) }
-    { "fixnum>=" "math.private" ( x y -- ? ) }
-    { "string-nth-fast" "strings.private" ( n string -- ch ) }
-    { "(set-context)" "threads.private" ( obj context -- obj' ) }
-    { "(set-context-and-delete)" "threads.private" ( obj context -- * ) }
-    { "(start-context)" "threads.private" ( obj quot -- obj' ) }
-    { "(start-context-and-delete)" "threads.private" ( obj quot -- * ) }
-} [ first3 make-sub-primitive ] each
-
-! Primitive words
-: make-primitive ( word vocab function effect -- )
-    [
-        [
-            create-word
-            dup reset-word
-            dup t "primitive" set-word-prop
-        ] dip
-        ascii string>alien [ do-primitive ] curry
-    ] dip define-declared ;
-
-{
-    { "<callback>" "alien" "primitive_callback" ( word return-rewind -- alien ) }
-    { "<displaced-alien>" "alien" "primitive_displaced_alien" ( displacement c-ptr -- alien ) }
-    { "alien-address" "alien" "primitive_alien_address" ( c-ptr -- addr ) }
-    { "alien-cell" "alien.accessors" "primitive_alien_cell" ( c-ptr n -- value ) }
-    { "alien-double" "alien.accessors" "primitive_alien_double" ( c-ptr n -- value ) }
-    { "alien-float" "alien.accessors" "primitive_alien_float" ( c-ptr n -- value ) }
-    { "alien-signed-1" "alien.accessors" "primitive_alien_signed_1" ( c-ptr n -- value ) }
-    { "alien-signed-2" "alien.accessors" "primitive_alien_signed_2" ( c-ptr n -- value ) }
-    { "alien-signed-4" "alien.accessors" "primitive_alien_signed_4" ( c-ptr n -- value ) }
-    { "alien-signed-8" "alien.accessors" "primitive_alien_signed_8" ( c-ptr n -- value ) }
-    { "alien-signed-cell" "alien.accessors" "primitive_alien_signed_cell" ( c-ptr n -- value ) }
-    { "alien-unsigned-1" "alien.accessors" "primitive_alien_unsigned_1" ( c-ptr n -- value ) }
-    { "alien-unsigned-2" "alien.accessors" "primitive_alien_unsigned_2" ( c-ptr n -- value ) }
-    { "alien-unsigned-4" "alien.accessors" "primitive_alien_unsigned_4" ( c-ptr n -- value ) }
-    { "alien-unsigned-8" "alien.accessors" "primitive_alien_unsigned_8" ( c-ptr n -- value ) }
-    { "alien-unsigned-cell" "alien.accessors" "primitive_alien_unsigned_cell" ( c-ptr n -- value ) }
-    { "set-alien-cell" "alien.accessors" "primitive_set_alien_cell" ( value c-ptr n -- ) }
-    { "set-alien-double" "alien.accessors" "primitive_set_alien_double" ( value c-ptr n -- ) }
-    { "set-alien-float" "alien.accessors" "primitive_set_alien_float" ( value c-ptr n -- ) }
-    { "set-alien-signed-1" "alien.accessors" "primitive_set_alien_signed_1" ( value c-ptr n -- ) }
-    { "set-alien-signed-2" "alien.accessors" "primitive_set_alien_signed_2" ( value c-ptr n -- ) }
-    { "set-alien-signed-4" "alien.accessors" "primitive_set_alien_signed_4" ( value c-ptr n -- ) }
-    { "set-alien-signed-8" "alien.accessors" "primitive_set_alien_signed_8" ( value c-ptr n -- ) }
-    { "set-alien-signed-cell" "alien.accessors" "primitive_set_alien_signed_cell" ( value c-ptr n -- ) }
-    { "set-alien-unsigned-1" "alien.accessors" "primitive_set_alien_unsigned_1" ( value c-ptr n -- ) }
-    { "set-alien-unsigned-2" "alien.accessors" "primitive_set_alien_unsigned_2" ( value c-ptr n -- ) }
-    { "set-alien-unsigned-4" "alien.accessors" "primitive_set_alien_unsigned_4" ( value c-ptr n -- ) }
-    { "set-alien-unsigned-8" "alien.accessors" "primitive_set_alien_unsigned_8" ( value c-ptr n -- ) }
-    { "set-alien-unsigned-cell" "alien.accessors" "primitive_set_alien_unsigned_cell" ( value c-ptr n -- ) }
-    { "(dlopen)" "alien.libraries" "primitive_dlopen" ( path -- dll ) }
-    { "(dlsym)" "alien.libraries" "primitive_dlsym" ( name dll -- alien ) }
-    { "(dlsym-raw)" "alien.libraries" "primitive_dlsym_raw" ( name dll -- alien ) }
-    { "dlclose" "alien.libraries" "primitive_dlclose" ( dll -- ) }
-    { "dll-valid?" "alien.libraries" "primitive_dll_validp" ( dll -- ? ) }
-    { "current-callback" "alien.private" "primitive_current_callback" ( -- n ) }
-    { "<array>" "arrays" "primitive_array" ( n elt -- array ) }
-    { "resize-array" "arrays" "primitive_resize_array" ( n array -- new-array ) }
-    { "(byte-array)" "byte-arrays" "primitive_uninitialized_byte_array" ( n -- byte-array ) }
-    { "<byte-array>" "byte-arrays" "primitive_byte_array" ( n -- byte-array ) }
-    { "resize-byte-array" "byte-arrays" "primitive_resize_byte_array" ( n byte-array -- new-byte-array ) }
-    { "<tuple-boa>" "classes.tuple.private" "primitive_tuple_boa" ( slots... layout -- tuple ) }
-    { "<tuple>" "classes.tuple.private" "primitive_tuple" ( layout -- tuple ) }
-    { "modify-code-heap" "compiler.units" "primitive_modify_code_heap" ( alist update-existing? reset-pics? -- ) }
-    { "lookup-method" "generic.single.private" "primitive_lookup_method" ( object methods -- method ) }
-    { "mega-cache-miss" "generic.single.private" "primitive_mega_cache_miss" ( methods index cache -- method ) }
-    { "(exists?)" "io.files.private" "primitive_existsp" ( path -- ? ) }
-    { "(fopen)" "io.streams.c" "primitive_fopen" ( path mode -- alien ) }
-    { "fclose" "io.streams.c" "primitive_fclose" ( alien -- ) }
-    { "fflush" "io.streams.c" "primitive_fflush" ( alien -- ) }
-    { "fgetc" "io.streams.c" "primitive_fgetc" ( alien -- byte/f ) }
-    { "fputc" "io.streams.c" "primitive_fputc" ( byte alien -- ) }
-    { "fread-unsafe" "io.streams.c" "primitive_fread" ( n buf alien -- count ) }
-    { "free-callback" "alien" "primitive_free_callback" ( alien -- ) }
-    { "fseek" "io.streams.c" "primitive_fseek" ( alien offset whence -- ) }
-    { "ftell" "io.streams.c" "primitive_ftell" ( alien -- n ) }
-    { "fwrite" "io.streams.c" "primitive_fwrite" ( data length alien -- ) }
-    { "(clone)" "kernel" "primitive_clone" ( obj -- newobj ) }
-    { "<wrapper>" "kernel" "primitive_wrapper" ( obj -- wrapper ) }
-
-    { "callstack>array" "kernel" "primitive_callstack_to_array" ( callstack -- array ) }
-    { "die" "kernel" "primitive_die" ( -- ) }
-    { "callstack-for" "kernel.private" "primitive_callstack_for" ( context -- array ) }
-    { "datastack-for" "kernel.private" "primitive_datastack_for" ( context -- array ) }
-    { "retainstack-for" "kernel.private" "primitive_retainstack_for" ( context -- array ) }
-    { "(identity-hashcode)" "kernel.private" "primitive_identity_hashcode" ( obj -- code ) }
-    { "become" "kernel.private" "primitive_become" ( old new -- ) }
-    { "callstack-bounds" "kernel.private" "primitive_callstack_bounds" ( -- start end ) }
-    { "check-datastack" "kernel.private" "primitive_check_datastack" ( array in# out# -- ? ) }
-    { "compute-identity-hashcode" "kernel.private" "primitive_compute_identity_hashcode" ( obj -- ) }
-    { "context-object" "kernel.private" "primitive_context_object" ( n -- obj ) }
-    { "innermost-frame-executing" "kernel.private" "primitive_innermost_stack_frame_executing" ( callstack -- obj ) }
-    { "innermost-frame-scan" "kernel.private" "primitive_innermost_stack_frame_scan" ( callstack -- n ) }
-    { "set-context-object" "kernel.private" "primitive_set_context_object" ( obj n -- ) }
-    { "set-datastack" "kernel.private" "primitive_set_datastack" ( array -- ) }
-    { "set-innermost-frame-quotation" "kernel.private" "primitive_set_innermost_stack_frame_quotation" ( n callstack -- ) }
-    { "set-retainstack" "kernel.private" "primitive_set_retainstack" ( array -- ) }
-    { "set-special-object" "kernel.private" "primitive_set_special_object" ( obj n -- ) }
-    { "special-object" "kernel.private" "primitive_special_object" ( n -- obj ) }
-    { "strip-stack-traces" "kernel.private" "primitive_strip_stack_traces" ( -- ) }
-    { "unimplemented" "kernel.private" "primitive_unimplemented" ( -- * ) }
-    { "load-locals" "locals.backend" "primitive_load_locals" ( ... n -- ) }
-    { "bits>double" "math" "primitive_bits_double" ( n -- x ) }
-    { "bits>float" "math" "primitive_bits_float" ( n -- x ) }
-    { "double>bits" "math" "primitive_double_bits" ( x -- n ) }
-    { "float>bits" "math" "primitive_float_bits" ( x -- n ) }
-    { "(format-float)" "math.parser.private" "primitive_format_float" ( n fill width precision format locale -- byte-array ) }
-    { "bignum*" "math.private" "primitive_bignum_multiply" ( x y -- z ) }
-    { "bignum+" "math.private" "primitive_bignum_add" ( x y -- z ) }
-    { "bignum-" "math.private" "primitive_bignum_subtract" ( x y -- z ) }
-    { "bignum-bit?" "math.private" "primitive_bignum_bitp" ( x n -- ? ) }
-    { "bignum-bitand" "math.private" "primitive_bignum_and" ( x y -- z ) }
-    { "bignum-bitnot" "math.private" "primitive_bignum_not" ( x -- y ) }
-    { "bignum-bitor" "math.private" "primitive_bignum_or" ( x y -- z ) }
-    { "bignum-bitxor" "math.private" "primitive_bignum_xor" ( x y -- z ) }
-    { "bignum-log2" "math.private" "primitive_bignum_log2" ( x -- n ) }
-    { "bignum-mod" "math.private" "primitive_bignum_mod" ( x y -- z ) }
-    { "bignum-gcd" "math.private" "primitive_bignum_gcd" ( x y -- z ) }
-    { "bignum-shift" "math.private" "primitive_bignum_shift" ( x y -- z ) }
-    { "bignum/i" "math.private" "primitive_bignum_divint" ( x y -- z ) }
-    { "bignum/mod" "math.private" "primitive_bignum_divmod" ( x y -- z w ) }
-    { "bignum<" "math.private" "primitive_bignum_less" ( x y -- ? ) }
-    { "bignum<=" "math.private" "primitive_bignum_lesseq" ( x y -- ? ) }
-    { "bignum=" "math.private" "primitive_bignum_eq" ( x y -- ? ) }
-    { "bignum>" "math.private" "primitive_bignum_greater" ( x y -- ? ) }
-    { "bignum>=" "math.private" "primitive_bignum_greatereq" ( x y -- ? ) }
-    { "bignum>fixnum" "math.private" "primitive_bignum_to_fixnum" ( x -- y ) }
-    { "bignum>fixnum-strict" "math.private" "primitive_bignum_to_fixnum_strict" ( x -- y ) }
-    { "fixnum-shift" "math.private" "primitive_fixnum_shift" ( x y -- z ) }
-    { "fixnum/i" "math.private" "primitive_fixnum_divint" ( x y -- z ) }
-    { "fixnum/mod" "math.private" "primitive_fixnum_divmod" ( x y -- z w ) }
-    { "fixnum>bignum" "math.private" "primitive_fixnum_to_bignum" ( x -- y ) }
-    { "fixnum>float" "math.private" "primitive_fixnum_to_float" ( x -- y ) }
-    { "float*" "math.private" "primitive_float_multiply" ( x y -- z ) }
-    { "float+" "math.private" "primitive_float_add" ( x y -- z ) }
-    { "float-" "math.private" "primitive_float_subtract" ( x y -- z ) }
-    { "float-u<" "math.private" "primitive_float_less" ( x y -- ? ) }
-    { "float-u<=" "math.private" "primitive_float_lesseq" ( x y -- ? ) }
-    { "float-u>" "math.private" "primitive_float_greater" ( x y -- ? ) }
-    { "float-u>=" "math.private" "primitive_float_greatereq" ( x y -- ? ) }
-    { "float/f" "math.private" "primitive_float_divfloat" ( x y -- z ) }
-    { "float<" "math.private" "primitive_float_less" ( x y -- ? ) }
-    { "float<=" "math.private" "primitive_float_lesseq" ( x y -- ? ) }
-    { "float=" "math.private" "primitive_float_eq" ( x y -- ? ) }
-    { "float>" "math.private" "primitive_float_greater" ( x y -- ? ) }
-    { "float>=" "math.private" "primitive_float_greatereq" ( x y -- ? ) }
-    { "float>bignum" "math.private" "primitive_float_to_bignum" ( x -- y ) }
-    { "float>fixnum" "math.private" "primitive_float_to_fixnum" ( x -- y ) }
-    { "all-instances" "memory" "primitive_all_instances" ( -- array ) }
-    { "(code-blocks)" "tools.memory.private" "primitive_code_blocks" ( -- array ) }
-    { "(code-room)" "tools.memory.private" "primitive_code_room" ( -- allocator-room ) }
-    { "compact-gc" "memory" "primitive_compact_gc" ( -- ) }
-    { "(callback-room)" "tools.memory.private" "primitive_callback_room" ( -- allocator-room ) }
-    { "(data-room)" "tools.memory.private" "primitive_data_room" ( -- data-room ) }
-    { "disable-gc-events" "tools.memory.private" "primitive_disable_gc_events" ( -- events ) }
-    { "enable-gc-events" "tools.memory.private" "primitive_enable_gc_events" ( -- ) }
-    { "gc" "memory" "primitive_full_gc" ( -- ) }
-    { "minor-gc" "memory" "primitive_minor_gc" ( -- ) }
-    { "size" "memory" "primitive_size" ( obj -- n ) }
-    { "(save-image)" "memory.private" "primitive_save_image" ( path1 path2 then-die? -- ) }
-    { "jit-compile" "quotations" "primitive_jit_compile" ( quot -- ) }
-    { "quotation-code" "quotations" "primitive_quotation_code" ( quot -- start end ) }
-    { "quotation-compiled?" "quotations" "primitive_quotation_compiled_p" ( quot -- ? ) }
-    { "array>quotation" "quotations.private" "primitive_array_to_quotation" ( array -- quot ) }
-    { "set-slot" "slots.private" "primitive_set_slot" ( value obj n -- ) }
-    { "<string>" "strings" "primitive_string" ( n ch -- string ) }
-    { "resize-string" "strings" "primitive_resize_string" ( n str -- newstr ) }
-    { "set-string-nth-fast" "strings.private" "primitive_set_string_nth_fast" ( ch n string -- ) }
-    { "(exit)" "system" "primitive_exit" ( n -- * ) }
-    { "nano-count" "system" "primitive_nano_count" ( -- ns ) }
-    { "(sleep)" "threads.private" "primitive_sleep" ( nanos -- ) }
-    { "context-object-for" "threads.private" "primitive_context_object_for" ( n context -- obj ) }
-    { "dispatch-stats" "tools.dispatch.private" "primitive_dispatch_stats" ( -- stats ) }
-    { "reset-dispatch-stats" "tools.dispatch.private" "primitive_reset_dispatch_stats" ( -- ) }
-    { "word-code" "words" "primitive_word_code" ( word -- start end ) }
-    { "word-optimized?" "words" "primitive_word_optimized_p" ( word -- ? ) }
-    { "(word)" "words.private" "primitive_word" ( name vocab hashcode -- word ) }
-    { "profiling" "tools.profiler.sampling.private" "primitive_sampling_profiler" ( ? -- ) }
-    { "(get-samples)" "tools.profiler.sampling.private" "primitive_get_samples" ( -- samples/f ) }
-    { "(clear-samples)" "tools.profiler.sampling.private" "primitive_clear_samples" ( -- ) }
-} [ first4 make-primitive ] each
+"* Declaring primitives..." print flush
+all-primitives create-primitives
 
 ! Bump build number
 "build" "kernel" create-word build 1 + [ ] curry ( -- n ) define-declared