From cfe4fec574293cc97654ad5d12cb94137ee8e98c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Lindqvist?= Date: Sun, 1 Nov 2015 09:57:07 +0100 Subject: [PATCH] compiler.cfg.linear-scan.*: make it so cfg is given as an argument to next-spill-slot --- .../linear-scan/allocation/state/state-docs.factor | 4 ++-- .../linear-scan/allocation/state/state-tests.factor | 11 ++++------- .../cfg/linear-scan/allocation/state/state.factor | 8 +++----- basis/compiler/cfg/linear-scan/resolve/resolve.factor | 2 +- 4 files changed, 10 insertions(+), 15 deletions(-) diff --git a/basis/compiler/cfg/linear-scan/allocation/state/state-docs.factor b/basis/compiler/cfg/linear-scan/allocation/state/state-docs.factor index 6ca33327c0..516147be49 100644 --- a/basis/compiler/cfg/linear-scan/allocation/state/state-docs.factor +++ b/basis/compiler/cfg/linear-scan/allocation/state/state-docs.factor @@ -49,8 +49,8 @@ HELP: init-allocator { $see-also reg-class } ; HELP: next-spill-slot -{ $values { "size" "number of bytes required" } { "spill-slot" spill-slot } } -{ $description "Creates a new " { $link spill-slot } " of the given size and also allocates space in the " { $link cfg } " in the 'cfg' dynamic variable for it." } ; +{ $values { "size" "number of bytes required" } { "cfg" cfg } { "spill-slot" spill-slot } } +{ $description "Creates a new " { $link spill-slot } " of the given size and also allocates space in the " { $link cfg } " in the cfg for it." } ; HELP: progress { $var-description "Start index of current live interval. We ensure that all live intervals added to the unhandled set have a start index strictly greater than this one. This ensures that we can catch infinite loop situations. We also ensure that all live intervals added to the handled set have an end index strictly smaller than this one. This helps catch bugs." } diff --git a/basis/compiler/cfg/linear-scan/allocation/state/state-tests.factor b/basis/compiler/cfg/linear-scan/allocation/state/state-tests.factor index 416fa0d9e4..2197ed7231 100644 --- a/basis/compiler/cfg/linear-scan/allocation/state/state-tests.factor +++ b/basis/compiler/cfg/linear-scan/allocation/state/state-tests.factor @@ -2,8 +2,8 @@ USING: accessors assocs combinators.extras compiler.cfg compiler.cfg.instructions compiler.cfg.linear-scan.allocation compiler.cfg.linear-scan.allocation.state compiler.cfg.linear-scan.live-intervals compiler.cfg.registers -compiler.cfg.utilities cpu.architecture cpu.x86.assembler.operands heaps -kernel layouts literals namespaces sequences system tools.test ; +compiler.cfg.utilities cpu.architecture cpu.x86.assembler.operands fry +heaps kernel layouts literals namespaces sequences system tools.test ; IN: compiler.cfg.linear-scan.allocation.state.tests ! active-intervals-for @@ -128,14 +128,11 @@ ${ cell } [ ! next-spill-slot { + T{ cfg { spill-area-size 16 } } T{ spill-slot f 0 } T{ spill-slot f 8 } - T{ cfg { spill-area-size 16 } } } [ - H{ } clone spill-slots set - T{ cfg { spill-area-size 0 } } cfg set - [ 8 next-spill-slot ] twice - cfg get + T{ cfg { spill-area-size 0 } } dup '[ 8 _ next-spill-slot ] twice ] unit-test ! >unhandled-min-heap diff --git a/basis/compiler/cfg/linear-scan/allocation/state/state.factor b/basis/compiler/cfg/linear-scan/allocation/state/state.factor index c80f7d9617..2147febd7e 100644 --- a/basis/compiler/cfg/linear-scan/allocation/state/state.factor +++ b/basis/compiler/cfg/linear-scan/allocation/state/state.factor @@ -113,10 +113,8 @@ ERROR: register-already-used live-interval ; : reg-class-assoc ( quot -- assoc ) [ reg-classes ] dip { } map>assoc ; inline -: next-spill-slot ( size -- spill-slot ) - cfg get - [ swap [ align dup ] [ + ] bi ] change-spill-area-size drop - ; +: next-spill-slot ( size cfg -- spill-slot ) + [ swap [ align dup ] [ + ] bi ] change-spill-area-size drop ; : align-spill-area ( align cfg -- ) [ max ] change-spill-area-align drop ; @@ -126,7 +124,7 @@ SYMBOL: spill-slots : assign-spill-slot ( coalesced-vreg rep -- spill-slot ) rep-size [ cfg get align-spill-area ] - [ spill-slots get [ nip next-spill-slot ] 2cache ] + [ spill-slots get [ nip cfg get next-spill-slot ] 2cache ] bi ; : lookup-spill-slot ( coalesced-vreg rep -- spill-slot ) diff --git a/basis/compiler/cfg/linear-scan/resolve/resolve.factor b/basis/compiler/cfg/linear-scan/resolve/resolve.factor index 088064b034..f59fc734e7 100644 --- a/basis/compiler/cfg/linear-scan/resolve/resolve.factor +++ b/basis/compiler/cfg/linear-scan/resolve/resolve.factor @@ -29,7 +29,7 @@ SYMBOL: temp-spills : temp-spill ( rep -- spill-slot ) rep-size temp-spills get - [ next-spill-slot ] cache ; + [ cfg get next-spill-slot ] cache ; SYMBOL: temp-locations