From b89a305ef73822e35b32939761fa66b2358ac980 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Lindqvist?= Date: Tue, 15 Nov 2016 03:04:48 +0100 Subject: [PATCH] compiler.cfg.linear-scan.assignment: correct representation used when spilling Previously the rep-of word was used. But as the vregs representation can change, you need to instead use the representation it uas as the spill point. --- .../assignment/assignment-tests.factor | 2 +- .../cfg/linear-scan/assignment/assignment.factor | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/basis/compiler/cfg/linear-scan/assignment/assignment-tests.factor b/basis/compiler/cfg/linear-scan/assignment/assignment-tests.factor index ed62a964dc..354958a40b 100644 --- a/basis/compiler/cfg/linear-scan/assignment/assignment-tests.factor +++ b/basis/compiler/cfg/linear-scan/assignment/assignment-tests.factor @@ -179,7 +179,7 @@ IN: compiler.cfg.linear-scan.assignment.tests } ; { - V{ { RDI float-rep T{ spill-slot } } } + V{ { RDI int-rep T{ spill-slot } } } } [ f f cfg set H{ } clone spill-slots set diff --git a/basis/compiler/cfg/linear-scan/assignment/assignment.factor b/basis/compiler/cfg/linear-scan/assignment/assignment.factor index 3225b583b8..1ce2dd3dbe 100644 --- a/basis/compiler/cfg/linear-scan/assignment/assignment.factor +++ b/basis/compiler/cfg/linear-scan/assignment/assignment.factor @@ -112,14 +112,19 @@ RENAMING: assign [ vreg>reg ] [ vreg>reg ] [ vreg>reg ] [ pending-interval-heap get heap-members ] 2dip '[ _ _ spill-required? ] filter ; -: spill/reload ( interval -- {reg,rep,slot} ) - [ reg>> ] [ vreg>> dup rep-of dup swapd assign-spill-slot ] bi 3array ; +: rep-at-insn ( n interval -- rep ) + (find-use) [ def-rep>> ] [ use-rep>> ] bi or ; -: spill/reloads ( intervals -- spill/reloads ) - [ spill/reload ] map ; +: spill/reload ( n interval -- {reg,rep,slot} ) + [ rep-at-insn ] keep [ reg>> ] [ vreg>> ] bi + pick assign-spill-slot swapd 3array ; + +: spill/reloads ( n intervals -- spill/reloads ) + [ spill/reload ] with map ; : spill/reloads-for-call-gc ( ##call-gc -- spill-seq ) - [ gc-map>> gc-roots>> ] [ insn#>> ] bi spill-intervals spill/reloads ; + [ gc-map>> gc-roots>> ] [ insn#>> ] bi + [ spill-intervals ] keep swap spill/reloads ; : emit-##call-gc ( insn -- ) dup spill/reloads-for-call-gc