]> gitweb.factorcode.org Git - factor.git/blob - basis/bootstrap/compiler/compiler.factor
5e3827efea2579a0691ac8312c220e0e41442c52
[factor.git] / basis / bootstrap / compiler / compiler.factor
1 ! Copyright (C) 2007, 2009 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 compiler.tree.builder compiler.tree.optimizer
10 compiler.cfg.optimizer ;
11 FROM: compiler => enable-optimizer compile-word ;
12 IN: bootstrap.compiler
13
14 ! Don't bring this in when deploying, since it will store a
15 ! reference to 'eval' in a global variable
16 "deploy-vocab" get "staging" get or [
17     "alien.remote-control" require
18 ] unless
19
20 "prettyprint" vocab [
21     "stack-checker.errors.prettyprint" require
22     "alien.prettyprint" require
23 ] when
24
25 "cpu." cpu name>> append require
26
27 enable-optimizer
28
29 ! Push all tuple layouts to tenured space to improve method caching
30 gc
31
32 : compile-unoptimized ( words -- )
33     [ optimized? not ] filter compile ;
34
35 nl
36 "Compiling..." write flush
37
38 ! Compile a set of words ahead of the full compile.
39 ! This set of words was determined semi-empirically
40 ! using the profiler. It improves bootstrap time
41 ! significantly, because frequenly called words
42 ! which are also quick to compile are replaced by
43 ! compiled definitions as soon as possible.
44 {
45     not
46
47     array? hashtable? vector?
48     tuple? sbuf? tombstone?
49
50     array-nth set-array-nth
51
52     wrap probe
53
54     namestack*
55 } compile-unoptimized
56
57 "." write flush
58
59 {
60     bitand bitor bitxor bitnot
61 } compile-unoptimized
62
63 "." write flush
64
65 {
66     + 1+ 1- 2/ < <= > >= shift
67 } compile-unoptimized
68
69 "." write flush
70
71 {
72     new-sequence nth push pop peek flip
73 } compile-unoptimized
74
75 "." write flush
76
77 {
78     hashcode* = get set
79 } compile-unoptimized
80
81 "." write flush
82
83 {
84     memq? split harvest sift cut cut-slice start index clone
85     set-at reverse push-all class number>string string>number
86 } compile-unoptimized
87
88 "." write flush
89
90 {
91     lines prefix suffix unclip new-assoc update
92     word-prop set-word-prop 1array 2array 3array ?nth
93 } compile-unoptimized
94
95 "." write flush
96
97 {
98     malloc calloc free memcpy
99 } compile-unoptimized
100
101 "." write flush
102
103 { build-tree } compile-unoptimized
104
105 "." write flush
106
107 { optimize-tree } compile-unoptimized
108
109 "." write flush
110
111 { optimize-cfg } compile-unoptimized
112
113 "." write flush
114
115 { compile-word } compile-unoptimized
116
117 "." write flush
118
119 vocabs [ words compile-unoptimized "." write flush ] each
120
121 " done" print flush