Merge git://factorcode.org/git/factor

db4
Doug Coleman 2008-01-12 15:00:47 -10:00
commit 03f6728e26
9 changed files with 151 additions and 122 deletions

View File

@ -8,12 +8,14 @@ implementation. It is not an introduction to the language itself.
- Platform support - Platform support
- Compiling the Factor VM - Compiling the Factor VM
- Libraries needed for compilation
- Bootstrapping the Factor image - Bootstrapping the Factor image
- Running Factor on Unix with X11 - Running Factor on Unix with X11
- Running Factor on Mac OS X - Cocoa UI - Running Factor on Mac OS X - Cocoa UI
- Running Factor on Mac OS X - X11 UI - Running Factor on Mac OS X - X11 UI
- Running Factor on Windows - Running Factor on Windows
- Command line usage - Command line usage
- The Factor FAQ
- Source organization - Source organization
- Community - Community
@ -59,6 +61,17 @@ for your platform.
Compilation will yield an executable named 'factor' on Unix, Compilation will yield an executable named 'factor' on Unix,
'factor-nt.exe' on Windows XP/Vista, and 'factor-ce.exe' on Windows CE. 'factor-nt.exe' on Windows XP/Vista, and 'factor-ce.exe' on Windows CE.
* Libraries needed for compilation
For X11 support, you need recent development libraries for libc, Freetype,
X11, OpenGL and GLUT. On a Debian-derived Linux distribution (like Ubuntu),
you can use the line
sudo apt-get install libc6-dev libfreetype6-dev libx11-dev glutg3-dev
to grab everything (if you're on a non-debian-derived distro please tell us
what the equivalent command is on there and it can be added :)
* Bootstrapping the Factor image * Bootstrapping the Factor image
The boot images are no longer included with the Factor distribution The boot images are no longer included with the Factor distribution
@ -148,6 +161,10 @@ To run the listener in the command prompt:
factor-nt.exe -run=listener factor-nt.exe -run=listener
* The Factor FAQ
The Factor FAQ lives online at http://factorcode.org/faq.fhtml
* Command line usage * Command line usage
The Factor VM supports a number of command line switches. To read The Factor VM supports a number of command line switches. To read

View File

@ -3,7 +3,7 @@
USING: byte-arrays arrays generator.registers assocs USING: byte-arrays arrays generator.registers assocs
kernel kernel.private libc math namespaces parser sequences kernel kernel.private libc math namespaces parser sequences
strings words assocs splitting math.parser cpu.architecture strings words assocs splitting math.parser cpu.architecture
alien quotations system ; alien quotations system compiler.units ;
IN: alien.c-types IN: alien.c-types
TUPLE: c-type TUPLE: c-type
@ -227,130 +227,135 @@ M: long-long-type box-return ( type -- )
define-out ; define-out ;
: expand-constants ( c-type -- c-type' ) : expand-constants ( c-type -- c-type' )
#! We use word-def call instead of execute to get around
#! staging violations
dup array? [ dup array? [
unclip >r [ dup word? [ execute ] when ] map r> add* unclip >r [ dup word? [ word-def call ] when ] map
r> add*
] when ; ] when ;
[ alien-cell ] [
[ set-alien-cell ] [ alien-cell ]
bootstrap-cell [ set-alien-cell ]
"box_alien" bootstrap-cell
"alien_offset" <primitive-type> "box_alien"
"void*" define-primitive-type "alien_offset" <primitive-type>
"void*" define-primitive-type
[ alien-signed-8 ] [ alien-signed-8 ]
[ set-alien-signed-8 ] [ set-alien-signed-8 ]
8 8
"box_signed_8" "box_signed_8"
"to_signed_8" <primitive-type> <long-long-type> "to_signed_8" <primitive-type> <long-long-type>
"longlong" define-primitive-type "longlong" define-primitive-type
[ alien-unsigned-8 ] [ alien-unsigned-8 ]
[ set-alien-unsigned-8 ] [ set-alien-unsigned-8 ]
8 8
"box_unsigned_8" "box_unsigned_8"
"to_unsigned_8" <primitive-type> <long-long-type> "to_unsigned_8" <primitive-type> <long-long-type>
"ulonglong" define-primitive-type "ulonglong" define-primitive-type
[ alien-signed-cell ] [ alien-signed-cell ]
[ set-alien-signed-cell ] [ set-alien-signed-cell ]
bootstrap-cell bootstrap-cell
"box_signed_cell" "box_signed_cell"
"to_fixnum" <primitive-type> "to_fixnum" <primitive-type>
"long" define-primitive-type "long" define-primitive-type
[ alien-unsigned-cell ] [ alien-unsigned-cell ]
[ set-alien-unsigned-cell ] [ set-alien-unsigned-cell ]
bootstrap-cell bootstrap-cell
"box_unsigned_cell" "box_unsigned_cell"
"to_cell" <primitive-type> "to_cell" <primitive-type>
"ulong" define-primitive-type "ulong" define-primitive-type
[ alien-signed-4 ] [ alien-signed-4 ]
[ set-alien-signed-4 ] [ set-alien-signed-4 ]
4 4
"box_signed_4" "box_signed_4"
"to_fixnum" <primitive-type> "to_fixnum" <primitive-type>
"int" define-primitive-type "int" define-primitive-type
[ alien-unsigned-4 ] [ alien-unsigned-4 ]
[ set-alien-unsigned-4 ] [ set-alien-unsigned-4 ]
4 4
"box_unsigned_4" "box_unsigned_4"
"to_cell" <primitive-type> "to_cell" <primitive-type>
"uint" define-primitive-type "uint" define-primitive-type
[ alien-signed-2 ] [ alien-signed-2 ]
[ set-alien-signed-2 ] [ set-alien-signed-2 ]
2 2
"box_signed_2" "box_signed_2"
"to_fixnum" <primitive-type> "to_fixnum" <primitive-type>
"short" define-primitive-type "short" define-primitive-type
[ alien-unsigned-2 ] [ alien-unsigned-2 ]
[ set-alien-unsigned-2 ] [ set-alien-unsigned-2 ]
2 2
"box_unsigned_2" "box_unsigned_2"
"to_cell" <primitive-type> "to_cell" <primitive-type>
"ushort" define-primitive-type "ushort" define-primitive-type
[ alien-signed-1 ] [ alien-signed-1 ]
[ set-alien-signed-1 ] [ set-alien-signed-1 ]
1 1
"box_signed_1" "box_signed_1"
"to_fixnum" <primitive-type> "to_fixnum" <primitive-type>
"char" define-primitive-type "char" define-primitive-type
[ alien-unsigned-1 ] [ alien-unsigned-1 ]
[ set-alien-unsigned-1 ] [ set-alien-unsigned-1 ]
1 1
"box_unsigned_1" "box_unsigned_1"
"to_cell" <primitive-type> "to_cell" <primitive-type>
"uchar" define-primitive-type "uchar" define-primitive-type
[ alien-unsigned-4 zero? not ] [ alien-unsigned-4 zero? not ]
[ 1 0 ? set-alien-unsigned-4 ] [ 1 0 ? set-alien-unsigned-4 ]
4 4
"box_boolean" "box_boolean"
"to_boolean" <primitive-type> "to_boolean" <primitive-type>
"bool" define-primitive-type "bool" define-primitive-type
[ alien-float ] [ alien-float ]
[ >r >r >float r> r> set-alien-float ] [ >r >r >float r> r> set-alien-float ]
4 4
"box_float" "box_float"
"to_float" <primitive-type> "to_float" <primitive-type>
"float" define-primitive-type "float" define-primitive-type
T{ float-regs f 4 } "float" c-type set-c-type-reg-class T{ float-regs f 4 } "float" c-type set-c-type-reg-class
[ >float ] "float" c-type set-c-type-prep [ >float ] "float" c-type set-c-type-prep
[ alien-double ] [ alien-double ]
[ >r >r >float r> r> set-alien-double ] [ >r >r >float r> r> set-alien-double ]
8 8
"box_double" "box_double"
"to_double" <primitive-type> "to_double" <primitive-type>
"double" define-primitive-type "double" define-primitive-type
T{ float-regs f 8 } "double" c-type set-c-type-reg-class T{ float-regs f 8 } "double" c-type set-c-type-reg-class
[ >float ] "double" c-type set-c-type-prep [ >float ] "double" c-type set-c-type-prep
[ alien-cell alien>char-string ] [ alien-cell alien>char-string ]
[ set-alien-cell ] [ set-alien-cell ]
bootstrap-cell bootstrap-cell
"box_char_string" "box_char_string"
"alien_offset" <primitive-type> "alien_offset" <primitive-type>
"char*" define-primitive-type "char*" define-primitive-type
"char*" "uchar*" typedef "char*" "uchar*" typedef
[ string>char-alien ] "char*" c-type set-c-type-prep [ string>char-alien ] "char*" c-type set-c-type-prep
[ alien-cell alien>u16-string ] [ alien-cell alien>u16-string ]
[ set-alien-cell ] [ set-alien-cell ]
4 4
"box_u16_string" "box_u16_string"
"alien_offset" <primitive-type> "alien_offset" <primitive-type>
"ushort*" define-primitive-type "ushort*" define-primitive-type
[ string>u16-alien ] "ushort*" c-type set-c-type-prep [ string>u16-alien ] "ushort*" c-type set-c-type-prep
] with-compilation-unit

View File

@ -8,10 +8,9 @@ IN: bootstrap.x86
: arg0 RDI ; : arg0 RDI ;
: arg1 RSI ; : arg1 RSI ;
: temp-reg RBX ;
: stack-reg RSP ; : stack-reg RSP ;
: ds-reg R14 ; : ds-reg R14 ;
: scan-reg RBX ;
: xt-reg RCX ;
: fixnum>slot@ ; : fixnum>slot@ ;
"resource:core/cpu/x86/bootstrap.factor" run-file "resource:core/cpu/x86/bootstrap.factor" run-file

View File

@ -13,7 +13,8 @@ big-endian off
[ [
! Load word ! Load word
temp-reg 0 [] MOV temp-reg 0 MOV
temp-reg dup [] MOV
! Bump profiling counter ! Bump profiling counter
temp-reg profile-count-offset [+] 1 tag-fixnum ADD temp-reg profile-count-offset [+] 1 tag-fixnum ADD
! Load word->code ! Load word->code
@ -22,7 +23,7 @@ big-endian off
temp-reg compiled-header-size ADD temp-reg compiled-header-size ADD
! Jump to XT ! Jump to XT
temp-reg JMP temp-reg JMP
] rc-absolute-cell rt-literal 2 jit-profiling jit-define ] rc-absolute-cell rt-literal 1 jit-profiling jit-define
[ [
stack-frame-size PUSH ! save stack frame size stack-frame-size PUSH ! save stack frame size
@ -31,10 +32,11 @@ big-endian off
] rc-absolute-cell rt-label 6 jit-prolog jit-define ] rc-absolute-cell rt-label 6 jit-prolog jit-define
[ [
arg0 0 [] MOV ! load literal arg0 0 MOV ! load literal
arg0 dup [] MOV
ds-reg bootstrap-cell ADD ! increment datastack pointer ds-reg bootstrap-cell ADD ! increment datastack pointer
ds-reg [] arg0 MOV ! store literal on datastack ds-reg [] arg0 MOV ! store literal on datastack
] rc-absolute-cell rt-literal 2 jit-push-literal jit-define ] rc-absolute-cell rt-literal 1 jit-push-literal jit-define
[ [
arg1 stack-reg MOV ! pass callstack pointer as arg 2 arg1 stack-reg MOV ! pass callstack pointer as arg 2
@ -60,14 +62,15 @@ big-endian off
] rc-absolute-cell rt-literal 1 jit-if-jump jit-define ] rc-absolute-cell rt-literal 1 jit-if-jump jit-define
[ [
arg1 0 [] MOV ! load dispatch table arg1 0 MOV ! load dispatch table
arg1 dup [] MOV
arg0 ds-reg [] MOV ! load index arg0 ds-reg [] MOV ! load index
fixnum>slot@ ! turn it into an array offset fixnum>slot@ ! turn it into an array offset
ds-reg bootstrap-cell SUB ! pop index ds-reg bootstrap-cell SUB ! pop index
arg0 arg1 ADD ! compute quotation location arg0 arg1 ADD ! compute quotation location
arg0 arg0 array-start [+] MOV ! load quotation arg0 arg0 array-start [+] MOV ! load quotation
arg0 quot-xt@ [+] JMP ! execute branch arg0 quot-xt@ [+] JMP ! execute branch
] rc-absolute-cell rt-literal 2 jit-dispatch jit-define ] rc-absolute-cell rt-literal 1 jit-dispatch jit-define
[ [
stack-reg stack-frame-size bootstrap-cell - ADD ! unwind stack frame stack-reg stack-frame-size bootstrap-cell - ADD ! unwind stack frame

View File

@ -61,6 +61,11 @@ M: pair (bitfield-quot) ( spec -- quot )
\ set-slots [ <reversed> [get-slots] ] 1 define-transform \ set-slots [ <reversed> [get-slots] ] 1 define-transform
\ construct-boa [ : [construct] ( word quot -- newquot )
dup tuple-size [ <tuple-boa> ] 2curry >r dup +inlined+ depends-on dup tuple-size r> 2curry ;
] 1 define-transform
\ construct-boa
[ [ <tuple-boa> ] [construct] ] 1 define-transform
\ construct-empty
[ [ <tuple> ] [construct] ] 1 define-transform

View File

@ -301,7 +301,7 @@ IN: temporary
] unit-test ] unit-test
[ ] [ [ ] [
"IN: temporary GENERIC: killer?" "IN: temporary GENERIC: killer? ( a -- b )"
<string-reader> "removing-the-predicate" parse-stream drop <string-reader> "removing-the-predicate" parse-stream drop
] unit-test ] unit-test

View File

@ -437,7 +437,7 @@ SYMBOL: bootstrap-syntax
smudged-usage forget-all smudged-usage forget-all
over empty? [ 2dup smudged-usage-warning ] unless 2drop ; over empty? [ 2dup smudged-usage-warning ] unless 2drop ;
: finish-parsing ( contents quot -- ) : finish-parsing ( lines quot -- )
file get file get
[ record-form ] keep [ record-form ] keep
[ record-modified ] keep [ record-modified ] keep
@ -447,8 +447,7 @@ SYMBOL: bootstrap-syntax
: parse-stream ( stream name -- quot ) : parse-stream ( stream name -- quot )
[ [
[ [
contents lines dup parse-fresh
dup string-lines parse-fresh
tuck finish-parsing tuck finish-parsing
forget-smudged forget-smudged
] with-source-file ] with-source-file

View File

@ -59,7 +59,7 @@ M: tuple class class-of-tuple ;
] unless ] unless
] when 2drop ; ] when 2drop ;
GENERIC: tuple-size ( class -- size ) foldable GENERIC: tuple-size ( class -- size )
M: tuple-class tuple-size "slot-names" word-prop length 2 + ; M: tuple-class tuple-size "slot-names" word-prop length 2 + ;

View File

@ -1,4 +1,5 @@
USING: math.statistics help.markup help.syntax debugger ; USING: help.markup help.syntax debugger ;
IN: math.statistics
HELP: geometric-mean HELP: geometric-mean
{ $values { "seq" "a sequence of numbers" } { "n" "a non-negative real number"} } { $values { "seq" "a sequence of numbers" } { "n" "a non-negative real number"} }