[pypy-commit] pypy resume-refactor: Adjust tests for the real interface of bhimpl_new_with_vtable
fijal
noreply at buildbot.pypy.org
Mon Jan 27 15:38:59 CET 2014
Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: resume-refactor
Changeset: r68961:a6c79f403639
Date: 2014-01-27 15:38 +0100
http://bitbucket.org/pypy/pypy/changeset/a6c79f403639/
Log: Adjust tests for the real interface of bhimpl_new_with_vtable
diff --git a/rpython/jit/backend/llgraph/runner.py b/rpython/jit/backend/llgraph/runner.py
--- a/rpython/jit/backend/llgraph/runner.py
+++ b/rpython/jit/backend/llgraph/runner.py
@@ -6,6 +6,7 @@
from rpython.jit.metainterp.history import AbstractDescr
from rpython.jit.metainterp.history import Const, getkind
from rpython.jit.metainterp.history import INT, REF, FLOAT, VOID, Box
+from rpython.jit.metainterp.history import getkind
from rpython.jit.metainterp.resoperation import rop
from rpython.jit.codewriter import longlong, heaptracker
from rpython.jit.codewriter.effectinfo import EffectInfo
@@ -36,6 +37,7 @@
def __init__(self, mapping, frontend_liveness, descr, inputargs, inputlocs):
self.liveness = LivenessAnalyzer()
self.numbering = {}
+ self.deps = {}
self.mapping = mapping
self.framestack = []
if inputlocs is not None:
@@ -68,15 +70,24 @@
def process_resume_set_pc(self, op):
pass
+ def process_resume_new_with_vtable(self, op):
+ self._add_box_to_numbering(op.result)
+ self.deps[op.result] = {}
+
def process_resume_setfield_gc(self, op):
- xxx
+ self._add_box_to_numbering(op.getarg(1))
+ self.deps[op.getarg(0)][op.getdescr()] = op.getarg(1)
+
+ def _add_box_to_numbering(self, box):
+ if box not in self.deps:
+ if self.mapping(box) not in self.numbering:
+ self.numbering[self.mapping(box)] = len(self.numbering)
def process_resume_put(self, op):
box = op.getarg(0)
if isinstance(box, Const):
return
- if self.mapping(box) not in self.numbering:
- self.numbering[self.mapping(box)] = len(self.numbering)
+ self._add_box_to_numbering(box)
frame_pos = op.getarg(1).getint()
pos_in_frame = op.getarg(2).getint()
self.framestack[frame_pos].registers[pos_in_frame] = box
@@ -86,13 +97,23 @@
frontend_pos = op.getarg(1).getint()
self.framestack[frame_pos].registers[frontend_pos] = None
+ def extend_from_virtual(self, r, box):
+ for v in sorted(self.deps[box].values()):
+ if v in self.deps:
+ self.extend_from_virtual(r, v)
+ else:
+ r.append(self.mapping(v))
+
def get_numbering(self, mapping, op):
res = []
all = {}
for frame in self.framestack:
for reg in frame.registers:
if reg is not None and isinstance(reg, Box) and reg not in all:
- res.append(mapping(reg))
+ if reg in self.deps:
+ self.extend_from_virtual(res, reg)
+ else:
+ res.append(mapping(reg))
all[reg] = None
return res
diff --git a/rpython/jit/backend/llsupport/llmodel.py b/rpython/jit/backend/llsupport/llmodel.py
--- a/rpython/jit/backend/llsupport/llmodel.py
+++ b/rpython/jit/backend/llsupport/llmodel.py
@@ -23,10 +23,10 @@
def __init__(self, rtyper, stats, opts, translate_support_code=False,
gcdescr=None):
+ from rpython.jit.backend.llsupport.gc import get_ll_description
+
assert type(opts) is not bool
self.opts = opts
-
- from rpython.jit.backend.llsupport.gc import get_ll_description
AbstractCPU.__init__(self)
self.rtyper = rtyper
self.stats = stats
diff --git a/rpython/jit/resume/frontend.py b/rpython/jit/resume/frontend.py
--- a/rpython/jit/resume/frontend.py
+++ b/rpython/jit/resume/frontend.py
@@ -84,13 +84,13 @@
return val
def setfield_gc(self, struct, encoded_field_pos, fielddescr):
- if fielddescr.kind == INT:
+ if fielddescr.is_field_signed():
intval = self.getint(encoded_field_pos)
self.cpu.bh_setfield_gc_i(struct, intval, fielddescr)
- elif fielddescr.kind == REF:
+ elif fielddescr.is_pointer_field():
refval = self.getref(encoded_field_pos)
self.cpu.bh_setfield_gc_r(struct, refval, fielddescr)
- elif fielddescr.kind == FLOAT:
+ elif fielddescr.is_float_field():
xxx
def store_float_value(self, curbh, i, jitframe_pos):
diff --git a/rpython/jit/resume/reader.py b/rpython/jit/resume/reader.py
--- a/rpython/jit/resume/reader.py
+++ b/rpython/jit/resume/reader.py
@@ -1,6 +1,7 @@
from rpython.jit.metainterp.resoperation import rop
from rpython.jit.metainterp.history import ConstInt
+from rpython.jit.codewriter import heaptracker
from rpython.jit.resume import rescode
class ResumeFrame(object):
@@ -35,7 +36,8 @@
ConstInt(self.const_class))
def allocate_direct(self, cpu):
- return cpu.bh_new_with_vtable(self.const_class)
+ descr = heaptracker.vtable2descr(cpu, self.const_class)
+ return cpu.bh_new_with_vtable(self.const_class, descr)
class AbstractResumeReader(object):
""" A resume reader that can follow resume until given point. Consult
diff --git a/rpython/jit/resume/test/test_frontend.py b/rpython/jit/resume/test/test_frontend.py
--- a/rpython/jit/resume/test/test_frontend.py
+++ b/rpython/jit/resume/test/test_frontend.py
@@ -12,6 +12,7 @@
from rpython.jit.metainterp.resoperation import rop
from rpython.jit.codewriter.format import unformat_assembler
from rpython.jit.codewriter.codewriter import CodeWriter
+from rpython.jit.codewriter import heaptracker
from rpython.jit.backend.llgraph.runner import LLGraphCPU
from rpython.jit.metainterp.pyjitpl import MetaInterp, MetaInterpStaticData
from rpython.jit.metainterp.jitdriver import JitDriverStaticData
@@ -19,10 +20,15 @@
from rpython.jit.metainterp.jitexc import DoneWithThisFrameInt
from rpython.jit.metainterp.optimizeopt.util import equaloplists
from rpython.rlib.jit import JitDriver
+from rpython.rtyper.lltypesystem import rclass, lltype, llmemory
class Descr(AbstractDescr):
- pass
+ def is_pointer_field(self):
+ return self.kind == REF
+
+ def is_field_signed(self):
+ return self.kind == INT
class MockLoop(object):
pass
@@ -90,7 +96,7 @@
def bh_setfield_gc_r(self, struct, refval, fielddescr):
self.history.append(("setfield_gc_r", struct, refval, fielddescr))
- def bh_new_with_vtable(self, const_class):
+ def bh_new_with_vtable(self, const_class, descr):
self.history.append(("new_with_vtable", const_class))
return "new_with_vtable"
@@ -206,7 +212,10 @@
jitcode1.setup(num_regs_i=0, num_regs_r=1, num_regs_f=0)
builder = ResumeBytecodeBuilder()
descr = Descr()
- const_class = ConstInt(13)
+ cls = lltype.malloc(rclass.OBJECT_VTABLE, flavor='raw',
+ immortal=True)
+ cls_as_int = heaptracker.adr2int(llmemory.cast_ptr_to_adr(cls))
+ const_class = ConstInt(cls_as_int)
descr.global_descr_index = 0
builder.enter_frame(-1, jitcode1)
builder.resume_new(0, descr)
@@ -230,16 +239,24 @@
metainterp = MockMetaInterp()
metainterp.staticdata = MockStaticData([jitcode1], [descr, d2, d3])
metainterp.cpu = MockCPU()
+
+ class MockTracker(object):
+ pass
+
+ tr = MockTracker()
+ tr._all_size_descrs_with_vtable = [descr]
+ descr._corresponding_vtable = cls
+ metainterp.cpu.tracker = tr
metainterp.staticdata.cpu = metainterp.cpu
rebuild_from_resumedata(metainterp, "myframe", descr)
expected = [(rop.NEW, descr),
(rop.SETFIELD_GC, d2, AnyBox(), EqConstInt(1)),
- (rop.NEW_WITH_VTABLE, EqConstInt(13)),
+ (rop.NEW_WITH_VTABLE, EqConstInt(cls_as_int)),
(rop.SETFIELD_GC, d3, AnyBox(), AnyBox()),
(rop.RESUME_PUT, None, AnyBox(), EqConstInt(0),
EqConstInt(0))]
expected2 = [(rop.NEW, descr),
- (rop.NEW_WITH_VTABLE, EqConstInt(13)),
+ (rop.NEW_WITH_VTABLE, EqConstInt(cls_as_int)),
(rop.SETFIELD_GC, d3, AnyBox(), AnyBox()),
(rop.SETFIELD_GC, d2, AnyBox(), EqConstInt(1)),
(rop.RESUME_PUT, None, AnyBox(), EqConstInt(0),
@@ -251,14 +268,14 @@
hist = metainterp.cpu.history
dir_expected2 = [
("new", descr),
- ("new_with_vtable", 13),
+ ("new_with_vtable", cls_as_int),
("setfield_gc_r", "new", "new_with_vtable", d3),
("setfield_gc_i", "new", 1, d2),
]
dir_expected = [
("new", descr),
("setfield_gc_i", "new", 1, d2),
- ("new_with_vtable", 13),
+ ("new_with_vtable", cls_as_int),
("setfield_gc_r", "new", "new_with_vtable", d3),
]
assert hist == dir_expected or hist == dir_expected2
More information about the pypy-commit
mailing list