]> gitweb.factorcode.org Git - factor.git/blob - basis/bootstrap/compiler/compiler.factor
use reject instead of [ ... not ] filter.
[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 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 io
8 io.encodings.string libc splitting math.parser memory compiler.units
9 math.order quotations quotations.private assocs.private vocabs.loader ;
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 { "boostrap.compiler" "prettyprint" } "alien.prettyprint" require-when
24 { "boostrap.compiler" "debugger" } "alien.debugger" require-when
25
26 "cpu." cpu name>> append require
27
28 enable-optimizer
29
30 ! Push all tuple layouts to tenured space to improve method caching
31 gc
32
33 : compile-unoptimized ( words -- )
34     [ [ subwords ] map ] keep suffix concat
35     [ optimized? ] reject compile ;
36
37 "debug-compiler" get [
38
39     nl
40     "Compiling..." write flush
41
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 frequently called words
46     ! which are also quick to compile are replaced by
47     ! compiled definitions as soon as possible.
48     {
49         not ?
50
51         2over
52
53         array? hashtable? vector?
54         tuple? sbuf? tombstone?
55         curry? compose? callable?
56         quotation?
57
58         curry compose uncurry
59
60         array-nth set-array-nth
61
62         wrap probe
63
64         namestack*
65
66         layout-of
67     } compile-unoptimized
68
69     "." write flush
70
71     {
72         bitand bitor bitxor bitnot
73     } compile-unoptimized
74
75     "." write flush
76
77     {
78         + * 2/ < <= > >= shift
79     } compile-unoptimized
80
81     "." write flush
82
83     {
84         new-sequence nth push pop last flip
85     } compile-unoptimized
86
87     "." write flush
88
89     {
90         hashcode* = equal? assoc-stack (assoc-stack) get set
91     } compile-unoptimized
92
93     "." write flush
94
95     {
96         member-eq? split harvest sift cut cut-slice start index clone
97         set-at reverse push-all class-of number>string string>number
98         like clone-like
99     } compile-unoptimized
100
101     "." write flush
102
103     {
104         lines prefix suffix unclip new-assoc assoc-union!
105         word-prop set-word-prop 1array 2array 3array ?nth
106     } compile-unoptimized
107
108     "." write flush
109
110     os windows? [
111         "GetLastError" "windows.kernel32" lookup-word
112         "FormatMessageW" "windows.kernel32" lookup-word
113         2array compile-unoptimized
114     ] when
115
116     os unix? [
117         "(dlerror)" "alien.libraries.unix" lookup-word
118         1array compile-unoptimized
119     ] when
120
121     {
122         malloc calloc free memcpy
123     } compile-unoptimized
124
125     "." write flush
126
127     vocabs [ words compile-unoptimized "." write flush ] each
128
129     " done" print flush
130
131     "alien.syntax" require
132     "io.streams.byte-array.fast" require
133
134 ] unless