diff --git a/basis/compiler/cfg/stacks/local/local-docs.factor b/basis/compiler/cfg/stacks/local/local-docs.factor index 96cede064c..b511dab29c 100644 --- a/basis/compiler/cfg/stacks/local/local-docs.factor +++ b/basis/compiler/cfg/stacks/local/local-docs.factor @@ -91,7 +91,6 @@ $nl translate-local-loc } "Words for writing the stack state:" { $subsections - adjust inc-stack modify-height replace-loc diff --git a/basis/compiler/cfg/stacks/local/local.factor b/basis/compiler/cfg/stacks/local/local.factor index 388156ad68..c10feda47c 100644 --- a/basis/compiler/cfg/stacks/local/local.factor +++ b/basis/compiler/cfg/stacks/local/local.factor @@ -14,9 +14,6 @@ IN: compiler.cfg.stacks.local : modify-height ( state loc -- ) >loc< 0 1 ? rot nth [ + ] with map! drop ; -: adjust ( state loc -- ) - >loc< 0 1 ? rot nth dup first swapd + 0 rot set-nth ; - : reset-emits ( state -- ) [ 0 1 rot set-nth ] each ; diff --git a/basis/compiler/cfg/stacks/stacks-docs.factor b/basis/compiler/cfg/stacks/stacks-docs.factor index c2ff2131f8..73ba20cc8c 100644 --- a/basis/compiler/cfg/stacks/stacks-docs.factor +++ b/basis/compiler/cfg/stacks/stacks-docs.factor @@ -16,8 +16,8 @@ HELP: end-stack-analysis { $description "Ends the stack analysis of the current cfg. This is the last step of the cfg construction (but comes before all optimization passes)." } ; HELP: adjust-d -{ $values { "n" number } } -{ $description "Changes the height of the current data stack. This word is called when other instructions which internally adjust the stack height are emitted, such as " { $link ##call } " and " { $link ##alien-invoke } "." } ; +{ $values { "n" integer } } +{ $description "Changes the current height of the data stack. The word is used when other instructions which adjust the stack height are emitted, such as " { $link ##call } " and " { $link ##alien-invoke } ". Since the stack height is adjusted without emitting " { ##inc } " instructions, the " { $link inc-stack } " word can't be used by them." } ; HELP: ds-drop { $description "Used to signal to the stack analysis that the datastacks height is decreased by one." } ; diff --git a/basis/compiler/cfg/stacks/stacks-tests.factor b/basis/compiler/cfg/stacks/stacks-tests.factor index 707ebf615e..71a70b1839 100644 --- a/basis/compiler/cfg/stacks/stacks-tests.factor +++ b/basis/compiler/cfg/stacks/stacks-tests.factor @@ -3,6 +3,15 @@ compiler.cfg.stacks compiler.cfg.stacks.local compiler.test kernel literals namespaces tools.test ; IN: compiler.cfg.stacks.tests +! adjust-d +{ + { { 6 2 } { 3 4 } } + { { -4 2 } { 3 4 } } +} [ + { { 1 2 } { 3 4 } } [ height-state set 5 adjust-d ] keep + { { 1 2 } { 3 4 } } [ height-state set -5 adjust-d ] keep +] unit-test + { H{ { D: 1 4 } { D: 2 3 } { D: 0 5 } } { { 0 0 } { 0 0 } } diff --git a/basis/compiler/cfg/stacks/stacks.factor b/basis/compiler/cfg/stacks/stacks.factor index 3587a9d6e4..9919864a91 100644 --- a/basis/compiler/cfg/stacks/stacks.factor +++ b/basis/compiler/cfg/stacks/stacks.factor @@ -61,4 +61,4 @@ IN: compiler.cfg.stacks [ ds-pop ] dip call ds-push ; inline : adjust-d ( n -- ) - height-state get swap adjust ; + 0 height-state get first [ + ] change-nth ;