From fc6c9e2dfde7ebfb63de5fa89dfcc00514b4b772 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 30 Jun 2009 16:47:22 -0500 Subject: [PATCH 1/5] cpu.x86: don't clobber src in %dispatch --- basis/cpu/x86/32/32.factor | 4 ++-- basis/cpu/x86/64/64.factor | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/basis/cpu/x86/32/32.factor b/basis/cpu/x86/32/32.factor index b591b254f8..e908f52952 100755 --- a/basis/cpu/x86/32/32.factor +++ b/basis/cpu/x86/32/32.factor @@ -29,10 +29,10 @@ M: x86.32 temp-reg-2 EDX ; M:: x86.32 %dispatch ( src temp -- ) ! Load jump table base. - src HEX: ffffffff ADD + temp src HEX: ffffffff [+] LEA 0 rc-absolute-cell rel-here ! Go - src HEX: 7f [+] JMP + temp HEX: 7f [+] JMP ! Fix up the displacement above cell code-alignment [ 7 + building get dup pop* push ] diff --git a/basis/cpu/x86/64/64.factor b/basis/cpu/x86/64/64.factor index 3a7221c239..2c8fb3f18f 100644 --- a/basis/cpu/x86/64/64.factor +++ b/basis/cpu/x86/64/64.factor @@ -27,8 +27,8 @@ M:: x86.64 %dispatch ( src temp -- ) temp HEX: ffffffff MOV 0 rc-absolute-cell rel-here ! Add jump table base - src temp ADD - src HEX: 7f [+] JMP + temp src ADD + temp HEX: 7f [+] JMP ! Fix up the displacement above cell code-alignment [ 15 + building get dup pop* push ] From 54876d0cba8e892e5298166d456c191fd43e53d1 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 30 Jun 2009 18:10:53 -0500 Subject: [PATCH 2/5] compiler.cfg.linear-scan.assignment: get check-assignment? to work with coalescing --- .../compiler/cfg/linear-scan/assignment/assignment.factor | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/basis/compiler/cfg/linear-scan/assignment/assignment.factor b/basis/compiler/cfg/linear-scan/assignment/assignment.factor index 1a7f32a0ea..ea717f9218 100644 --- a/basis/compiler/cfg/linear-scan/assignment/assignment.factor +++ b/basis/compiler/cfg/linear-scan/assignment/assignment.factor @@ -108,11 +108,14 @@ SYMBOL: check-assignment? ERROR: overlapping-registers intervals ; +: check-assignment ( intervals -- ) + dup [ copy-from>> ] map sift '[ vreg>> _ member? not ] filter + dup [ reg>> ] map all-unique? [ drop ] [ overlapping-registers ] if ; + : active-intervals ( insn -- intervals ) insn#>> pending-intervals get [ covers? ] with filter check-assignment? get [ - dup [ reg>> ] map all-unique? - [ overlapping-registers ] unless + dup check-assignment ] when ; M: vreg-insn assign-registers-in-insn From 4db44cd23f57c41284debe0e196a9fb77f6c1b49 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 30 Jun 2009 18:11:15 -0500 Subject: [PATCH 3/5] %dispatch: sometimes the generated sequence is one byte longer, so instead of hard-coding it, compute the right length --- basis/cpu/x86/32/32.factor | 4 +++- basis/cpu/x86/64/64.factor | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/basis/cpu/x86/32/32.factor b/basis/cpu/x86/32/32.factor index e908f52952..86cd53712d 100755 --- a/basis/cpu/x86/32/32.factor +++ b/basis/cpu/x86/32/32.factor @@ -30,12 +30,14 @@ M: x86.32 temp-reg-2 EDX ; M:: x86.32 %dispatch ( src temp -- ) ! Load jump table base. temp src HEX: ffffffff [+] LEA + building get length cell - :> start 0 rc-absolute-cell rel-here ! Go temp HEX: 7f [+] JMP + building get length :> end ! Fix up the displacement above cell code-alignment - [ 7 + building get dup pop* push ] + [ end start - + building get dup pop* push ] [ align-code ] bi ; diff --git a/basis/cpu/x86/64/64.factor b/basis/cpu/x86/64/64.factor index 2c8fb3f18f..5390d7e0c8 100644 --- a/basis/cpu/x86/64/64.factor +++ b/basis/cpu/x86/64/64.factor @@ -23,15 +23,17 @@ M: x86.64 rs-reg R15 ; M: x86.64 stack-reg RSP ; M:: x86.64 %dispatch ( src temp -- ) + building get length :> start ! Load jump table base. temp HEX: ffffffff MOV 0 rc-absolute-cell rel-here ! Add jump table base temp src ADD temp HEX: 7f [+] JMP + building get length :> end ! Fix up the displacement above cell code-alignment - [ 15 + building get dup pop* push ] + [ end start - 2 - + building get dup pop* push ] [ align-code ] bi ; From 3355fa480993e19a68686f622f5767cedd20b72f Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 30 Jun 2009 18:11:45 -0500 Subject: [PATCH 4/5] compiler.cfg.stack-analysis: enable global optimization --- basis/compiler/cfg/stack-analysis/stack-analysis.factor | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/basis/compiler/cfg/stack-analysis/stack-analysis.factor b/basis/compiler/cfg/stack-analysis/stack-analysis.factor index 5679d8bd11..1e7f33c7e0 100644 --- a/basis/compiler/cfg/stack-analysis/stack-analysis.factor +++ b/basis/compiler/cfg/stack-analysis/stack-analysis.factor @@ -59,17 +59,12 @@ UNION: sync-if-back-edge ##dispatch ##loop-entry ; -SYMBOL: local-only? - -t local-only? set-global - : back-edge? ( from to -- ? ) [ number>> ] bi@ > ; : sync-state? ( -- ? ) basic-block get successors>> - [ [ predecessors>> ] keep '[ _ back-edge? ] any? ] any? - local-only? get or ; + [ [ predecessors>> ] keep '[ _ back-edge? ] any? ] any? ; M: sync-if-back-edge visit sync-state? [ sync-state ] when , ; From bc2a6c0ecc3909567bbf5c3b0e1f6ad115b59add Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 30 Jun 2009 18:22:54 -0500 Subject: [PATCH 5/5] compiler.cfg.stack-analysis: fix tests --- basis/compiler/cfg/stack-analysis/stack-analysis-tests.factor | 2 -- 1 file changed, 2 deletions(-) diff --git a/basis/compiler/cfg/stack-analysis/stack-analysis-tests.factor b/basis/compiler/cfg/stack-analysis/stack-analysis-tests.factor index 1bef0c3967..6f4b88e28e 100644 --- a/basis/compiler/cfg/stack-analysis/stack-analysis-tests.factor +++ b/basis/compiler/cfg/stack-analysis/stack-analysis-tests.factor @@ -17,8 +17,6 @@ IN: compiler.cfg.stack-analysis.tests : linearize ( cfg -- mr ) flatten-cfg instructions>> ; -local-only? off - [ ] [ [ ] test-stack-analysis drop ] unit-test ! Only peek once