factor/basis/bootstrap/compiler/compiler.factor

135 lines
3.2 KiB
Factor
Raw Normal View History

! Copyright (C) 2007, 2010 Slava Pestov.
2008-01-01 14:54:14 -05:00
! See http://factorcode.org/license.txt for BSD license.
USING: accessors cpu.architecture vocabs 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 io
io.encodings.string libc splitting math.parser memory compiler.units
math.order quotations quotations.private assocs.private vocabs.loader ;
FROM: compiler => enable-optimizer ;
2007-12-24 21:54:45 -05:00
IN: bootstrap.compiler
2007-09-20 18:09:08 -04:00
"profile-compiler" get [
"bootstrap.compiler.timing" require
] when
! 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
{ "boostrap.compiler" "prettyprint" } "alien.prettyprint" require-when
{ "boostrap.compiler" "debugger" } "alien.debugger" require-when
2008-12-08 15:58:00 -05:00
"cpu." cpu name>> append require
2007-09-20 18:09:08 -04:00
enable-optimizer
2009-04-25 21:33:52 -04:00
! Push all tuple layouts to tenured space to improve method caching
gc
: compile-unoptimized ( words -- )
[ [ subwords ] map ] keep suffix concat
[ optimized? not ] filter compile ;
2008-04-28 22:26:31 -04:00
"debug-compiler" get [
nl
"Compiling..." write flush
! 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.
{
not ?
2over
2007-09-20 18:09:08 -04:00
array? hashtable? vector?
tuple? sbuf? tombstone?
curry? compose? callable?
quotation?
curry compose uncurry
2007-09-20 18:09:08 -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
namestack*
layout-of
} 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
{
+ * 2/ < <= > >= shift
} compile-unoptimized
2007-09-20 18:09:08 -04:00
"." write flush
{
new-sequence nth push pop last flip
} compile-unoptimized
"." write flush
{
hashcode* = equal? assoc-stack (assoc-stack) get set
} compile-unoptimized
2007-09-20 18:09:08 -04:00
"." write flush
2008-01-01 14:54:14 -05:00
{
member-eq? split harvest sift cut cut-slice start index clone
2011-10-24 07:47:42 -04:00
set-at reverse push-all class-of number>string string>number
like clone-like
} compile-unoptimized
"." write flush
{
lines prefix suffix unclip new-assoc assoc-union!
word-prop set-word-prop 1array 2array 3array ?nth
} compile-unoptimized
2008-08-22 04:12:15 -04:00
"." write flush
2008-08-22 04:12:15 -04:00
os windows? [
2011-11-06 18:57:24 -05:00
"GetLastError" "windows.kernel32" lookup-word
"FormatMessageW" "windows.kernel32" lookup-word
2array compile-unoptimized
] when
os unix? [
2011-11-06 18:57:24 -05:00
"(dlerror)" "alien.libraries.unix" lookup-word
1array compile-unoptimized
] when
{
malloc calloc free memcpy
} compile-unoptimized
"." write flush
2008-11-06 02:11:28 -05:00
vocabs [ words compile-unoptimized "." write flush ] each
2008-04-05 08:35:36 -04:00
" done" print flush
"alien.syntax" require
"io.streams.byte-array.fast" require
] unless