[pypy-commit] pypy optresult: pass the first virtual test
fijal
noreply at buildbot.pypy.org
Fri Mar 6 17:13:32 CET 2015
Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: optresult
Changeset: r76258:1f70e61d2780
Date: 2015-03-06 18:13 +0200
http://bitbucket.org/pypy/pypy/changeset/1f70e61d2780/
Log: pass the first virtual test
diff --git a/rpython/jit/metainterp/optimizeopt/info.py b/rpython/jit/metainterp/optimizeopt/info.py
--- a/rpython/jit/metainterp/optimizeopt/info.py
+++ b/rpython/jit/metainterp/optimizeopt/info.py
@@ -41,6 +41,7 @@
class InstancePtrInfo(NonNullPtrInfo):
_attrs_ = ('_known_class', '_is_virtual', '_fields')
+ _fields = None
def __init__(self, known_class=None, is_virtual=False):
self._known_class = known_class
@@ -57,6 +58,17 @@
return newop
return op
+ def setfield_virtual(self, descr, op):
+ if self._fields is None:
+ self._fields = {}
+ self._fields[descr] = op
+
+ def getfield_virtual(self, descr):
+ return self._fields.get(descr, None)
+
+ def is_virtual(self):
+ return self._is_virtual
+
def get_known_class(self, cpu):
return self._known_class
diff --git a/rpython/jit/metainterp/optimizeopt/virtualize.py b/rpython/jit/metainterp/optimizeopt/virtualize.py
--- a/rpython/jit/metainterp/optimizeopt/virtualize.py
+++ b/rpython/jit/metainterp/optimizeopt/virtualize.py
@@ -665,22 +665,24 @@
return False
def optimize_GETFIELD_GC_I(self, op):
- value = self.getvalue(op.getarg(0))
+ opinfo = self.getptrinfo(op.getarg(0))
# If this is an immutable field (as indicated by op.is_always_pure())
# then it's safe to reuse the virtual's field, even if it has been
# forced, because it should never be written to again.
- if value.is_forced_virtual() and op.is_always_pure():
- fieldvalue = value.getfield(op.getdescr(), None)
- if fieldvalue is not None:
- self.make_equal_to(op, fieldvalue)
- return
- if value.is_virtual():
- assert isinstance(value, AbstractVirtualValue)
- fieldvalue = value.getfield(op.getdescr(), None)
- if fieldvalue is None:
+ if op.is_always_pure():
+ if value.is_forced_virtual() and op.is_always_pure():
+ fieldvalue = value.getfield(op.getdescr(), None)
+ if fieldvalue is not None:
+ self.make_equal_to(op, fieldvalue)
+ return
+ if opinfo and opinfo.is_virtual():
+ fieldop = opinfo.getfield_virtual(op.getdescr())
+ if fieldop is None:
+ xxx
fieldvalue = self.optimizer.new_const(op.getdescr())
- self.make_equal_to(op, fieldvalue)
+ self.make_equal_to(op, fieldop)
else:
+ yyyy
value.ensure_nonnull()
self.emit_operation(op)
optimize_GETFIELD_GC_R = optimize_GETFIELD_GC_I
@@ -693,11 +695,11 @@
optimize_GETFIELD_GC_PURE_F = optimize_GETFIELD_GC_I
def optimize_SETFIELD_GC(self, op):
- value = self.getvalue(op.getarg(0))
- if value.is_virtual():
- fieldvalue = self.getvalue(op.getarg(1))
- value.setfield(op.getdescr(), fieldvalue)
+ opinfo = self.getptrinfo(op.getarg(0))
+ if opinfo is not None and opinfo.is_virtual():
+ opinfo.setfield_virtual(op.getdescr(), op.getarg(1))
else:
+ xxx
value.ensure_nonnull()
self.emit_operation(op)
More information about the pypy-commit
mailing list