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