]> gitweb.factorcode.org Git - factor.git/commitdiff
compile all by default
authorSlava Pestov <slava@factorcode.org>
Sat, 9 Oct 2004 19:14:49 +0000 (19:14 +0000)
committerSlava Pestov <slava@factorcode.org>
Sat, 9 Oct 2004 19:14:49 +0000 (19:14 +0000)
Makefile
TODO.FACTOR.txt
library/compiler/compile-all.factor
library/compiler/compiler.factor
library/compiler/dummy-compiler.factor [new file with mode: 0644]
library/platform/native/boot-stage2.factor
library/platform/native/init-stage2.factor
library/platform/native/kernel.factor
native/factor.c
native/run.h

index 54450585aedb2dcc27ae95e41e95d6f6ceb42921..249cb0ef0a603699b81016283a800bea7194f451 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,11 +1,11 @@
-CC = gcc
+CC = gcc34
 
 # On FreeBSD, to use SDL and other libc_r libs:
-CFLAGS = -g -Wall -export-dynamic -pthread
+CFLAGS = -g -Wall -export-dynamic -pthread
 # On PowerPC G5:
 # CFLAGS = -mcpu=970 -mtune=970 -mpowerpc64 -ffast-math -O3
 # On Pentium 4:
-CFLAGS = -march=pentium4 -ffast-math -Os -fomit-frame-pointer -export-dynamic -pthread
+CFLAGS = -march=pentium4 -ffast-math -Os -fomit-frame-pointer -export-dynamic -pthread
 # Add -fomit-frame-pointer if you don't care about debugging
 # CFLAGS = -Os -g -Wall
 
index 2b8a806a7d3eff5f0b2be9748e8be88327abea83..4602784ef3bf596ce410ef0e7f6f079c64162f71 100644 (file)
@@ -4,12 +4,14 @@ FFI:
 - BIN: 2: bad\r
 \r
 - compile word twice; no more 'cannot compile' error!\r
-\r
-- compiled? messy\r
+- doc comments in assoc, image, inferior\r
+- styles - could use some cleanup\r
+- list - trim down\r
+- move quadratic and simpson to contrib\r
+- init-assembler called twice\r
 - compiler: drop literal peephole optimization\r
 - compiling when*\r
 - compiling unless*\r
-- eliminate uses of 2dip\r
 - getenv/setenv: if literal arg, compile as a load/store\r
 - inline words\r
 \r
index 32214150a96b928651e006ff3c91b01e18859374..b5841e5c55e4f9b6a13d9569932a8c263eb3276f 100644 (file)
 
 IN: compiler
 USE: combinators
+USE: errors
 USE: lists
 USE: logic
+USE: namespaces
+USE: prettyprint
 USE: stack
+USE: stdio
 USE: vectors
 USE: words
 
@@ -99,6 +103,14 @@ DEFER: can-compile-vector?
         "can-compile" set-word-property
     ] ifte ;
 
+SYMBOL: compilable-word-list
+
 : compilable-words ( -- list )
     #! Make a list of all words that can be compiled.
     [, [ dup can-compile? [ , ] [ drop ] ifte ] each-word ,] ;
+
+: init-compiler ( -- )
+    #! Compile all words.
+    compilable-word-list get [
+        [ compile ] [ [ "Cannot compile " write . ] when ] catch
+    ] each ;
index bc06bb4e8d2e7ba5074c9db27bb1c9ee2b3a3a84..c8332533b94b44b7edfa2f72beefed2f5f8d91f9 100644 (file)
@@ -211,7 +211,6 @@ SYMBOL: compile-callstack
 
 : (compile) ( word -- )
     #! Should be called inside the with-compiler scope.
-    dup . flush
     intern dup save-xt word-parameter compile-quot RET ;
 
 : compile-postponed ( -- )
diff --git a/library/compiler/dummy-compiler.factor b/library/compiler/dummy-compiler.factor
new file mode 100644 (file)
index 0000000..80a379f
--- /dev/null
@@ -0,0 +1,5 @@
+! Loaded on non-x86 platforms.
+
+SYMBOL: compilable-word-list
+: compilable-words f ;
+: init-compiler ;
index 3478fa658f5762ee084cc103db9e82e2d9c59671..d61d9a4b7a2ffcd53d1ce86e15395e3586ca2fe8 100644 (file)
 
 IN: init
 USE: combinators
+USE: compiler
 USE: errors
 USE: kernel
 USE: lists
+USE: namespaces
 USE: parser
 USE: stack
 USE: strings
@@ -135,35 +137,47 @@ USE: stdio
     "/library/jedit/jedit-remote.factor"
     "/library/jedit/jedit.factor"
 
-    "/library/compiler/assembler.factor"
-    "/library/compiler/assembly-x86.factor"
-    "/library/compiler/compiler-macros.factor"
-    "/library/compiler/compiler.factor"
-    "/library/compiler/ifte.factor"
-    "/library/compiler/generic.factor"
-    "/library/compiler/interpret-only.factor"
-    "/library/compiler/compile-all.factor"
-    "/library/compiler/alien-types.factor"
-    "/library/compiler/alien-macros.factor"
-    "/library/compiler/alien.factor"
-
     "/library/platform/native/primitives.factor"
 
     "/library/init.factor"
-    "/library/platform/native/init-stage2.factor"
 ] [
     dup print
     run-resource
 ] each
 
+cpu "x86" = [
+    [
+        "/library/compiler/assembler.factor"
+        "/library/compiler/assembly-x86.factor"
+        "/library/compiler/compiler-macros.factor"
+        "/library/compiler/compiler.factor"
+        "/library/compiler/ifte.factor"
+        "/library/compiler/generic.factor"
+        "/library/compiler/interpret-only.factor"
+        "/library/compiler/compile-all.factor"
+        "/library/compiler/alien-types.factor"
+        "/library/compiler/alien-macros.factor"
+        "/library/compiler/alien.factor"
+    ] [
+        dup print
+        run-resource
+    ] each
+] [
+    "/library/compiler/dummy-compiler.factor" dup print run-resource
+] ifte
+
+"/library/platform/native/init-stage2.factor" dup print run-resource
+
 IN: init
 DEFER: warm-boot
 
 IN: compiler
-DEFER: init-assembler
+DEFER: compilable-words
+DEFER: compilable-word-list
+
+[ warm-boot ] set-boot
 
-: set-boot ( quot -- ) 8 setenv ;
-[ init-assembler warm-boot ] set-boot
+compilable-words compilable-word-list set
 
 garbage-collection
 "factor.image" save-image
index e69d25f0fad55d557dbd36401eb582b460701f5d..b66579516b9dda625d6c3f872b1fca2f1491b37a 100644 (file)
@@ -62,10 +62,13 @@ USE: words
     t "user-init" set
     t "interactive" set
     t "ansi" set
+    t "compile" set
 
     ! The first CLI arg is the image name.
     cli-args uncons parse-command-line "image" set
 
+    "compile" get [ init-compiler ] when
+
     run-user-init
 
     "ansi" get [ "stdio" get <ansi-stream> "stdio" set ] when
index 94b1b40c734de99843283747ca76102e3eca2587..9ccdb9645c59088eb112ef43f36b8bf8919f9622 100644 (file)
@@ -46,6 +46,10 @@ USE: words
 USE: unparser
 USE: vectors
 
+: cpu ( -- arch )
+    #! Returns one of "x86" or "unknown".
+    11 getenv ;
+
 ! The 'fake vtable' used here speeds things up a lot.
 ! It is quite clumsy, however. A higher-level CLOS-style
 ! 'generic words' system will be built later.
@@ -116,6 +120,10 @@ IN: kernel
         [ drop t ] [ ( return the object ) ]
     ] cond ;
 
+: set-boot ( quot -- )
+    #! Set the boot quotation.
+    8 setenv ;
+
 : java? f ;
 : native? t ;
 
index 58721fcc31965894d9ea4a52b9fb8428a6a08c2e..ad200c062b7178ab6deb796c9f6e9dd5ad9435cc 100644 (file)
@@ -27,6 +27,12 @@ int main(int argc, char** argv)
 
        userenv[ARGS_ENV] = args;
 
+#if defined(i386) || defined(__i386) || defined(__i386__)
+       userenv[CPU_ENV] = tag_object(from_c_string("x86"));
+#else
+       userenv[CPU_ENV] = tag_object(from_c_string("unknown"));
+#endif
+
        run();
 
        return 0;
index 09f08a287fcb043781f5a9745cd3f3f11e9f508f..550fc982069b01ed3ae34257616a991013d2a725 100644 (file)
@@ -11,6 +11,7 @@
 #define BOOT_ENV       8
 #define RUNQUEUE_ENV   9 /* used by library only */
 #define ARGS_ENV       10
+#define CPU_ENV        11
 
 /* Profiling timer */
 struct itimerval prof_timer;