diff --git a/TODO.FACTOR.txt b/TODO.FACTOR.txt index 143a0a3f4a..1710ca5718 100644 --- a/TODO.FACTOR.txt +++ b/TODO.FACTOR.txt @@ -1,6 +1,5 @@ + compiler: -- recursive? and tree-contains? should handle vectors - type inference fails with some assembler words; displaced, register and other predicates need to inherit from list not cons, and need stronger branch partial eval diff --git a/library/bootstrap/boot.factor b/library/bootstrap/boot.factor index c16f80af3e..6b7e0dd495 100644 --- a/library/bootstrap/boot.factor +++ b/library/bootstrap/boot.factor @@ -72,9 +72,11 @@ USE: hashtables "traits" [ "generic" ] search "delegate" [ "generic" ] search + "object" [ "generic" ] search vocabularies get [ "generic" off ] bind + reveal reveal reveal diff --git a/library/compiler/generator.factor b/library/compiler/generator.factor index 741cc386b0..699826f3da 100644 --- a/library/compiler/generator.factor +++ b/library/compiler/generator.factor @@ -49,10 +49,6 @@ SYMBOL: relocation-table #! If flag is true; relative. 0 1 ? rel, relocating word-primitive rel, ; -: rel-word ( word rel/abs -- ) - #! If flag is true; relative. - over primitive? [ rel-primitive ] [ 2drop ] ifte ; - : rel-dlsym ( name dll rel/abs -- ) #! If flag is true; relative. 2 3 ? rel, relocating cons intern-literal rel, ; @@ -61,6 +57,14 @@ SYMBOL: relocation-table #! Relocate address just compiled. 4 rel, relocating 0 rel, ; +: rel-word ( word rel/abs -- ) + #! If flag is true; relative. + over primitive? [ + rel-primitive + ] [ + nip [ rel-address ] unless + ] ifte ; + : generate-node ( [[ op params ]] -- ) #! Generate machine code for a node. unswons dup "generator" word-property [ @@ -107,6 +111,8 @@ SYMBOL: previous-offset #label [ save-xt ] "generator" set-word-property +#end-dispatch [ drop ] "generator" set-word-property + : type-tag ( type -- tag ) #! Given a type number, return the tag number. dup 6 > [ drop 3 ] when ; diff --git a/library/compiler/linearizer.factor b/library/compiler/linearizer.factor index 2f67034160..4ab12d6d8b 100644 --- a/library/compiler/linearizer.factor +++ b/library/compiler/linearizer.factor @@ -53,10 +53,13 @@ SYMBOL: #jump ( tail-call ) SYMBOL: #jump-label ( tail-call ) SYMBOL: #return-to ( push addr on C stack ) -! dispatch is linearized as dispatch followed by a #target -! for each dispatch table entry. The linearizer ensures the -! correct number of #targets is emitted. +! dispatch is linearized as dispatch followed by a #target or +! #target-label for each dispatch table entry. The dispatch +! table terminates with #end-dispatch. The linearizer ensures +! the correct number of #targets is emitted. SYMBOL: #target ( part of jump table ) +SYMBOL: #target-label +SYMBOL: #end-dispatch : linear, ( node -- ) #! Add a node to the linear IR. @@ -146,7 +149,8 @@ SYMBOL: #target ( part of jump table ) #! label/branch pairs. [ dispatch ] ,