1 USING: alien.strings assocs io.encodings.ascii kernel kernel.private
2 locals quotations sequences words ;
3 IN: bootstrap.image.primitives
5 CONSTANT: all-primitives {
9 { "<callback>" ( word return-rewind -- alien ) "callback" }
10 { "<displaced-alien>" ( displacement c-ptr -- alien ) "displaced_alien" }
11 { "alien-address" ( c-ptr -- addr ) "alien_address" }
12 { "free-callback" ( alien -- ) "free_callback" }
18 { "current-callback" ( -- n ) "current_callback" }
24 { "alien-cell" ( c-ptr n -- value ) "alien_cell" }
25 { "alien-double" ( c-ptr n -- value ) "alien_double" }
26 { "alien-float" ( c-ptr n -- value ) "alien_float" }
28 { "alien-signed-1" ( c-ptr n -- value ) "alien_signed_1" }
29 { "alien-signed-2" ( c-ptr n -- value ) "alien_signed_2" }
30 { "alien-signed-4" ( c-ptr n -- value ) "alien_signed_4" }
31 { "alien-signed-8" ( c-ptr n -- value ) "alien_signed_8" }
32 { "alien-signed-cell" ( c-ptr n -- value ) "alien_signed_cell" }
34 { "alien-unsigned-1" ( c-ptr n -- value ) "alien_unsigned_1" }
35 { "alien-unsigned-2" ( c-ptr n -- value ) "alien_unsigned_2" }
36 { "alien-unsigned-4" ( c-ptr n -- value ) "alien_unsigned_4" }
37 { "alien-unsigned-8" ( c-ptr n -- value ) "alien_unsigned_8" }
38 { "alien-unsigned-cell" ( c-ptr n -- value ) "alien_unsigned_cell" }
40 { "set-alien-cell" ( value c-ptr n -- ) "set_alien_cell" }
41 { "set-alien-double" ( value c-ptr n -- ) "set_alien_double" }
42 { "set-alien-float" ( value c-ptr n -- ) "set_alien_float" }
44 { "set-alien-signed-1" ( value c-ptr n -- ) "set_alien_signed_1" }
45 { "set-alien-signed-2" ( value c-ptr n -- ) "set_alien_signed_2" }
46 { "set-alien-signed-4" ( value c-ptr n -- ) "set_alien_signed_4" }
47 { "set-alien-signed-8" ( value c-ptr n -- ) "set_alien_signed_8" }
48 { "set-alien-signed-cell" ( value c-ptr n -- ) "set_alien_signed_cell" }
50 { "set-alien-unsigned-1" ( value c-ptr n -- ) "set_alien_unsigned_1" }
51 { "set-alien-unsigned-2" ( value c-ptr n -- ) "set_alien_unsigned_2" }
52 { "set-alien-unsigned-4" ( value c-ptr n -- ) "set_alien_unsigned_4" }
53 { "set-alien-unsigned-8" ( value c-ptr n -- ) "set_alien_unsigned_8" }
54 { "set-alien-unsigned-cell" ( value c-ptr n -- ) "set_alien_unsigned_cell" }
60 { "(dlopen)" ( path -- dll ) "dlopen" }
61 { "(dlsym)" ( name dll -- alien ) "dlsym" }
62 { "(dlsym-raw)" ( name dll -- alien ) "dlsym_raw" }
63 { "dlclose" ( dll -- ) "dlclose" }
64 { "dll-valid?" ( dll -- ? ) "dll_validp" }
70 { "<array>" ( n elt -- array ) "array" }
71 { "resize-array" ( n array -- new-array ) "resize_array" }
77 { "(byte-array)" ( n -- byte-array ) "uninitialized_byte_array" }
78 { "<byte-array>" ( n -- byte-array ) "byte_array" }
80 "resize-byte-array" ( n byte-array -- new-byte-array )
86 "classes.tuple.private"
88 { "<tuple-boa>" ( slots... layout -- tuple ) "tuple_boa" }
89 { "<tuple>" ( layout -- tuple ) "tuple" }
96 "modify-code-heap" ( alist update-existing? reset-pics? -- )
102 "generic.single.private"
104 { "inline-cache-miss" ( generic methods index cache -- ) f }
105 { "inline-cache-miss-tail" ( generic methods index cache -- ) f }
106 { "lookup-method" ( object methods -- method ) "lookup_method" }
107 { "mega-cache-lookup" ( methods index cache -- ) f }
108 { "mega-cache-miss" ( methods index cache -- method ) "mega_cache_miss" }
114 { "(exists?)" ( path -- ? ) "existsp" }
120 { "(fopen)" ( path mode -- alien ) "fopen" }
121 { "fclose" ( alien -- ) "fclose" }
122 { "fflush" ( alien -- ) "fflush" }
123 { "fgetc" ( alien -- byte/f ) "fgetc" }
124 { "fputc" ( byte alien -- ) "fputc" }
125 { "fread-unsafe" ( n buf alien -- count ) "fread" }
126 { "fseek" ( alien offset whence -- ) "fseek" }
127 { "ftell" ( alien -- n ) "ftell" }
128 { "fwrite" ( data length alien -- ) "fwrite" }
134 { "(clone)" ( obj -- newobj ) "clone" }
135 { "<wrapper>" ( obj -- wrapper ) "wrapper" }
136 { "callstack>array" ( callstack -- array ) "callstack_to_array" }
137 { "die" ( -- ) "die" }
138 { "drop" ( x -- ) f }
139 { "2drop" ( x y -- ) f }
140 { "3drop" ( x y z -- ) f }
141 { "4drop" ( w x y z -- ) f }
142 { "dup" ( x -- x x ) f }
143 { "2dup" ( x y -- x y x y ) f }
144 { "3dup" ( x y z -- x y z x y z ) f }
145 { "4dup" ( w x y z -- w x y z w x y z ) f }
146 { "rot" ( x y z -- y z x ) f }
147 { "-rot" ( x y z -- z x y ) f }
148 { "dupd" ( x y -- x x y ) f }
149 { "swapd" ( x y z -- y x z ) f }
150 { "nip" ( x y -- y ) f }
151 { "2nip" ( x y z -- z ) f }
152 { "over" ( x y -- x y x ) f }
153 { "pick" ( x y z -- x y z x ) f }
154 { "swap" ( x y -- y x ) f }
155 { "eq?" ( obj1 obj2 -- ? ) f }
161 { "(call)" ( quot -- ) f }
162 { "(execute)" ( word -- ) f }
163 { "c-to-factor" ( -- ) f }
164 { "fpu-state" ( -- ) f }
165 { "lazy-jit-compile" ( -- ) f }
166 { "leaf-signal-handler" ( -- ) f }
167 { "set-callstack" ( callstack -- * ) f }
168 { "set-fpu-state" ( -- ) f }
169 { "signal-handler" ( -- ) f }
170 { "tag" ( object -- n ) f }
171 { "unwind-native-frames" ( -- ) f }
173 { "callstack-for" ( context -- array ) "callstack_for" }
174 { "datastack-for" ( context -- array ) "datastack_for" }
175 { "retainstack-for" ( context -- array ) "retainstack_for" }
176 { "(identity-hashcode)" ( obj -- code ) "identity_hashcode" }
177 { "become" ( old new -- ) "become" }
178 { "callstack-bounds" ( -- start end ) "callstack_bounds" }
179 { "check-datastack" ( array in# out# -- ? ) "check_datastack" }
180 { "compute-identity-hashcode" ( obj -- ) "compute_identity_hashcode" }
181 { "context-object" ( n -- obj ) "context_object" }
183 "innermost-frame-executing" ( callstack -- obj )
184 "innermost_stack_frame_executing"
187 "innermost-frame-scan" ( callstack -- n )
188 "innermost_stack_frame_scan"
190 { "set-context-object" ( obj n -- ) "set_context_object" }
191 { "set-datastack" ( array -- ) "set_datastack" }
193 "set-innermost-frame-quotation" ( n callstack -- )
194 "set_innermost_stack_frame_quotation"
196 { "set-retainstack" ( array -- ) "set_retainstack" }
197 { "set-special-object" ( obj n -- ) "set_special_object" }
198 { "special-object" ( n -- obj ) "special_object" }
199 { "strip-stack-traces" ( -- ) "strip_stack_traces" }
200 { "unimplemented" ( -- * ) "unimplemented" }
206 { "drop-locals" ( n -- ) f }
207 { "get-local" ( n -- obj ) f }
208 { "load-local" ( obj -- ) f }
209 { "load-locals" ( ... n -- ) "load_locals" }
215 { "bits>double" ( n -- x ) "bits_double" }
216 { "bits>float" ( n -- x ) "bits_float" }
217 { "double>bits" ( x -- n ) "double_bits" }
218 { "float>bits" ( x -- n ) "float_bits" }
222 "math.parser.private"
225 "(format-float)" ( n fill width precision format locale -- byte-array )
233 { "both-fixnums?" ( x y -- ? ) f }
234 { "fixnum+fast" ( x y -- z ) f }
235 { "fixnum-fast" ( x y -- z ) f }
236 { "fixnum*fast" ( x y -- z ) f }
237 { "fixnum-bitand" ( x y -- z ) f }
238 { "fixnum-bitor" ( x y -- z ) f }
239 { "fixnum-bitxor" ( x y -- z ) f }
240 { "fixnum-bitnot" ( x -- y ) f }
241 { "fixnum-mod" ( x y -- z ) f }
242 { "fixnum-shift-fast" ( x y -- z ) f }
243 { "fixnum/i-fast" ( x y -- z ) f }
244 { "fixnum/mod-fast" ( x y -- z w ) f }
245 { "fixnum+" ( x y -- z ) f }
246 { "fixnum-" ( x y -- z ) f }
247 { "fixnum*" ( x y -- z ) f }
248 { "fixnum<" ( x y -- ? ) f }
249 { "fixnum<=" ( x y -- z ) f }
250 { "fixnum>" ( x y -- ? ) f }
251 { "fixnum>=" ( x y -- ? ) f }
253 { "bignum*" ( x y -- z ) "bignum_multiply" }
254 { "bignum+" ( x y -- z ) "bignum_add" }
255 { "bignum-" ( x y -- z ) "bignum_subtract" }
256 { "bignum-bit?" ( x n -- ? ) "bignum_bitp" }
257 { "bignum-bitand" ( x y -- z ) "bignum_and" }
258 { "bignum-bitnot" ( x -- y ) "bignum_not" }
259 { "bignum-bitor" ( x y -- z ) "bignum_or" }
260 { "bignum-bitxor" ( x y -- z ) "bignum_xor" }
261 { "bignum-log2" ( x -- n ) "bignum_log2" }
262 { "bignum-mod" ( x y -- z ) "bignum_mod" }
263 { "bignum-gcd" ( x y -- z ) "bignum_gcd" }
264 { "bignum-shift" ( x y -- z ) "bignum_shift" }
265 { "bignum/i" ( x y -- z ) "bignum_divint" }
266 { "bignum/mod" ( x y -- z w ) "bignum_divmod" }
267 { "bignum<" ( x y -- ? ) "bignum_less" }
268 { "bignum<=" ( x y -- ? ) "bignum_lesseq" }
269 { "bignum=" ( x y -- ? ) "bignum_eq" }
270 { "bignum>" ( x y -- ? ) "bignum_greater" }
271 { "bignum>=" ( x y -- ? ) "bignum_greatereq" }
272 { "bignum>fixnum" ( x -- y ) "bignum_to_fixnum" }
273 { "bignum>fixnum-strict" ( x -- y ) "bignum_to_fixnum_strict" }
274 { "fixnum-shift" ( x y -- z ) "fixnum_shift" }
275 { "fixnum/i" ( x y -- z ) "fixnum_divint" }
276 { "fixnum/mod" ( x y -- z w ) "fixnum_divmod" }
277 { "fixnum>bignum" ( x -- y ) "fixnum_to_bignum" }
278 { "fixnum>float" ( x -- y ) "fixnum_to_float" }
279 { "float*" ( x y -- z ) "float_multiply" }
280 { "float+" ( x y -- z ) "float_add" }
281 { "float-" ( x y -- z ) "float_subtract" }
282 { "float-u<" ( x y -- ? ) "float_less" }
283 { "float-u<=" ( x y -- ? ) "float_lesseq" }
284 { "float-u>" ( x y -- ? ) "float_greater" }
285 { "float-u>=" ( x y -- ? ) "float_greatereq" }
286 { "float/f" ( x y -- z ) "float_divfloat" }
287 { "float<" ( x y -- ? ) "float_less" }
288 { "float<=" ( x y -- ? ) "float_lesseq" }
289 { "float=" ( x y -- ? ) "float_eq" }
290 { "float>" ( x y -- ? ) "float_greater" }
291 { "float>=" ( x y -- ? ) "float_greatereq" }
292 { "float>bignum" ( x -- y ) "float_to_bignum" }
293 { "float>fixnum" ( x -- y ) "float_to_fixnum" }
299 { "all-instances" ( -- array ) "all_instances" }
300 { "compact-gc" ( -- ) "compact_gc" }
301 { "gc" ( -- ) "full_gc" }
302 { "minor-gc" ( -- ) "minor_gc" }
303 { "size" ( obj -- n ) "size" }
309 { "(save-image)" ( path1 path2 then-die? -- ) "save_image" }
315 { "jit-compile" ( quot -- ) "jit_compile" }
316 { "quotation-code" ( quot -- start end ) "quotation_code" }
317 { "quotation-compiled?" ( quot -- ? ) "quotation_compiled_p" }
323 { "array>quotation" ( array -- quot ) "array_to_quotation" }
329 { "set-slot" ( value obj n -- ) "set_slot" }
330 { "slot" ( obj m -- value ) f }
336 { "<string>" ( n ch -- string ) "string" }
337 { "resize-string" ( n str -- newstr ) "resize_string" }
343 { "set-string-nth-fast" ( ch n string -- ) "set_string_nth_fast" }
344 { "string-nth-fast" ( n string -- ch ) f }
350 { "(exit)" ( n -- * ) "exit" }
351 { "nano-count" ( -- ns ) "nano_count" }
357 { "(sleep)" ( nanos -- ) "sleep" }
358 { "(set-context)" ( obj context -- obj' ) f }
359 { "(set-context-and-delete)" ( obj context -- * ) f }
360 { "(start-context)" ( obj quot -- obj' ) f }
361 { "(start-context-and-delete)" ( obj quot -- * ) f }
362 { "context-object-for" ( n context -- obj ) "context_object_for" }
366 "tools.dispatch.private"
368 { "dispatch-stats" ( -- stats ) "dispatch_stats" }
369 { "reset-dispatch-stats" ( -- ) "reset_dispatch_stats" }
373 "tools.memory.private"
375 { "(callback-room)" ( -- allocator-room ) "callback_room" }
376 { "(code-blocks)" ( -- array ) "code_blocks" }
377 { "(code-room)" ( -- allocator-room ) "code_room" }
378 { "(data-room)" ( -- data-room ) "data_room" }
379 { "disable-gc-events" ( -- events ) "disable_gc_events" }
380 { "enable-gc-events" ( -- ) "enable_gc_events" }
384 "tools.profiler.sampling.private"
386 { "profiling" ( ? -- ) "sampling_profiler" }
387 { "(get-samples)" ( -- samples/f ) "get_samples" }
388 { "(clear-samples)" ( -- ) "clear_samples" }
394 { "word-code" ( word -- start end ) "word_code" }
395 { "word-optimized?" ( word -- ? ) "word_optimized_p" }
401 { "(word)" ( name vocab hashcode -- word ) "word" }
406 : primitive-quot ( word vm-func -- quot )
408 nip "primitive_" prepend ascii string>alien [ do-primitive ] curry
409 ] [ 1quotation ] if* ;
411 : primitive-word ( name vocab -- word )
412 create-word dup t "primitive" set-word-prop ;
414 :: create-primitive ( vocab word effect vm-func -- )
415 word vocab primitive-word
416 dup vm-func primitive-quot effect define-declared ;
418 : create-primitives ( assoc -- )
419 [ [ first3 create-primitive ] with each ] assoc-each ;