]> gitweb.factorcode.org Git - factor.git/blob - basis/bootstrap/compiler/compiler.factor
Factor source files should not be executable
[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 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 ] when
27
28 "cpu." cpu name>> append require
29
30 enable-optimizer
31
32 ! Push all tuple layouts to tenured space to improve method caching
33 gc
34
35 : compile-unoptimized ( words -- )
36     [ optimized? not ] filter compile ;
37
38 "debug-compiler" get [
39     
40     nl
41     "Compiling..." write flush
42
43     ! Compile a set of words ahead of the full compile.
44     ! This set of words was determined semi-empirically
45     ! using the profiler. It improves bootstrap time
46     ! significantly, because frequenly called words
47     ! which are also quick to compile are replaced by
48     ! compiled definitions as soon as possible.
49     {
50         not ?
51
52         2over
53
54         array? hashtable? vector?
55         tuple? sbuf? tombstone?
56         curry? compose? callable?
57         quotation?
58
59         curry compose uncurry
60
61         array-nth set-array-nth length>>
62
63         wrap probe
64
65         namestack*
66
67         layout-of
68     } compile-unoptimized
69
70     "." write flush
71
72     {
73         bitand bitor bitxor bitnot
74     } compile-unoptimized
75
76     "." write flush
77
78     {
79         + 2/ < <= > >= shift
80     } compile-unoptimized
81
82     "." write flush
83
84     {
85         new-sequence nth push pop last flip
86     } compile-unoptimized
87
88     "." write flush
89
90     {
91         hashcode* = equal? assoc-stack (assoc-stack) get set
92     } compile-unoptimized
93
94     "." write flush
95
96     {
97         member-eq? split harvest sift cut cut-slice start index clone
98         set-at reverse push-all class number>string string>number
99         like clone-like
100     } compile-unoptimized
101
102     "." write flush
103
104     {
105         lines prefix suffix unclip new-assoc update
106         word-prop set-word-prop 1array 2array 3array ?nth
107     } compile-unoptimized
108
109     "." write flush
110
111     {
112         malloc calloc free memcpy
113     } compile-unoptimized
114
115     "." write flush
116
117     vocabs [ words compile-unoptimized "." write flush ] each
118
119     " done" print flush
120
121 ] unless