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
24 "stack-checker.errors.prettyprint" require
25 "alien.prettyprint" require
26 "alien.debugger" require
29 "cpu." cpu name>> append require
33 ! Push all tuple layouts to tenured space to improve method caching
36 : compile-unoptimized ( words -- )
37 [ [ subwords ] map ] keep suffix concat
38 [ optimized? not ] filter compile ;
40 "debug-compiler" get [
43 "Compiling..." write flush
45 ! Compile a set of words ahead of the full compile.
46 ! This set of words was determined semi-empirically
47 ! using the profiler. It improves bootstrap time
48 ! significantly, because frequenly called words
49 ! which are also quick to compile are replaced by
50 ! compiled definitions as soon as possible.
56 array? hashtable? vector?
57 tuple? sbuf? tombstone?
58 curry? compose? callable?
63 array-nth set-array-nth length>>
75 bitand bitor bitxor bitnot
81 + * 2/ < <= > >= shift
87 new-sequence nth push pop last flip
93 hashcode* = equal? assoc-stack (assoc-stack) get set
99 member-eq? split harvest sift cut cut-slice start index clone
100 set-at reverse push-all class number>string string>number
102 } compile-unoptimized
107 lines prefix suffix unclip new-assoc assoc-union!
108 word-prop set-word-prop 1array 2array 3array ?nth
109 } compile-unoptimized
114 malloc calloc free memcpy
115 } compile-unoptimized
119 vocabs [ words compile-unoptimized "." write flush ] each