]> gitweb.factorcode.org Git - factor.git/blob - basis/bootstrap/compiler/compiler.factor
0bdb2494f88957bfa5031cef2bf4d8351c0ec6ec
[factor.git] / basis / bootstrap / compiler / compiler.factor
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
12
13 "profile-compiler" get [
14     "bootstrap.compiler.timing" require
15 ] when
16
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
21 ] unless
22
23 "prettyprint" vocab [
24     "stack-checker.errors.prettyprint" require
25     "alien.prettyprint" require
26     "alien.debugger" require
27 ] when
28
29 "cpu." cpu name>> append require
30
31 enable-optimizer
32
33 ! Push all tuple layouts to tenured space to improve method caching
34 gc
35
36 : compile-unoptimized ( words -- )
37     [ [ subwords ] map ] keep suffix concat
38     [ optimized? not ] filter compile ;
39
40 "debug-compiler" get [
41     
42     nl
43     "Compiling..." write flush
44
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.
51     {
52         not ?
53
54         2over
55
56         array? hashtable? vector?
57         tuple? sbuf? tombstone?
58         curry? compose? callable?
59         quotation?
60
61         curry compose uncurry
62
63         array-nth set-array-nth length>>
64
65         wrap probe
66
67         namestack*
68
69         layout-of
70     } compile-unoptimized
71
72     "." write flush
73
74     {
75         bitand bitor bitxor bitnot
76     } compile-unoptimized
77
78     "." write flush
79
80     {
81         + * 2/ < <= > >= shift
82     } compile-unoptimized
83
84     "." write flush
85
86     {
87         new-sequence nth push pop last flip
88     } compile-unoptimized
89
90     "." write flush
91
92     {
93         hashcode* = equal? assoc-stack (assoc-stack) get set
94     } compile-unoptimized
95
96     "." write flush
97
98     {
99         member-eq? split harvest sift cut cut-slice start index clone
100         set-at reverse push-all class number>string string>number
101         like clone-like
102     } compile-unoptimized
103
104     "." write flush
105
106     {
107         lines prefix suffix unclip new-assoc assoc-union!
108         word-prop set-word-prop 1array 2array 3array ?nth
109     } compile-unoptimized
110
111     "." write flush
112
113     {
114         malloc calloc free memcpy
115     } compile-unoptimized
116
117     "." write flush
118
119     vocabs [ words compile-unoptimized "." write flush ] each
120
121     " done" print flush
122
123 ] unless