factor/basis/bootstrap/compiler/compiler.factor

118 lines
2.4 KiB
Factor
Raw Normal View History

! Copyright (C) 2007, 2009 Slava Pestov.
2008-01-01 14:54:14 -05:00
! See http://factorcode.org/license.txt for BSD license.
USING: accessors compiler cpu.architecture vocabs.loader system
sequences namespaces parser kernel kernel.private classes
classes.private arrays hashtables vectors classes.tuple sbufs
2008-08-12 04:31:48 -04:00
hashtables.private sequences.private math classes.tuple.private
growable namespaces.private assocs words command-line vocabs io
2008-12-08 15:58:00 -05:00
io.encodings.string libc splitting math.parser
2008-08-22 04:12:15 -04:00
compiler.units math.order compiler.tree.builder
2008-10-23 03:49:55 -04:00
compiler.tree.optimizer compiler.cfg.optimizer ;
2007-12-24 21:54:45 -05:00
IN: bootstrap.compiler
2007-09-20 18:09:08 -04:00
! Don't bring this in when deploying, since it will store a
! reference to 'eval' in a global variable
2008-12-08 15:58:00 -05:00
"deploy-vocab" get "staging" get or [
"alien.remote-control" require
] unless
2007-09-20 18:09:08 -04:00
2008-12-08 15:58:00 -05:00
"prettyprint" vocab [
"stack-checker.errors.prettyprint" require
"alien.prettyprint" require
] when
"cpu." cpu name>> append require
2007-09-20 18:09:08 -04:00
enable-compiler
: compile-unoptimized ( words -- )
[ optimized>> not ] filter compile ;
2008-04-28 22:26:31 -04:00
nl
2008-04-05 08:35:36 -04:00
"Compiling..." write flush
2007-12-26 20:21:46 -05:00
! Compile a set of words ahead of the full compile.
! This set of words was determined semi-empirically
! using the profiler. It improves bootstrap time
! significantly, because frequenly called words
! which are also quick to compile are replaced by
! compiled definitions as soon as possible.
{
roll -roll declare not
2007-09-20 18:09:08 -04:00
2008-03-26 04:57:48 -04:00
array? hashtable? vector?
2008-08-12 04:38:56 -04:00
tuple? sbuf? tombstone?
2007-09-20 18:09:08 -04:00
2008-07-16 17:48:09 -04:00
array-nth set-array-nth
2007-09-20 18:09:08 -04:00
wrap probe
2007-09-20 18:09:08 -04:00
2008-06-09 06:39:55 -04:00
namestack*
} compile-unoptimized
"." write flush
2007-09-20 18:09:08 -04:00
{
bitand bitor bitxor bitnot
} compile-unoptimized
2007-09-20 18:09:08 -04:00
"." write flush
2007-12-16 15:17:28 -05:00
{
2008-04-28 22:26:31 -04:00
+ 1+ 1- 2/ < <= > >= shift
} compile-unoptimized
2007-09-20 18:09:08 -04:00
"." write flush
{
new-sequence nth push pop peek flip
} compile-unoptimized
"." write flush
{
hashcode* = get set
} compile-unoptimized
2007-09-20 18:09:08 -04:00
2008-01-01 14:54:14 -05:00
"." write flush
{
2008-08-22 04:12:15 -04:00
memq? split harvest sift cut cut-slice start index clone
set-at reverse push-all class number>string string>number
} compile-unoptimized
"." write flush
{
2008-08-22 04:12:15 -04:00
lines prefix suffix unclip new-assoc update
word-prop set-word-prop 1array 2array 3array ?nth
} compile-unoptimized
2008-08-22 04:12:15 -04:00
"." write flush
{
2008-12-08 15:58:00 -05:00
malloc calloc free memcpy
} compile-unoptimized
2007-09-20 18:09:08 -04:00
2008-11-06 02:11:28 -05:00
"." write flush
{ build-tree } compile-unoptimized
2008-08-18 16:47:49 -04:00
2008-11-06 02:11:28 -05:00
"." write flush
{ optimize-tree } compile-unoptimized
2008-08-12 04:31:48 -04:00
2008-11-06 02:11:28 -05:00
"." write flush
{ optimize-cfg } compile-unoptimized
2008-10-23 03:49:55 -04:00
2008-11-06 02:11:28 -05:00
"." write flush
{ (compile) } compile-unoptimized
2008-10-23 03:49:55 -04:00
2008-11-06 02:11:28 -05:00
"." write flush
vocabs [ words compile-unoptimized "." write flush ] each
2008-04-05 08:35:36 -04:00
2008-01-01 14:54:14 -05:00
" done" print flush