[pypy-commit] pypy stmgc-c7: Test that setfield_gc maintain their original stm_location when
arigo
noreply at buildbot.pypy.org
Mon Apr 21 18:07:43 CEST 2014
Author: Armin Rigo <arigo at tunes.org>
Branch: stmgc-c7
Changeset: r70812:f76f5363798a
Date: 2014-04-21 18:06 +0200
http://bitbucket.org/pypy/pypy/changeset/f76f5363798a/
Log: Test that setfield_gc maintain their original stm_location when
delayed by optimization
diff --git a/rpython/jit/metainterp/history.py b/rpython/jit/metainterp/history.py
--- a/rpython/jit/metainterp/history.py
+++ b/rpython/jit/metainterp/history.py
@@ -760,13 +760,6 @@
# ____________________________________________________________
-
-class StmLocation(object):
- def __init__(self, num, ref):
- self.num = num
- self.ref = ref
-
-
class History(object):
def __init__(self, metainterp_sd):
self.inputargs = None
diff --git a/rpython/jit/metainterp/optimizeopt/test/test_stm.py b/rpython/jit/metainterp/optimizeopt/test/test_stm.py
--- a/rpython/jit/metainterp/optimizeopt/test/test_stm.py
+++ b/rpython/jit/metainterp/optimizeopt/test/test_stm.py
@@ -270,8 +270,17 @@
"""
self.optimize_loop(ops, expected, expected_preamble=preamble)
-
-
-
-
-
+ def test_stm_location_1(self):
+ ops = """
+ [i1, p1]
+ setfield_gc(p1, i1, descr=adescr) {81}
+ call(i1, descr=nonwritedescr) {90}
+ jump(i1, p1)
+ """
+ expected = """
+ [i1, p1]
+ call(i1, descr=nonwritedescr) {90}
+ setfield_gc(p1, i1, descr=adescr) {81}
+ jump(i1, p1)
+ """
+ self.optimize_loop(ops, expected)
diff --git a/rpython/jit/metainterp/optimizeopt/test/test_util.py b/rpython/jit/metainterp/optimizeopt/test/test_util.py
--- a/rpython/jit/metainterp/optimizeopt/test/test_util.py
+++ b/rpython/jit/metainterp/optimizeopt/test/test_util.py
@@ -377,7 +377,8 @@
assert box1.__class__ == box2.__class__
remap[box2] = box1
assert equaloplists(optimized.operations,
- expected.operations, False, remap, text_right)
+ expected.operations, False, remap, text_right,
+ expect_stm_locations_from_right=True)
def _do_optimize_loop(self, loop, call_pure_results,
stm_info):
diff --git a/rpython/jit/metainterp/optimizeopt/util.py b/rpython/jit/metainterp/optimizeopt/util.py
--- a/rpython/jit/metainterp/optimizeopt/util.py
+++ b/rpython/jit/metainterp/optimizeopt/util.py
@@ -125,7 +125,7 @@
# ____________________________________________________________
def equaloplists(oplist1, oplist2, strict_fail_args=True, remap={},
- text_right=None):
+ text_right=None, expect_stm_locations_from_right=False):
# try to use the full width of the terminal to display the list
# unfortunately, does not work with the default capture method of py.test
# (which is fd), you you need to use either -s or --capture=sys, else you
@@ -184,5 +184,8 @@
break
else:
assert False
+ if expect_stm_locations_from_right and op2.stm_location is not None:
+ assert op1.stm_location is not None
+ assert op1.stm_location.num == op2.stm_location.num
assert len(oplist1) == len(oplist2)
return True
diff --git a/rpython/jit/metainterp/pyjitpl.py b/rpython/jit/metainterp/pyjitpl.py
--- a/rpython/jit/metainterp/pyjitpl.py
+++ b/rpython/jit/metainterp/pyjitpl.py
@@ -12,7 +12,7 @@
from rpython.jit.metainterp.jitprof import EmptyProfiler
from rpython.jit.metainterp.logger import Logger
from rpython.jit.metainterp.optimizeopt.util import args_dict
-from rpython.jit.metainterp.resoperation import rop
+from rpython.jit.metainterp.resoperation import rop, StmLocation
from rpython.rlib import nonconst, rstack
from rpython.rlib.debug import debug_start, debug_stop, debug_print, make_sure_not_resized
from rpython.rlib.jit import Counters
@@ -1130,7 +1130,7 @@
idx_num, idx_ref = report_location
num = greenkey[idx_num].getint()
ref = greenkey[idx_ref].getref_base()
- location = history.StmLocation(num, ref)
+ location = StmLocation(num, ref)
self.metainterp.history.stm_location = location
@arguments("box", "label")
@@ -2089,8 +2089,8 @@
#
if (self.staticdata.config.translation.stm and
isinstance(key, compile.ResumeGuardDescr)):
- location = history.StmLocation(key.stm_location_int,
- key.stm_location_ref)
+ location = StmLocation(key.stm_location_int,
+ key.stm_location_ref)
self.history.stm_location = location
#
self.interpret()
diff --git a/rpython/jit/metainterp/resoperation.py b/rpython/jit/metainterp/resoperation.py
--- a/rpython/jit/metainterp/resoperation.py
+++ b/rpython/jit/metainterp/resoperation.py
@@ -371,6 +371,12 @@
self._args[i] = box
+class StmLocation(object):
+ def __init__(self, num, ref):
+ self.num = num
+ self.ref = ref
+
+
# ____________________________________________________________
_oplist = [
diff --git a/rpython/jit/tool/oparser.py b/rpython/jit/tool/oparser.py
--- a/rpython/jit/tool/oparser.py
+++ b/rpython/jit/tool/oparser.py
@@ -7,7 +7,7 @@
from rpython.jit.tool.oparser_model import get_model
from rpython.jit.metainterp.resoperation import rop, ResOperation, \
ResOpWithDescr, N_aryOp, \
- UnaryOp, PlainResOp
+ UnaryOp, PlainResOp, StmLocation
r_skip_thread = re.compile(r'^(\d+#)?')
@@ -223,6 +223,8 @@
if rop._GUARD_FIRST <= opnum <= rop._GUARD_LAST:
i = line.find('[', endnum) + 1
j = line.find(']', i)
+ if j >= 0:
+ endnum = j + 1
if (i <= 0 or j <= 0) and not self.nonstrict:
raise ParseError("missing fail_args for guard operation")
fail_args = []
@@ -251,7 +253,16 @@
if descr is None and self.invent_fail_descr:
descr = self.original_jitcell_token
- return opnum, args, descr, fail_args
+ if line.find('{', endnum) >= 0:
+ i = line.find('{', endnum) + 1
+ j = line.find('}', i)
+ if j < 0:
+ raise ParseError("missing '}' after '{'")
+ stm_location = int(line[i:j].strip())
+ else:
+ stm_location = None
+
+ return opnum, args, descr, fail_args, stm_location
def create_op(self, opnum, args, result, descr):
if opnum == ESCAPE_OP.OPNUM:
@@ -271,7 +282,7 @@
res, op = line.split("=", 1)
res = res.strip()
op = op.strip()
- opnum, args, descr, fail_args = self.parse_op(op)
+ opnum, args, descr, fail_args, stm_location = self.parse_op(op)
if res in self.vars:
raise ParseError("Double assign to var %s in line: %s" % (res, line))
rvar = self.box_for_var(res)
@@ -279,13 +290,17 @@
res = self.create_op(opnum, args, rvar, descr)
if fail_args is not None:
res.setfailargs(fail_args)
+ if stm_location is not None:
+ res.stm_location = StmLocation(stm_location, '?')
return res
def parse_op_no_result(self, line):
- opnum, args, descr, fail_args = self.parse_op(line)
+ opnum, args, descr, fail_args, stm_location = self.parse_op(line)
res = self.create_op(opnum, args, None, descr)
if fail_args is not None:
res.setfailargs(fail_args)
+ if stm_location is not None:
+ res.stm_location = StmLocation(stm_location, '?')
return res
def parse_next_op(self, line):
diff --git a/rpython/jit/tool/test/test_oparser.py b/rpython/jit/tool/test/test_oparser.py
--- a/rpython/jit/tool/test/test_oparser.py
+++ b/rpython/jit/tool/test/test_oparser.py
@@ -184,7 +184,7 @@
def test_attach_comment_to_loop(self):
loop = self.parse(self.example_loop_log, no_namespace=True)
- assert loop.comment == ' # bridge out of Guard12, 6 ops'
+ assert loop.comment.lstrip() == '# bridge out of Guard12, 6 ops'
def test_parse_new_with_comma(self):
# this is generated by PYPYJITLOG, check that we can handle it
@@ -233,6 +233,17 @@
assert len(loop.operations) == 2
assert loop.last_offset == 30
+ def test_stm_location(self):
+ x = """
+ [i0]
+ p1 = escape(i0) {42}
+ p2 = int_add(i0, i0) {81}
+ """
+ loop = self.parse(x)
+ [op0, op1] = loop.operations
+ assert op0.stm_location.num == 42
+ assert op1.stm_location.num == 81
+
class TestOpParser(BaseTestOparser):
More information about the pypy-commit
mailing list