1 ! Copyright (C) 2007, 2010 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors cpu.architecture vocabs.loader system
4 sequences namespaces parser kernel kernel.private classes
5 classes.private arrays hashtables vectors classes.tuple sbufs
6 hashtables.private sequences.private math classes.tuple.private
7 growable namespaces.private assocs words command-line vocabs io
8 io.encodings.string libc splitting math.parser memory compiler.units
9 math.order quotations quotations.private assocs.private ;
10 FROM: compiler => enable-optimizer ;
11 IN: bootstrap.compiler
13 "profile-compiler" get [
14 "bootstrap.compiler.timing" require
17 ! Don't bring this in when deploying, since it will store a
18 ! reference to 'eval' in a global variable
19 "deploy-vocab" get "staging" get or [
20 "alien.remote-control" require
23 { "boostrap.compiler" "prettyprint" } "alien.prettyprint" require-when
24 { "boostrap.compiler" "debugger" } "alien.debugger" require-when
26 "cpu." cpu name>> append require
30 ! Push all tuple layouts to tenured space to improve method caching
33 : compile-unoptimized ( words -- )
34 [ [ subwords ] map ] keep suffix concat
35 [ optimized? not ] filter compile ;
37 "debug-compiler" get [
40 "Compiling..." write flush
42 ! Compile a set of words ahead of the full compile.
43 ! This set of words was determined semi-empirically
44 ! using the profiler. It improves bootstrap time
45 ! significantly, because frequenly called words
46 ! which are also quick to compile are replaced by
47 ! compiled definitions as soon as possible.
53 array? hashtable? vector?
54 tuple? sbuf? tombstone?
55 curry? compose? callable?
60 array-nth set-array-nth length>>
72 bitand bitor bitxor bitnot
78 + * 2/ < <= > >= shift
84 new-sequence nth push pop last flip
90 hashcode* = equal? assoc-stack (assoc-stack) get set
96 member-eq? split harvest sift cut cut-slice start index clone
97 set-at reverse push-all class number>string string>number
104 lines prefix suffix unclip new-assoc assoc-union!
105 word-prop set-word-prop 1array 2array 3array ?nth
106 } compile-unoptimized
111 malloc calloc free memcpy
112 } compile-unoptimized
116 vocabs [ words compile-unoptimized "." write flush ] each