load primitive types in stage 1

cvs
Slava Pestov 2005-12-07 02:34:18 +00:00
parent 00ec673094
commit ceb15dbe5d
5 changed files with 33 additions and 30 deletions

View File

@ -136,6 +136,7 @@ vectors words ;
"/library/compiler/compiler.factor"
"/library/alien/c-types.factor"
"/library/alien/primitive-types.factor"
"/library/alien/structs.factor"
"/library/alien/compiler.factor"
"/library/alien/syntax.factor"

View File

@ -5,27 +5,23 @@ errors generic hashtables io io-internals kernel
kernel-internals lists math memory namespaces optimizer parser
sequences sequences-internals words ;
: pull-in ( ? list -- )
swap [ [ dup print run-resource ] each ] [ drop ] if ;
"Loading compiler backend..." print
cpu "x86" = [
"/library/compiler/x86/load.factor"
] pull-in
"/library/compiler/x86/load.factor" run-resource
] when
cpu "ppc" = [
"/library/compiler/ppc/load.factor"
] pull-in
"/library/compiler/ppc/load.factor" run-resource
] when
cpu "amd64" = [
"/library/compiler/amd64/load.factor"
] pull-in
"/library/compiler/amd64/load.factor" run-resource
] when
"Loading more library code..." print
t [
"/library/alien/primitive-types.factor"
[
"/library/alien/malloc.factor"
"/library/io/buffer.factor"
@ -34,19 +30,21 @@ t [
"/library/freetype/load.factor"
"/library/ui/load.factor"
"/library/help/load.factor"
] pull-in
] [
dup print run-resource
] each
! Handle -libraries:... overrides
parse-command-line
"compile" get supported-cpu? and [
unix? [
"/library/unix/load.factor"
] pull-in
"/library/unix/load.factor" run-resource
] when
os "win32" = [
"/library/win32/load.factor"
] pull-in
"/library/win32/load.factor" run-resource
] when
"Compiling base..." print
@ -96,5 +94,3 @@ number>string write " ms" print
"factor.image" save-image
0 exit
FORGET: pull-in

View File

@ -28,3 +28,5 @@ M: float-regs fastcall-regs drop 0 ;
0 scratch [ swap MOV ] keep ; inline
: fixnum>slot@ drop ; inline
: return-register RAX ; inline

View File

@ -28,3 +28,5 @@ M: float-regs fastcall-regs drop 0 ;
; inline
: fixnum>slot@ 1 SHR ; inline
: return-register EAX ; inline

View File

@ -29,7 +29,7 @@ math-internals memory namespaces words ;
"s48_long_to_bignum" f compile-c-call
! An untagged pointer to the bignum is now in EAX; tag it
EAX bignum-tag OR
ESP 4 ADD
0 scratch POP
"end" get save-xt ; inline
M: %fixnum+ generate-node ( vop -- )
@ -111,32 +111,33 @@ M: %fixnum-bitnot generate-node ( vop -- )
0 output-operand tag-mask XOR ;
M: %fixnum<< generate-node
#! This has specific register requirements.
drop
! This has specific register requirements.
<label> "no-overflow" set
<label> "end" set
! make a copy
ECX EAX MOV
0 scratch 1 input-operand MOV
! check for potential overflow
ECX 0 input shift-add ADD
ECX 0 input shift-add 2 * 1- CMP
0 scratch 0 input shift-add ADD
0 scratch 0 input shift-add 2 * 1- CMP
! is there going to be an overflow?
"no-overflow" get JBE
! there is going to be an overflow, make a bignum
EAX tag-bits SAR
1 input-operand tag-bits SAR
0 input PUSH
EAX PUSH
1 input-operand PUSH
"s48_long_to_bignum" f compile-c-call
EDX POP
EAX PUSH
0 scratch POP
1 input-operand PUSH
"s48_bignum_arithmetic_shift" f compile-c-call
! tag the result
EAX bignum-tag OR
ESP cell 2 * ADD
1 input-operand bignum-tag OR
0 scratch POP
1 scratch POP
"end" get JMP
! there is not going to be an overflow
"no-overflow" get save-xt
EAX 0 input SHL
1 input-operand 0 input SHL
"end" get save-xt ;
M: %fixnum>> generate-node
@ -147,6 +148,7 @@ M: %fixnum>> generate-node
0 output-operand tag-mask bitnot AND ;
M: %fixnum-sgn generate-node
#! This has specific register requirements.
drop
! store 0 in EDX if EAX is >=0, otherwise store -1.
CDQ