Author: Maciej Fijalkowski <[email protected]>
Branch: result-in-resops
Changeset: r58523:30128f37f1fe
Date: 2012-10-27 23:48 +0200
http://bitbucket.org/pypy/pypy/changeset/30128f37f1fe/
Log: flush operations before jump or finish. not completely sure how it
was done before
diff --git a/pypy/jit/metainterp/optimizeopt/heap.py
b/pypy/jit/metainterp/optimizeopt/heap.py
--- a/pypy/jit/metainterp/optimizeopt/heap.py
+++ b/pypy/jit/metainterp/optimizeopt/heap.py
@@ -25,6 +25,8 @@
# value pending in the ResOperation is *not* visible in
# 'cached_fields'.
#
+
+ # XXXX kill dicts here
self._cached_fields = {}
self._cached_fields_getfield_op = {}
self._lazy_setfield = None
@@ -32,8 +34,8 @@
def do_setfield(self, optheap, op):
# Update the state with the SETFIELD_GC/SETARRAYITEM_GC operation 'op'.
- structvalue = optheap.getvalue(op.getarg(0))
- fieldvalue = optheap.getvalue(op.getarglist()[-1])
+ structvalue = optheap.getforwarded(op.getarg(0))
+ fieldvalue = optheap.getforwarded(op.getarglist()[-1])
if self.possible_aliasing(optheap, structvalue):
self.force_lazy_setfield(optheap)
assert not self.possible_aliasing(optheap, structvalue)
@@ -44,7 +46,7 @@
optheap.optimizer.ensure_imported(cached_fieldvalue)
cached_fieldvalue = self._cached_fields.get(structvalue, None)
- if not fieldvalue.same_value(cached_fieldvalue):
+ if not optheap.optimizer.same_value(fieldvalue, cached_fieldvalue):
# common case: store the 'op' as lazy_setfield, and register
# myself in the optheap's _lazy_setfields_and_arrayitems list
self._lazy_setfield = op
@@ -94,14 +96,15 @@
# possible aliasing).
self.clear()
self._lazy_setfield = None
- optheap.next_optimization.propagate_forward(op)
+ # XXX should we push it through the optimizer chain?
+ optheap.optimizer.emit_operation(op)
if not can_cache:
return
# Once it is done, we can put at least one piece of information
# back in the cache: the value of this particular structure's
# field.
- structvalue = optheap.getvalue(op.getarg(0))
- fieldvalue = optheap.getvalue(op.getarglist()[-1])
+ structvalue = optheap.getforwarded(op.getarg(0))
+ fieldvalue = optheap.getforwarded(op.getarglist()[-1])
self.remember_field_value(structvalue, fieldvalue, op)
elif not can_cache:
self.clear()
@@ -294,7 +297,7 @@
# of virtualref_info and virtualizable_info are not gcptrs.
def turned_constant(self, value):
- value = self.getforwarded(value)
+ newvalue = self.getforwarded(value)
for cf in self.cached_fields.itervalues():
cf.turned_constant(newvalue, value)
for submap in self.cached_arrayitems.itervalues():
@@ -394,6 +397,7 @@
optimize_GETFIELD_GC_PURE_r = optimize_GETFIELD_GC_PURE_i
def optimize_SETFIELD_GC(self, op):
+ # XXX this is just debugging, should we comment it out somehow?
if op.type == INT:
op_key = create_resop_1(rop.GETFIELD_GC_PURE_i, 0, op.getarg(0),
op.getdescr())
diff --git a/pypy/jit/metainterp/optimizeopt/optimizer.py
b/pypy/jit/metainterp/optimizeopt/optimizer.py
--- a/pypy/jit/metainterp/optimizeopt/optimizer.py
+++ b/pypy/jit/metainterp/optimizeopt/optimizer.py
@@ -158,13 +158,6 @@
return not op.nonnull()
return False
- def same_value(self, other):
- if not other:
- return False
- if self.is_constant() and other.is_constant():
- return self.box.same_constant(other.box)
- return self is other
-
def make_constant_class(self, classbox, guardop, index):
assert self.level < LEVEL_KNOWNCLASS
self.known_class = classbox
@@ -469,6 +462,15 @@
if not op.is_constant():
op._forwarded = ConstInt(intvalue)
+ def same_value(self, op1, op2):
+ if op1 is op2:
+ return True
+ if op2 is None:
+ return False
+ if op1.is_constant() and op2.is_constant():
+ return op1.same_constant(op2)
+ return False
+
def new_ptr_box(self):
return self.cpu.ts.BoxRef()
@@ -539,6 +541,7 @@
dispatch_opt(self, op)
def emit_operation(self, op):
+ op = self.getforwarded(op)
assert op.getopnum() not in opgroups.CALL_PURE
assert not op._forwarded
if isinstance(op, Const):
@@ -617,9 +620,6 @@
# self.emit_operation(op)
# FIXME: Is this still needed?
- def optimize_DEBUG_MERGE_POINT(self, op):
- self.emit_operation(op)
-
def optimize_GETARRAYITEM_GC_PURE_i(self, op):
indexvalue = self.getvalue(op.getarg(1))
if indexvalue.is_constant():
diff --git a/pypy/jit/metainterp/optimizeopt/rewrite.py
b/pypy/jit/metainterp/optimizeopt/rewrite.py
--- a/pypy/jit/metainterp/optimizeopt/rewrite.py
+++ b/pypy/jit/metainterp/optimizeopt/rewrite.py
@@ -538,6 +538,14 @@
optimize_SAME_AS_r = optimize_SAME_AS_i
optimize_SAME_AS_f = optimize_SAME_AS_i
+ def optimize_JUMP(self, op):
+ self.optimizer.flush()
+ return op
+
+ def optimize_FINISH(self, op):
+ self.optimizer.flush()
+ return op
+
#dispatch_opt = make_dispatcher_method(OptRewrite, 'optimize_',
# default=OptRewrite.emit_operation)
#optimize_guards = _findall(OptRewrite, 'optimize_', 'GUARD')
diff --git a/pypy/jit/metainterp/optimizeopt/virtualize.py
b/pypy/jit/metainterp/optimizeopt/virtualize.py
--- a/pypy/jit/metainterp/optimizeopt/virtualize.py
+++ b/pypy/jit/metainterp/optimizeopt/virtualize.py
@@ -458,8 +458,7 @@
fieldvalue = self.getforwarded(op.getarg(1))
value.setfield(op.getdescr(), fieldvalue)
else:
- xxx
- value.ensure_nonnull()
+ value.setknownnonnull(True)
return op
def optimize_NEW_WITH_VTABLE(self, op):
diff --git a/pypy/jit/metainterp/resoperation.py
b/pypy/jit/metainterp/resoperation.py
--- a/pypy/jit/metainterp/resoperation.py
+++ b/pypy/jit/metainterp/resoperation.py
@@ -478,9 +478,9 @@
# XXX this is a hack kill me
import sys
co_fname = sys._getframe(1).f_code.co_filename
- if co_fname.endswith('resume.py') or
co_fname.endswith('optimizeopt/util.py') or 'backend/llgraph' in co_fname or
'backend/test' in co_fname or 'test/test_util' in co_fname:
+ if co_fname.endswith('resume.py') or
co_fname.endswith('optimizeopt/util.py') or 'backend/llgraph' in co_fname or
'backend/test' in co_fname or 'test/test_util' in co_fname or
co_fname.endswith('heap.py'):
return object.__hash__(self)
- raise Exception("Should not hash resops, use get/set extra instead")
+ raise Exception("Should not hash resops")
def _get_hash_(self):
""" rpython level implementation of hash, cache it because computations
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit