diff --git a/basis/compiler/cfg/builder/builder-tests.factor b/basis/compiler/cfg/builder/builder-tests.factor index 3befceb7ec..b08ab59f27 100644 --- a/basis/compiler/cfg/builder/builder-tests.factor +++ b/basis/compiler/cfg/builder/builder-tests.factor @@ -4,10 +4,10 @@ compiler.cfg.debugger compiler.cfg.instructions compiler.cfg.optimizer compiler.cfg.predecessors compiler.cfg.registers compiler.cfg.representations compiler.cfg.rpo compiler.cfg.stacks compiler.cfg.stacks.local compiler.cfg.utilities compiler.test compiler.tree compiler.tree.builder -compiler.tree.optimizer fry hashtables io kernel kernel.private locals make math -math.partial-dispatch math.private namespaces prettyprint sbufs sequences -sequences.private slots.private strings strings.private tools.test vectors -words ; +compiler.tree.optimizer cpu.architecture fry hashtables io kernel kernel.private +locals make math math.partial-dispatch math.private namespaces prettyprint sbufs +sequences sequences.private slots.private strings strings.private tools.test +vectors words ; FROM: alien.c-types => int ; IN: compiler.cfg.builder.tests @@ -275,6 +275,26 @@ IN: compiler.cfg.builder.tests replaces get ] cfg-unit-test +{ + V{ + T{ ##load-integer { dst 3 } { val 0 } } + T{ ##add { dst 4 } { src1 3 } { src2 2 } } + T{ ##load-memory-imm + { dst 5 } + { base 4 } + { offset 0 } + { rep int-rep } + } + T{ ##box-alien { dst 7 } { src 5 } { temp 6 } } + } +} [ + T{ #call + { word alien-cell } + { in-d V{ 10 20 } } + { out-d { 30 } } + } [ emit-node ] V{ } make +] cfg-unit-test + { 1 } [ V{ } 0 insns>block basic-block set init-cfg-test V{ } 1 insns>block [ emit-loop-call ] V{ } make drop diff --git a/basis/compiler/cfg/builder/builder.factor b/basis/compiler/cfg/builder/builder.factor index ee2e30131b..34c49fc864 100644 --- a/basis/compiler/cfg/builder/builder.factor +++ b/basis/compiler/cfg/builder/builder.factor @@ -133,22 +133,18 @@ M: #if emit-node [ emit-actual-if ] } cond ; -! #dispatch M: #dispatch emit-node ! Inputs to the final instruction need to be copied because of ! loc>vreg sync. ^^offset>slot always returns a fresh vreg, ! though. ds-pop ^^offset>slot next-vreg ##dispatch, emit-if ; -! #call M: #call emit-node dup word>> dup "intrinsic" word-prop [ emit-intrinsic ] [ swap call-height emit-call ] if ; -! #call-recursive M: #call-recursive emit-node [ label>> id>> ] [ call-height ] bi emit-call ; -! #push M: #push emit-node literal>> ^^load-literal ds-push ; diff --git a/basis/compiler/cfg/linear-scan/assignment/assignment-docs.factor b/basis/compiler/cfg/linear-scan/assignment/assignment-docs.factor index 42cc0eb4dc..6a1f748002 100644 --- a/basis/compiler/cfg/linear-scan/assignment/assignment-docs.factor +++ b/basis/compiler/cfg/linear-scan/assignment/assignment-docs.factor @@ -1,7 +1,7 @@ USING: assocs compiler.cfg compiler.cfg.instructions -compiler.cfg.linear-scan.live-intervals +compiler.cfg.linear-scan.live-intervals compiler.cfg.linear-scan.allocation compiler.cfg.linear-scan.allocation.state compiler.cfg.liveness -compiler.cfg.registers heaps help.markup help.syntax math ; +compiler.cfg.registers heaps help.markup help.syntax math sequences ; IN: compiler.cfg.linear-scan.assignment HELP: add-pending @@ -21,6 +21,10 @@ HELP: assign-registers-in-block { $values { "bb" basic-block } } { $description "Assigns registers and also inserts " { $link ##reload } " and " { $link ##spill } " instructions." } ; +HELP: assign-registers +{ $values { "cfg" cfg } { "live-intervals" sequence } } +{ $description "Uses the live intervals in the sequence to assign physical registers to all instructions in the cfg. The live intervals must first have had their physical registers assigned by " { $link allocate-registers } "." } ; + HELP: assign-registers-in-insn { $values { "insn" insn } } { $description "Assigns physical registers and spill slots for the virtual registers used by the instruction." } ; diff --git a/basis/compiler/cfg/linear-scan/live-intervals/live-intervals-tests.factor b/basis/compiler/cfg/linear-scan/live-intervals/live-intervals-tests.factor index fd1f5e661d..77abec80cc 100644 --- a/basis/compiler/cfg/linear-scan/live-intervals/live-intervals-tests.factor +++ b/basis/compiler/cfg/linear-scan/live-intervals/live-intervals-tests.factor @@ -18,6 +18,14 @@ IN: compiler.cfg.linear-scan.live-intervals.tests [ number-instructions ] [ cfg>sync-points ] bi ] unit-test +! find-use +{ + f T{ vreg-use { n 25 } } +} [ + 25 T{ live-interval-state { uses V{ } } } find-use + 25 T{ live-interval-state { uses V{ T{ vreg-use { n 25 } } } } } find-use +] unit-test + ! intervals-intersect? { t f f } [ { { 4 20 } } diff --git a/basis/compiler/cfg/linear-scan/live-intervals/live-intervals.factor b/basis/compiler/cfg/linear-scan/live-intervals/live-intervals.factor index 3c863577b6..276bad6fb8 100644 --- a/basis/compiler/cfg/linear-scan/live-intervals/live-intervals.factor +++ b/basis/compiler/cfg/linear-scan/live-intervals/live-intervals.factor @@ -35,7 +35,7 @@ TUPLE: live-interval-state : (find-use) ( insn# live-interval -- vreg-use ) uses>> [ n>> <=> ] with search nip ; -:: find-use ( insn# live-interval -- vreg-use ) +:: find-use ( insn# live-interval -- vreg-use/f ) insn# live-interval (find-use) dup [ dup n>> insn# = [ drop f ] unless ] when ; diff --git a/basis/compiler/cfg/liveness/liveness-docs.factor b/basis/compiler/cfg/liveness/liveness-docs.factor index efbb1d5e9e..ce1c70fb0d 100644 --- a/basis/compiler/cfg/liveness/liveness-docs.factor +++ b/basis/compiler/cfg/liveness/liveness-docs.factor @@ -43,7 +43,7 @@ HELP: live-ins { $see-also compute-live-sets } ; HELP: live-outs -{ $var-description "Hash that maps from basic blocks to sets of vregs that are live after execution leaves the block." } ; +{ $var-description "Hash that maps from basic blocks to sets of vregs that are live after execution leaves the block. The data is computed by " { $link compute-live-sets } } ; HELP: lookup-base-pointer { $values { "vreg" "vreg" } { "vreg/f" { $maybe "vreg" } } } diff --git a/basis/compiler/constants/constants-docs.factor b/basis/compiler/constants/constants-docs.factor index 287f8adf06..5ac2088a06 100644 --- a/basis/compiler/constants/constants-docs.factor +++ b/basis/compiler/constants/constants-docs.factor @@ -1,6 +1,9 @@ -USING: compiler.codegen.relocation help.markup help.syntax math ; +USING: compiler.codegen.relocation help.markup help.syntax math vm ; IN: compiler.constants +HELP: context-callstack-save-offset +{ $description "Offset in bytes in the " { $link context } " struct to where the c callstack is saved." } ; + HELP: rt-cards-offset { $description "Relocation offset type for the cards table." } { $see-also rel-cards-offset } ; diff --git a/basis/compiler/tree/propagation/simple/simple-docs.factor b/basis/compiler/tree/propagation/simple/simple-docs.factor index 0c388c8dd7..083c291fb8 100644 --- a/basis/compiler/tree/propagation/simple/simple-docs.factor +++ b/basis/compiler/tree/propagation/simple/simple-docs.factor @@ -11,6 +11,10 @@ HELP: output-value-infos { $description "Computes what the output value infos for a #call node should be." } { $see-also value-info-state } ; +HELP: propagate-predicate +{ $values { "#call" #call } { "word" word } { "infos" sequence } } +{ $description "We need to force the caller word to recompile when the class is redefined, since now we're making assumptions but the class definition itself." } ; + ARTICLE: "compiler.tree.propagation.simple" "Propagation for straight-line code" "Propagation for straight-line code" ; diff --git a/basis/compiler/tree/propagation/simple/simple-tests.factor b/basis/compiler/tree/propagation/simple/simple-tests.factor index 13ab4a51c8..c06afffd82 100644 --- a/basis/compiler/tree/propagation/simple/simple-tests.factor +++ b/basis/compiler/tree/propagation/simple/simple-tests.factor @@ -112,3 +112,43 @@ cpu x86.64? [ full-interval-and-bignum-literal setup-value-infos V{ 0 1 } V{ 2 } \ mod call-outputs-quot-of-word ] unit-test + +! (fold-call) +{ + { + T{ value-info-state + { class fixnum } + { interval + T{ interval { from { 5 t } } { to { 5 t } } } + } + { literal 5 } + { literal? t } + } + } +} [ + { 2 3 "hello" } [ ] map setup-value-infos + { 0 1 } { 2 } \ + <#call> dup word>> (fold-call) +] unit-test + +{ + { + T{ value-info-state + { class object } + { interval full-interval } + } + } +} [ + { 2 "hello" } [ ] map setup-value-infos { 0 1 } { 2 } \ + + <#call> (fold-call2) +] unit-test + +! foldable-call? +{ t f f t } [ + { 2 3 "hello" } [ ] map setup-value-infos + { 0 1 } { 2 } \ + <#call> foldable-call? + { 0 2 } { 2 } \ + <#call> foldable-call? + number 1array setup-value-infos + { 0 } { 1 } \ >fixnum <#call> foldable-call? + "mamma mia" 1array setup-value-infos + { 0 } { 1 } \ >fixnum <#call> foldable-call? +] unit-test