[pypy-commit] pypy resume-refactor: (fijal, rguillebert) Deal with duplicates in inputframes
fijal
noreply at buildbot.pypy.org
Tue Jan 14 15:24:05 CET 2014
Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: resume-refactor
Changeset: r68669:3d4afd8a844a
Date: 2014-01-14 15:23 +0100
http://bitbucket.org/pypy/pypy/changeset/3d4afd8a844a/
Log: (fijal, rguillebert) Deal with duplicates in inputframes
diff --git a/rpython/jit/backend/llsupport/assembler.py b/rpython/jit/backend/llsupport/assembler.py
--- a/rpython/jit/backend/llsupport/assembler.py
+++ b/rpython/jit/backend/llsupport/assembler.py
@@ -118,12 +118,14 @@
coeff = 1
else:
coeff = 2
+ all = {}
for i, frame in enumerate(inputframes):
inputlocs = loc_positions[i]
assert len(inputlocs) == len(frame)
for j, item in enumerate(frame):
- if item is None or isinstance(item, Const):
+ if item is None or isinstance(item, Const) or item in all:
continue
+ all[item] = None
pos = inputlocs[j]
if pos < GPR_REGS:
locs.append(self.cpu.gen_regs[pos])
diff --git a/rpython/jit/backend/llsupport/regalloc.py b/rpython/jit/backend/llsupport/regalloc.py
--- a/rpython/jit/backend/llsupport/regalloc.py
+++ b/rpython/jit/backend/llsupport/regalloc.py
@@ -646,6 +646,7 @@
"""
locs = []
base_ofs = self.assembler.cpu.get_baseofs_of_frame_field()
+
for box in inputargs:
assert isinstance(box, Box)
loc = self.fm.get_new_loc(box)
diff --git a/rpython/jit/backend/resumebuilder.py b/rpython/jit/backend/resumebuilder.py
--- a/rpython/jit/backend/resumebuilder.py
+++ b/rpython/jit/backend/resumebuilder.py
@@ -71,16 +71,19 @@
self.virtuals = {}
if inputlocs is not None:
i = 0
+ all = {}
for frame_pos, frame in enumerate(inputframes):
for pos_in_frame, box in enumerate(frame):
- if box is None:
+ if box is None or isinstance(box, Const) or box in all:
loc_pos = -1
else:
loc_pos = inputlocs[i].get_jitframe_position()
i += 1
self.frontend_pos[box] = (ConstInt(frame_pos),
ConstInt(pos_in_frame))
- self.current_attachment[box] = loc_pos
+ all[box] = None
+ if box not in self.current_attachment:
+ self.current_attachment[box] = loc_pos
def process(self, op):
if op.getopnum() == rop.RESUME_PUT:
@@ -144,16 +147,21 @@
def flatten(inputframes):
count = 0
+ all = {}
for frame in inputframes:
for x in frame:
- if x is not None and not isinstance(x, Const):
+ if x is not None and not isinstance(x, Const) and x not in all:
count += 1
+ all[x] = None
inputargs = [None] * count
pos = 0
+ all = {}
for frame in inputframes:
for item in frame:
- if item is not None and not isinstance(item, Const):
+ if (item is not None and not isinstance(item, Const) and
+ item not in all):
inputargs[pos] = item
+ all[item] = None
pos += 1
return inputargs
diff --git a/rpython/jit/metainterp/resume2.py b/rpython/jit/metainterp/resume2.py
--- a/rpython/jit/metainterp/resume2.py
+++ b/rpython/jit/metainterp/resume2.py
@@ -161,40 +161,50 @@
AbstractResumeReader.__init__(self)
def store_int_box(self, res, pos, miframe, i, jitframe_pos):
- if jitframe_pos == -1:
+ if jitframe_pos in self.cache:
+ box = self.cache[jitframe_pos]
+ elif jitframe_pos == -1:
return
- if jitframe_pos >= 0:
+ elif jitframe_pos >= 0:
box = BoxInt(self.metainterp.cpu.get_int_value(self.deadframe,
jitframe_pos))
elif jitframe_pos <= -2:
box = self.consts[-jitframe_pos - 2]
miframe.registers_i[i] = box
+ self.cache[jitframe_pos] = box
res[-1][pos] = box
def store_ref_box(self, res, pos, miframe, i, jitframe_pos):
- if jitframe_pos == -1:
+ if jitframe_pos in self.cache:
+ box = self.cache[jitframe_pos]
+ elif jitframe_pos == -1:
return
- if jitframe_pos >= 0:
+ elif jitframe_pos >= 0:
box = BoxPtr(self.metainterp.cpu.get_ref_value(self.deadframe,
jitframe_pos))
elif jitframe_pos <= -2:
box = self.consts[-jitframe_pos - 2]
miframe.registers_r[i] = box
+ self.cache[jitframe_pos] = box
res[-1][pos] = box
def store_float_box(self, res, pos, miframe, i, jitframe_pos):
- if jitframe_pos == -1:
+ if jitframe_pos in self.cache:
+ box = self.cache[jitframe_pos]
+ elif jitframe_pos == -1:
return
- if jitframe_pos >= 0:
+ elif jitframe_pos >= 0:
box = BoxFloat(self.metainterp.cpu.get_float_value(self.deadframe,
jitframe_pos))
elif jitframe_pos <= -2:
box = self.consts[-jitframe_pos - 2]
miframe.registers_f[i] = box
+ self.cache[jitframe_pos] = box
res[-1][pos] = box
def finish(self):
res = []
+ self.cache = {}
for frame in self.framestack:
jitcode = frame.jitcode
res.append([None] * jitcode.num_regs())
@@ -210,6 +220,7 @@
for i in range(jitcode.num_regs_f()):
self.store_float_box(res, pos, miframe, i, frame.registers[pos])
pos += 1
+ self.cache = None
return res, [f.registers for f in self.framestack]
def rebuild_from_resumedata(metainterp, deadframe, faildescr):
More information about the pypy-commit
mailing list