]> gitweb.factorcode.org Git - factor.git/blob - core/bootstrap/primitives.factor
bootstrap.primitives: new predicate integer-array-capacity
[factor.git] / core / bootstrap / primitives.factor
1 ! Copyright (C) 2004, 2010 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: alien.strings arrays assocs bootstrap.image.private classes
4 classes.builtin classes.intersection classes.predicate classes.private
5 classes.singleton classes.tuple classes.tuple.private classes.union
6 combinators compiler.units io io.encodings.ascii kernel kernel.private
7 layouts make math math.private namespaces parser quotations sequences
8 slots source-files splitting vocabs vocabs.loader words ;
9 IN: bootstrap.primitives
10
11 "Creating primitives and basic runtime structures..." print flush
12
13 H{ } clone sub-primitives set
14
15 "vocab:bootstrap/syntax.factor" parse-file
16
17 : asm-file ( arch -- file )
18     "-" split reverse "." join
19     "vocab:bootstrap/assembler/" ".factor" surround ;
20
21 architecture get asm-file parse-file
22
23 "vocab:bootstrap/layouts/layouts.factor" parse-file
24
25 ! Now we have ( syntax-quot arch-quot layouts-quot ) on the stack
26
27 ! Bring up a bare cross-compiling vocabulary.
28 "syntax" lookup-vocab vocab-words-assoc bootstrap-syntax set
29
30 H{ } clone dictionary set
31 H{ } clone root-cache set
32 H{ } clone source-files set
33 H{ } clone update-map set
34 H{ } clone implementors-map set
35
36 init-caches
37
38 bootstrapping? on
39
40 call( -- ) ! layouts quot
41 call( -- ) ! arch quot
42
43 ! Vocabulary for slot accessors
44 "accessors" create-vocab drop
45
46 ! After we execute bootstrap/layouts
47 num-types get f <array> builtins set
48
49 [
50
51 call( -- ) ! syntax-quot
52
53 ! create-word some empty vocabs where the below primitives and
54 ! classes will go
55 {
56     "alien"
57     "alien.accessors"
58     "alien.libraries"
59     "alien.private"
60     "arrays"
61     "byte-arrays"
62     "classes.private"
63     "classes.tuple"
64     "classes.tuple.private"
65     "classes.predicate"
66     "compiler.units"
67     "continuations.private"
68     "generic.single"
69     "generic.single.private"
70     "growable"
71     "hashtables"
72     "hashtables.private"
73     "io"
74     "io.files"
75     "io.files.private"
76     "io.streams.c"
77     "locals.backend"
78     "kernel"
79     "kernel.private"
80     "math"
81     "math.parser.private"
82     "math.private"
83     "memory"
84     "memory.private"
85     "quotations"
86     "quotations.private"
87     "sbufs"
88     "sbufs.private"
89     "scratchpad"
90     "sequences"
91     "sequences.private"
92     "slots.private"
93     "strings"
94     "strings.private"
95     "system"
96     "system.private"
97     "threads.private"
98     "tools.dispatch.private"
99     "tools.memory.private"
100     "tools.profiler.sampling.private"
101     "words"
102     "words.private"
103     "vectors"
104     "vectors.private"
105     "vm"
106 } [ create-vocab drop ] each
107
108 ! Builtin classes
109 : lookup-type-number ( word -- n )
110     [ target-word ] with-global type-number ;
111
112 : register-builtin ( class -- )
113     [ dup lookup-type-number "type" set-word-prop ]
114     [ dup "type" word-prop builtins get set-nth ]
115     [ f f f builtin-class define-class ]
116     tri ;
117
118 : prepare-slots ( slots -- slots' )
119     [ [ dup pair? [ first2 create-word ] when ] map ] map ;
120
121 : define-builtin-slots ( class slots -- )
122     prepare-slots make-slots 1 finalize-slots
123     [ "slots" set-word-prop ] [ define-accessors ] 2bi ;
124
125 : define-builtin-predicate ( class -- )
126     dup class>type [ eq? ] curry [ tag ] prepend define-predicate ;
127
128 : define-builtin ( symbol slotspec -- )
129     [ [ define-builtin-predicate ] keep ] dip define-builtin-slots ;
130
131 "fixnum" "math" create-word register-builtin
132 "bignum" "math" create-word register-builtin
133 "tuple" "kernel" create-word register-builtin
134 "float" "math" create-word register-builtin
135 "f" "syntax" lookup-word register-builtin
136 "array" "arrays" create-word register-builtin
137 "wrapper" "kernel" create-word register-builtin
138 "callstack" "kernel" create-word register-builtin
139 "string" "strings" create-word register-builtin
140 "quotation" "quotations" create-word register-builtin
141 "dll" "alien" create-word register-builtin
142 "alien" "alien" create-word register-builtin
143 "word" "words" create-word register-builtin
144 "byte-array" "byte-arrays" create-word register-builtin
145
146 ! We need this before defining c-ptr below
147 "f" "syntax" lookup-word { } define-builtin
148
149 "f" "syntax" create-word [ not ] "predicate" set-word-prop
150 "f?" "syntax" vocab-words-assoc delete-at
151
152 "t" "syntax" lookup-word define-singleton-class
153
154 ! Some unions
155 "c-ptr" "alien" create-word [
156     "alien" "alien" lookup-word ,
157     "f" "syntax" lookup-word ,
158     "byte-array" "byte-arrays" lookup-word ,
159 ] { } make define-union-class
160
161 "integer" "math" create-word
162 "fixnum" "math" lookup-word "bignum" "math" lookup-word 2array
163 define-union-class
164
165 ! Two predicate classes used for declarations.
166 "array-capacity" "sequences.private" create-word
167 "fixnum" "math" lookup-word
168 [
169     [ dup 0 fixnum>= ] %
170     bootstrap-max-array-capacity <fake-bignum> [ fixnum<= ] curry ,
171     [ [ drop f ] if ] %
172 ] [ ] make
173 define-predicate-class
174
175 "array-capacity" "sequences.private" lookup-word
176 [ >fixnum ] bootstrap-max-array-capacity <fake-bignum> [ fixnum-bitand ] curry append
177 "coercer" set-word-prop
178
179 "integer-array-capacity" "sequences.private" create-word
180 "integer" "math" lookup-word
181 [
182     [ dup 0 >= ] %
183     bootstrap-max-array-capacity <fake-bignum> [ <= ] curry ,
184     [ [ drop f ] if ] %
185 ] [ ] make
186 define-predicate-class
187
188 ! Catch-all class for providing a default method.
189 "object" "kernel" create-word
190 [ f f { } intersection-class define-class ]
191 [ [ drop t ] "predicate" set-word-prop ]
192 bi
193
194 "object?" "kernel" vocab-words-assoc delete-at
195
196 ! Empty class with no instances
197 "null" "kernel" create-word
198 [ f { } f union-class define-class ]
199 [ [ drop f ] "predicate" set-word-prop ]
200 bi
201
202 "null?" "kernel" vocab-words-assoc delete-at
203
204 "fixnum" "math" create-word { } define-builtin
205 "fixnum" "math" create-word "integer>fixnum-strict" "math" create-word 1quotation "coercer" set-word-prop
206
207 "bignum" "math" create-word { } define-builtin
208 "bignum" "math" create-word ">bignum" "math" create-word 1quotation "coercer" set-word-prop
209
210 "float" "math" create-word { } define-builtin
211 "float" "math" create-word ">float" "math" create-word 1quotation "coercer" set-word-prop
212
213 "array" "arrays" create-word {
214     { "length" { "array-capacity" "sequences.private" } read-only }
215 } define-builtin
216
217 "wrapper" "kernel" create-word {
218     { "wrapped" read-only }
219 } define-builtin
220
221 "string" "strings" create-word {
222     { "length" { "array-capacity" "sequences.private" } read-only }
223     "aux"
224 } define-builtin
225
226 "quotation" "quotations" create-word {
227     { "array" { "array" "arrays" } read-only }
228     "cached-effect"
229     "cache-counter"
230 } define-builtin
231
232 "dll" "alien" create-word {
233     { "path" { "byte-array" "byte-arrays" } read-only }
234 } define-builtin
235
236 "alien" "alien" create-word {
237     { "underlying" { "c-ptr" "alien" } read-only }
238     "expired"
239 } define-builtin
240
241 "word" "words" create-word {
242     { "hashcode" { "fixnum" "math" } }
243     "name"
244     "vocabulary"
245     { "def" { "quotation" "quotations" } initial: [ ] }
246     "props"
247     "pic-def"
248     "pic-tail-def"
249     { "sub-primitive" read-only }
250 } define-builtin
251
252 "byte-array" "byte-arrays" create-word {
253     { "length" { "array-capacity" "sequences.private" } read-only }
254 } define-builtin
255
256 "callstack" "kernel" create-word { } define-builtin
257
258 "tuple" "kernel" create-word
259 [ { } define-builtin ]
260 [ define-tuple-layout ]
261 bi
262
263 ! create-word special tombstone values
264 "tombstone" "hashtables.private" create-word
265 tuple
266 { "state" } define-tuple-class
267
268 "((empty))" "hashtables.private" create-word
269 { f } "tombstone" "hashtables.private" lookup-word
270 slots>tuple 1quotation ( -- value ) define-inline
271
272 "((tombstone))" "hashtables.private" create-word
273 { t } "tombstone" "hashtables.private" lookup-word
274 slots>tuple 1quotation ( -- value ) define-inline
275
276 ! Some tuple classes
277 "curry" "kernel" create-word
278 tuple
279 {
280     { "obj" read-only }
281     { "quot" read-only }
282 } prepare-slots define-tuple-class
283
284 "curry" "kernel" lookup-word
285 {
286     [ f "inline" set-word-prop ]
287     [ make-flushable ]
288     [ ]
289     [
290         [
291             callable instance-check-quot %
292             tuple-layout ,
293             \ <tuple-boa> ,
294         ] [ ] make
295     ]
296 } cleave
297 ( obj quot -- curry ) define-declared
298
299 "compose" "kernel" create-word
300 tuple
301 {
302     { "first" read-only }
303     { "second" read-only }
304 } prepare-slots define-tuple-class
305
306 "compose" "kernel" lookup-word
307 {
308     [ f "inline" set-word-prop ]
309     [ make-flushable ]
310     [ ]
311     [
312         [
313             callable instance-check-quot [ dip ] curry %
314             callable instance-check-quot %
315             tuple-layout ,
316             \ <tuple-boa> ,
317         ] [ ] make
318     ]
319 } cleave
320 ( quot1 quot2 -- compose ) define-declared
321
322 ! Sub-primitive words
323 : make-sub-primitive ( word vocab effect -- )
324     [
325         create-word
326         dup t "primitive" set-word-prop
327         dup 1quotation
328     ] dip define-declared ;
329
330 {
331     { "mega-cache-lookup" "generic.single.private" ( methods index cache -- ) }
332     { "inline-cache-miss" "generic.single.private" ( generic methods index cache -- ) }
333     { "inline-cache-miss-tail" "generic.single.private" ( generic methods index cache -- ) }
334     { "drop" "kernel" ( x -- ) }
335     { "2drop" "kernel" ( x y -- ) }
336     { "3drop" "kernel" ( x y z -- ) }
337     { "4drop" "kernel" ( w x y z -- ) }
338     { "dup" "kernel" ( x -- x x ) }
339     { "2dup" "kernel" ( x y -- x y x y ) }
340     { "3dup" "kernel" ( x y z -- x y z x y z ) }
341     { "4dup" "kernel" ( w x y z -- w x y z w x y z ) }
342     { "rot" "kernel" ( x y z -- y z x ) }
343     { "-rot" "kernel" ( x y z -- z x y ) }
344     { "dupd" "kernel" ( x y -- x x y ) }
345     { "swapd" "kernel" ( x y z -- y x z ) }
346     { "nip" "kernel" ( x y -- y ) }
347     { "2nip" "kernel" ( x y z -- z ) }
348     { "over" "kernel" ( x y -- x y x ) }
349     { "pick" "kernel" ( x y z -- x y z x ) }
350     { "swap" "kernel" ( x y -- y x ) }
351     { "eq?" "kernel" ( obj1 obj2 -- ? ) }
352     { "tag" "kernel.private" ( object -- n ) }
353     { "(execute)" "kernel.private" ( word -- ) }
354     { "(call)" "kernel.private" ( quot -- ) }
355     { "fpu-state" "kernel.private" ( -- ) }
356     { "set-fpu-state" "kernel.private" ( -- ) }
357     { "signal-handler" "kernel.private" ( -- ) }
358     { "leaf-signal-handler" "kernel.private" ( -- ) }
359     { "unwind-native-frames" "kernel.private" ( -- ) }
360     { "set-callstack" "kernel.private" ( callstack -- * ) }
361     { "lazy-jit-compile" "kernel.private" ( -- ) }
362     { "c-to-factor" "kernel.private" ( -- ) }
363     { "slot" "slots.private" ( obj m -- value ) }
364     { "get-local" "locals.backend" ( n -- obj ) }
365     { "load-local" "locals.backend" ( obj -- ) }
366     { "drop-locals" "locals.backend" ( n -- ) }
367     { "both-fixnums?" "math.private" ( x y -- ? ) }
368     { "fixnum+fast" "math.private" ( x y -- z ) }
369     { "fixnum-fast" "math.private" ( x y -- z ) }
370     { "fixnum*fast" "math.private" ( x y -- z ) }
371     { "fixnum-bitand" "math.private" ( x y -- z ) }
372     { "fixnum-bitor" "math.private" ( x y -- z ) }
373     { "fixnum-bitxor" "math.private" ( x y -- z ) }
374     { "fixnum-bitnot" "math.private" ( x -- y ) }
375     { "fixnum-mod" "math.private" ( x y -- z ) }
376     { "fixnum-shift-fast" "math.private" ( x y -- z ) }
377     { "fixnum/i-fast" "math.private" ( x y -- z ) }
378     { "fixnum/mod-fast" "math.private" ( x y -- z w ) }
379     { "fixnum+" "math.private" ( x y -- z ) }
380     { "fixnum-" "math.private" ( x y -- z ) }
381     { "fixnum*" "math.private" ( x y -- z ) }
382     { "fixnum<" "math.private" ( x y -- ? ) }
383     { "fixnum<=" "math.private" ( x y -- z ) }
384     { "fixnum>" "math.private" ( x y -- ? ) }
385     { "fixnum>=" "math.private" ( x y -- ? ) }
386     { "string-nth-fast" "strings.private" ( n string -- ch ) }
387     { "(set-context)" "threads.private" ( obj context -- obj' ) }
388     { "(set-context-and-delete)" "threads.private" ( obj context -- * ) }
389     { "(start-context)" "threads.private" ( obj quot -- obj' ) }
390     { "(start-context-and-delete)" "threads.private" ( obj quot -- * ) }
391 } [ first3 make-sub-primitive ] each
392
393 ! Primitive words
394 : make-primitive ( word vocab function effect -- )
395     [
396         [
397             create-word
398             dup reset-word
399             dup t "primitive" set-word-prop
400         ] dip
401         ascii string>alien [ do-primitive ] curry
402     ] dip define-declared ;
403
404 {
405     { "<callback>" "alien" "primitive_callback" ( word return-rewind -- alien ) }
406     { "<displaced-alien>" "alien" "primitive_displaced_alien" ( displacement c-ptr -- alien ) }
407     { "alien-address" "alien" "primitive_alien_address" ( c-ptr -- addr ) }
408     { "alien-cell" "alien.accessors" "primitive_alien_cell" ( c-ptr n -- value ) }
409     { "alien-double" "alien.accessors" "primitive_alien_double" ( c-ptr n -- value ) }
410     { "alien-float" "alien.accessors" "primitive_alien_float" ( c-ptr n -- value ) }
411     { "alien-signed-1" "alien.accessors" "primitive_alien_signed_1" ( c-ptr n -- value ) }
412     { "alien-signed-2" "alien.accessors" "primitive_alien_signed_2" ( c-ptr n -- value ) }
413     { "alien-signed-4" "alien.accessors" "primitive_alien_signed_4" ( c-ptr n -- value ) }
414     { "alien-signed-8" "alien.accessors" "primitive_alien_signed_8" ( c-ptr n -- value ) }
415     { "alien-signed-cell" "alien.accessors" "primitive_alien_signed_cell" ( c-ptr n -- value ) }
416     { "alien-unsigned-1" "alien.accessors" "primitive_alien_unsigned_1" ( c-ptr n -- value ) }
417     { "alien-unsigned-2" "alien.accessors" "primitive_alien_unsigned_2" ( c-ptr n -- value ) }
418     { "alien-unsigned-4" "alien.accessors" "primitive_alien_unsigned_4" ( c-ptr n -- value ) }
419     { "alien-unsigned-8" "alien.accessors" "primitive_alien_unsigned_8" ( c-ptr n -- value ) }
420     { "alien-unsigned-cell" "alien.accessors" "primitive_alien_unsigned_cell" ( c-ptr n -- value ) }
421     { "set-alien-cell" "alien.accessors" "primitive_set_alien_cell" ( value c-ptr n -- ) }
422     { "set-alien-double" "alien.accessors" "primitive_set_alien_double" ( value c-ptr n -- ) }
423     { "set-alien-float" "alien.accessors" "primitive_set_alien_float" ( value c-ptr n -- ) }
424     { "set-alien-signed-1" "alien.accessors" "primitive_set_alien_signed_1" ( value c-ptr n -- ) }
425     { "set-alien-signed-2" "alien.accessors" "primitive_set_alien_signed_2" ( value c-ptr n -- ) }
426     { "set-alien-signed-4" "alien.accessors" "primitive_set_alien_signed_4" ( value c-ptr n -- ) }
427     { "set-alien-signed-8" "alien.accessors" "primitive_set_alien_signed_8" ( value c-ptr n -- ) }
428     { "set-alien-signed-cell" "alien.accessors" "primitive_set_alien_signed_cell" ( value c-ptr n -- ) }
429     { "set-alien-unsigned-1" "alien.accessors" "primitive_set_alien_unsigned_1" ( value c-ptr n -- ) }
430     { "set-alien-unsigned-2" "alien.accessors" "primitive_set_alien_unsigned_2" ( value c-ptr n -- ) }
431     { "set-alien-unsigned-4" "alien.accessors" "primitive_set_alien_unsigned_4" ( value c-ptr n -- ) }
432     { "set-alien-unsigned-8" "alien.accessors" "primitive_set_alien_unsigned_8" ( value c-ptr n -- ) }
433     { "set-alien-unsigned-cell" "alien.accessors" "primitive_set_alien_unsigned_cell" ( value c-ptr n -- ) }
434     { "(dlopen)" "alien.libraries" "primitive_dlopen" ( path -- dll ) }
435     { "(dlsym)" "alien.libraries" "primitive_dlsym" ( name dll -- alien ) }
436     { "(dlsym-raw)" "alien.libraries" "primitive_dlsym_raw" ( name dll -- alien ) }
437     { "dlclose" "alien.libraries" "primitive_dlclose" ( dll -- ) }
438     { "dll-valid?" "alien.libraries" "primitive_dll_validp" ( dll -- ? ) }
439     { "current-callback" "alien.private" "primitive_current_callback" ( -- n ) }
440     { "<array>" "arrays" "primitive_array" ( n elt -- array ) }
441     { "resize-array" "arrays" "primitive_resize_array" ( n array -- new-array ) }
442     { "(byte-array)" "byte-arrays" "primitive_uninitialized_byte_array" ( n -- byte-array ) }
443     { "<byte-array>" "byte-arrays" "primitive_byte_array" ( n -- byte-array ) }
444     { "resize-byte-array" "byte-arrays" "primitive_resize_byte_array" ( n byte-array -- new-byte-array ) }
445     { "<tuple-boa>" "classes.tuple.private" "primitive_tuple_boa" ( slots... layout -- tuple ) }
446     { "<tuple>" "classes.tuple.private" "primitive_tuple" ( layout -- tuple ) }
447     { "modify-code-heap" "compiler.units" "primitive_modify_code_heap" ( alist update-existing? reset-pics? -- ) }
448     { "lookup-method" "generic.single.private" "primitive_lookup_method" ( object methods -- method ) }
449     { "mega-cache-miss" "generic.single.private" "primitive_mega_cache_miss" ( methods index cache -- method ) }
450     { "(exists?)" "io.files.private" "primitive_existsp" ( path -- ? ) }
451     { "(fopen)" "io.streams.c" "primitive_fopen" ( path mode -- alien ) }
452     { "fclose" "io.streams.c" "primitive_fclose" ( alien -- ) }
453     { "fflush" "io.streams.c" "primitive_fflush" ( alien -- ) }
454     { "fgetc" "io.streams.c" "primitive_fgetc" ( alien -- byte/f ) }
455     { "fputc" "io.streams.c" "primitive_fputc" ( byte alien -- ) }
456     { "fread-unsafe" "io.streams.c" "primitive_fread" ( n buf alien -- count ) }
457     { "free-callback" "alien" "primitive_free_callback" ( alien -- ) }
458     { "fseek" "io.streams.c" "primitive_fseek" ( alien offset whence -- ) }
459     { "ftell" "io.streams.c" "primitive_ftell" ( alien -- n ) }
460     { "fwrite" "io.streams.c" "primitive_fwrite" ( data length alien -- ) }
461     { "(clone)" "kernel" "primitive_clone" ( obj -- newobj ) }
462     { "<wrapper>" "kernel" "primitive_wrapper" ( obj -- wrapper ) }
463
464     { "callstack>array" "kernel" "primitive_callstack_to_array" ( callstack -- array ) }
465     { "die" "kernel" "primitive_die" ( -- ) }
466     { "callstack-for" "kernel.private" "primitive_callstack_for" ( context -- array ) }
467     { "datastack-for" "kernel.private" "primitive_datastack_for" ( context -- array ) }
468     { "retainstack-for" "kernel.private" "primitive_retainstack_for" ( context -- array ) }
469     { "(identity-hashcode)" "kernel.private" "primitive_identity_hashcode" ( obj -- code ) }
470     { "become" "kernel.private" "primitive_become" ( old new -- ) }
471     { "callstack-bounds" "kernel.private" "primitive_callstack_bounds" ( -- start end ) }
472     { "check-datastack" "kernel.private" "primitive_check_datastack" ( array in# out# -- ? ) }
473     { "compute-identity-hashcode" "kernel.private" "primitive_compute_identity_hashcode" ( obj -- ) }
474     { "context-object" "kernel.private" "primitive_context_object" ( n -- obj ) }
475     { "innermost-frame-executing" "kernel.private" "primitive_innermost_stack_frame_executing" ( callstack -- obj ) }
476     { "innermost-frame-scan" "kernel.private" "primitive_innermost_stack_frame_scan" ( callstack -- n ) }
477     { "set-context-object" "kernel.private" "primitive_set_context_object" ( obj n -- ) }
478     { "set-datastack" "kernel.private" "primitive_set_datastack" ( array -- ) }
479     { "set-innermost-frame-quotation" "kernel.private" "primitive_set_innermost_stack_frame_quotation" ( n callstack -- ) }
480     { "set-retainstack" "kernel.private" "primitive_set_retainstack" ( array -- ) }
481     { "set-special-object" "kernel.private" "primitive_set_special_object" ( obj n -- ) }
482     { "special-object" "kernel.private" "primitive_special_object" ( n -- obj ) }
483     { "strip-stack-traces" "kernel.private" "primitive_strip_stack_traces" ( -- ) }
484     { "unimplemented" "kernel.private" "primitive_unimplemented" ( -- * ) }
485     { "load-locals" "locals.backend" "primitive_load_locals" ( ... n -- ) }
486     { "bits>double" "math" "primitive_bits_double" ( n -- x ) }
487     { "bits>float" "math" "primitive_bits_float" ( n -- x ) }
488     { "double>bits" "math" "primitive_double_bits" ( x -- n ) }
489     { "float>bits" "math" "primitive_float_bits" ( x -- n ) }
490     { "(format-float)" "math.parser.private" "primitive_format_float" ( n fill width precision format locale -- byte-array ) }
491     { "bignum*" "math.private" "primitive_bignum_multiply" ( x y -- z ) }
492     { "bignum+" "math.private" "primitive_bignum_add" ( x y -- z ) }
493     { "bignum-" "math.private" "primitive_bignum_subtract" ( x y -- z ) }
494     { "bignum-bit?" "math.private" "primitive_bignum_bitp" ( x n -- ? ) }
495     { "bignum-bitand" "math.private" "primitive_bignum_and" ( x y -- z ) }
496     { "bignum-bitnot" "math.private" "primitive_bignum_not" ( x -- y ) }
497     { "bignum-bitor" "math.private" "primitive_bignum_or" ( x y -- z ) }
498     { "bignum-bitxor" "math.private" "primitive_bignum_xor" ( x y -- z ) }
499     { "bignum-log2" "math.private" "primitive_bignum_log2" ( x -- n ) }
500     { "bignum-mod" "math.private" "primitive_bignum_mod" ( x y -- z ) }
501     { "bignum-gcd" "math.private" "primitive_bignum_gcd" ( x y -- z ) }
502     { "bignum-shift" "math.private" "primitive_bignum_shift" ( x y -- z ) }
503     { "bignum/i" "math.private" "primitive_bignum_divint" ( x y -- z ) }
504     { "bignum/mod" "math.private" "primitive_bignum_divmod" ( x y -- z w ) }
505     { "bignum<" "math.private" "primitive_bignum_less" ( x y -- ? ) }
506     { "bignum<=" "math.private" "primitive_bignum_lesseq" ( x y -- ? ) }
507     { "bignum=" "math.private" "primitive_bignum_eq" ( x y -- ? ) }
508     { "bignum>" "math.private" "primitive_bignum_greater" ( x y -- ? ) }
509     { "bignum>=" "math.private" "primitive_bignum_greatereq" ( x y -- ? ) }
510     { "bignum>fixnum" "math.private" "primitive_bignum_to_fixnum" ( x -- y ) }
511     { "bignum>fixnum-strict" "math.private" "primitive_bignum_to_fixnum_strict" ( x -- y ) }
512     { "fixnum-shift" "math.private" "primitive_fixnum_shift" ( x y -- z ) }
513     { "fixnum/i" "math.private" "primitive_fixnum_divint" ( x y -- z ) }
514     { "fixnum/mod" "math.private" "primitive_fixnum_divmod" ( x y -- z w ) }
515     { "fixnum>bignum" "math.private" "primitive_fixnum_to_bignum" ( x -- y ) }
516     { "fixnum>float" "math.private" "primitive_fixnum_to_float" ( x -- y ) }
517     { "float*" "math.private" "primitive_float_multiply" ( x y -- z ) }
518     { "float+" "math.private" "primitive_float_add" ( x y -- z ) }
519     { "float-" "math.private" "primitive_float_subtract" ( x y -- z ) }
520     { "float-u<" "math.private" "primitive_float_less" ( x y -- ? ) }
521     { "float-u<=" "math.private" "primitive_float_lesseq" ( x y -- ? ) }
522     { "float-u>" "math.private" "primitive_float_greater" ( x y -- ? ) }
523     { "float-u>=" "math.private" "primitive_float_greatereq" ( x y -- ? ) }
524     { "float/f" "math.private" "primitive_float_divfloat" ( x y -- z ) }
525     { "float<" "math.private" "primitive_float_less" ( x y -- ? ) }
526     { "float<=" "math.private" "primitive_float_lesseq" ( x y -- ? ) }
527     { "float=" "math.private" "primitive_float_eq" ( x y -- ? ) }
528     { "float>" "math.private" "primitive_float_greater" ( x y -- ? ) }
529     { "float>=" "math.private" "primitive_float_greatereq" ( x y -- ? ) }
530     { "float>bignum" "math.private" "primitive_float_to_bignum" ( x -- y ) }
531     { "float>fixnum" "math.private" "primitive_float_to_fixnum" ( x -- y ) }
532     { "all-instances" "memory" "primitive_all_instances" ( -- array ) }
533     { "(code-blocks)" "tools.memory.private" "primitive_code_blocks" ( -- array ) }
534     { "(code-room)" "tools.memory.private" "primitive_code_room" ( -- allocator-room ) }
535     { "compact-gc" "memory" "primitive_compact_gc" ( -- ) }
536     { "(callback-room)" "tools.memory.private" "primitive_callback_room" ( -- allocator-room ) }
537     { "(data-room)" "tools.memory.private" "primitive_data_room" ( -- data-room ) }
538     { "disable-gc-events" "tools.memory.private" "primitive_disable_gc_events" ( -- events ) }
539     { "enable-gc-events" "tools.memory.private" "primitive_enable_gc_events" ( -- ) }
540     { "gc" "memory" "primitive_full_gc" ( -- ) }
541     { "minor-gc" "memory" "primitive_minor_gc" ( -- ) }
542     { "size" "memory" "primitive_size" ( obj -- n ) }
543     { "(save-image)" "memory.private" "primitive_save_image" ( path1 path2 then-die? -- ) }
544     { "jit-compile" "quotations" "primitive_jit_compile" ( quot -- ) }
545     { "quotation-code" "quotations" "primitive_quotation_code" ( quot -- start end ) }
546     { "quotation-compiled?" "quotations" "primitive_quotation_compiled_p" ( quot -- ? ) }
547     { "array>quotation" "quotations.private" "primitive_array_to_quotation" ( array -- quot ) }
548     { "set-slot" "slots.private" "primitive_set_slot" ( value obj n -- ) }
549     { "<string>" "strings" "primitive_string" ( n ch -- string ) }
550     { "resize-string" "strings" "primitive_resize_string" ( n str -- newstr ) }
551     { "set-string-nth-fast" "strings.private" "primitive_set_string_nth_fast" ( ch n string -- ) }
552     { "(exit)" "system" "primitive_exit" ( n -- * ) }
553     { "nano-count" "system" "primitive_nano_count" ( -- ns ) }
554     { "(sleep)" "threads.private" "primitive_sleep" ( nanos -- ) }
555     { "context-object-for" "threads.private" "primitive_context_object_for" ( n context -- obj ) }
556     { "dispatch-stats" "tools.dispatch.private" "primitive_dispatch_stats" ( -- stats ) }
557     { "reset-dispatch-stats" "tools.dispatch.private" "primitive_reset_dispatch_stats" ( -- ) }
558     { "word-code" "words" "primitive_word_code" ( word -- start end ) }
559     { "word-optimized?" "words" "primitive_word_optimized_p" ( word -- ? ) }
560     { "(word)" "words.private" "primitive_word" ( name vocab hashcode -- word ) }
561     { "profiling" "tools.profiler.sampling.private" "primitive_sampling_profiler" ( ? -- ) }
562     { "(get-samples)" "tools.profiler.sampling.private" "primitive_get_samples" ( -- samples/f ) }
563     { "(clear-samples)" "tools.profiler.sampling.private" "primitive_clear_samples" ( -- ) }
564 } [ first4 make-primitive ] each
565
566 ! Bump build number
567 "build" "kernel" create-word build 1 + [ ] curry ( -- n ) define-declared
568
569 ] with-compilation-unit