[pypy-svn] r65793 - in pypy/branch/pyjitpl5/pypy/jit: backend/cli backend/llgraph backend/llvm backend/minimal backend/x86 metainterp metainterp/test
arigo at codespeak.net
arigo at codespeak.net
Tue Jun 16 18:50:39 CEST 2009
Author: arigo
Date: Tue Jun 16 18:50:36 2009
New Revision: 65793
Modified:
pypy/branch/pyjitpl5/pypy/jit/backend/cli/method.py
pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/llimpl.py
pypy/branch/pyjitpl5/pypy/jit/backend/llvm/compile.py
pypy/branch/pyjitpl5/pypy/jit/backend/minimal/runner.py
pypy/branch/pyjitpl5/pypy/jit/backend/x86/assembler.py
pypy/branch/pyjitpl5/pypy/jit/backend/x86/regalloc.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/codewriter.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/graphpage.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/optimize.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/optimize2.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/pyjitpl.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/resoperation.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/simple_optimize.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/test/oparser.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_oparser.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_optimize2.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_tl.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_vable_optimize.py
Log:
Remove the 'guard_nonvirtualized' operation.
We'll introduce a different way to do this...
Modified: pypy/branch/pyjitpl5/pypy/jit/backend/cli/method.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/cli/method.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/cli/method.py Tue Jun 16 18:50:36 2009
@@ -601,9 +601,6 @@
self.il.Emit(OpCodes.Newarr, item_clitype)
self.store_result(op)
- def emit_op_guard_nonvirtualized(self, op):
- pass
-
def lltype_only(self, op):
print 'Operation %s is lltype specific, should not get here!' % op.getopname()
raise NotImplementedError
Modified: pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/llimpl.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/llimpl.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/llimpl.py Tue Jun 16 18:50:36 2009
@@ -114,7 +114,6 @@
'guard_class' : (('ptr', 'ptr'), None),
'guard_no_exception' : ((), None),
'guard_exception' : (('ptr',), 'ptr'),
- 'guard_nonvirtualized' : (('ptr', 'ptr'), None),
'newstr' : (('int',), 'ptr'),
'strlen' : (('ptr',), 'int'),
'strgetitem' : (('ptr', 'int'), 'int'),
@@ -553,18 +552,6 @@
if value == expected_value:
raise GuardFailed
- def op_guard_nonvirtualized(self, for_accessing_field,
- value, expected_class=None):
- # XXX
- # We completely ignore guard_nonvirtualized
- # right now, nobody can devirtualize a virtualizable anyway
- # and we abuse guard_nonvirtualized for propagating properties
- return
- if expected_class is not None:
- self.op_guard_class(-1, value, expected_class)
- if heaptracker.cast_vable(value).vable_rti:
- raise GuardFailed # some other code is already in control
-
def op_guard_no_exception(self, _):
if _last_exception:
raise GuardFailed
Modified: pypy/branch/pyjitpl5/pypy/jit/backend/llvm/compile.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/llvm/compile.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/llvm/compile.py Tue Jun 16 18:50:36 2009
@@ -406,9 +406,6 @@
self.getintarg(op.args[1]), "")
self._generate_guard(op, equal, False)
- def generate_GUARD_NONVIRTUALIZED(self, op):
- pass # xxx ignored
-
def generate_GUARD_NO_EXCEPTION(self, op):
# etype: ty_char_ptr
etype = llvm_rffi.LLVMBuildLoad(self.builder,
Modified: pypy/branch/pyjitpl5/pypy/jit/backend/minimal/runner.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/minimal/runner.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/minimal/runner.py Tue Jun 16 18:50:36 2009
@@ -177,8 +177,6 @@
expected_value = argboxes[1].getint()
if value != expected_value:
raise GuardFailed
- elif opnum == rop.GUARD_NONVIRTUALIZED:
- pass # XXX
elif opnum == rop.GUARD_NO_EXCEPTION:
if self.current_exc_inst:
raise GuardFailed
Modified: pypy/branch/pyjitpl5/pypy/jit/backend/x86/assembler.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/x86/assembler.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/x86/assembler.py Tue Jun 16 18:50:36 2009
@@ -701,14 +701,6 @@
self.mc.CMP(mem(locs[0], offset), locs[1])
self.implement_guard(addr, op, self.mc.JNE)
- #def genop_discard_guard_nonvirtualized(self, op):
- # STRUCT = op.args[0].concretetype.TO
- # offset, size = symbolic.get_field_token(STRUCT, 'vable_rti')
- # assert size == WORD
- # self.load(eax, op.args[0])
- # self.mc.CMP(mem(eax, offset), imm(0))
- # self.implement_guard(op, self.mc.JNE)
-
def implement_guard_recovery(self, guard_op, regalloc, ovf=False):
oldmc = self.mc
self.mc = self.mc2
Modified: pypy/branch/pyjitpl5/pypy/jit/backend/x86/regalloc.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/x86/regalloc.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/x86/regalloc.py Tue Jun 16 18:50:36 2009
@@ -709,11 +709,6 @@
self.assembler.generate_failure(op, locs, self.exc)
self.eventually_free_vars(op.args)
- def consider_guard_nonvirtualized(self, op, ignored):
- # XXX implement it
- self.eventually_free_var(op.args[0])
- self.eventually_free_vars(op.inputargs)
-
def consider_guard_no_exception(self, op, ignored):
box = TempBox()
loc = self.force_allocate_reg(box, [])
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/codewriter.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/codewriter.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/codewriter.py Tue Jun 16 18:50:36 2009
@@ -1174,28 +1174,7 @@
pass # for now
def serialize_op_promote_virtualizable(self, op):
- STRUCTTYPE = deref(op.args[0].concretetype)
- argname = op.args[1].value
- FIELDTYPE = fieldType(STRUCTTYPE, argname)
- if FIELDTYPE != lltype.Void:
- TOPSTRUCT = heaptracker.cast_vable_type(STRUCTTYPE)
- metainterp_sd = self.codewriter.metainterp_sd
- vdescs = metainterp_sd._virtualizabledescs
- try:
- virtualizabledesc = vdescs[TOPSTRUCT]
- except KeyError:
- from pypy.jit.metainterp import virtualizable
- virtualizabledesc = virtualizable.VirtualizableDesc(
- self.cpu, TOPSTRUCT, STRUCTTYPE)
- virtualizabledesc.hash = len(metainterp_sd._virtualizabledescs)
- vdescs[TOPSTRUCT] = virtualizabledesc
- metainterp_sd._can_have_virtualizables = virtualizabledesc
- # ^^^ stays None if this code is never seen
- guard_field = self.cpu.fielddescrof(STRUCTTYPE, argname)
- self.emit('guard_nonvirtualized')
- self.emit(self.var_position(op.args[0]))
- self.emit(self.get_position(virtualizabledesc))
- self.emit(self.get_position(guard_field))
+ pass
serialize_op_oostring = handle_builtin_call
serialize_op_oounicode = handle_builtin_call
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/graphpage.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/graphpage.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/graphpage.py Tue Jun 16 18:50:36 2009
@@ -16,7 +16,7 @@
graphs = [(loop, loop in highlight_loops) for loop in loops]
for graph, highlight in graphs:
for op in graph.get_operations():
- if op.is_guard() and op.opnum != rop.GUARD_NONVIRTUALIZED:
+ if op.is_guard():
graphs.append((SubGraph(op.suboperations), highlight))
graphpage = ResOpGraphPage(graphs, errmsg)
graphpage.display()
@@ -64,7 +64,7 @@
self.block_starters[graphindex] = {0: True}
for graphindex, graph in enumerate(self.graphs):
for i, op in enumerate(graph.get_operations()):
- if op.is_guard() and op.opnum != rop.GUARD_NONVIRTUALIZED:
+ if op.is_guard():
self.mark_starter(graphindex, i+1)
def set_errmsg(self, errmsg):
@@ -138,7 +138,7 @@
while True:
op = operations[opindex]
lines.append(repr(op))
- if op.is_guard() and op.opnum != rop.GUARD_NONVIRTUALIZED:
+ if op.is_guard():
tgt = op.suboperations[0]
tgt_g, tgt_i = self.all_operations[tgt]
self.genedge((graphindex, opstartindex),
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/optimize.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/optimize.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/optimize.py Tue Jun 16 18:50:36 2009
@@ -53,7 +53,6 @@
self.escaped = escaped
self.startbox = startbox
self.virtual = False
- self.virtualized = False
self.const = const
self.nonzero = False # NB. never set to True so far
self.cls = None
@@ -63,7 +62,6 @@
#self.dirtyfields = r_dict(av_eq, av_hash)
#self.expanded_fields = r_dict(av_eq, av_hash)
self.cursize = -1
- self.vdesc = None # for virtualizables
self.allfields = None
def is_nonzero(self):
@@ -78,45 +76,45 @@
memo[self] = None
if self.startbox:
self.escaped = True
- if not self.virtualized:
+ if 1: ## not self.virtualized:
for node in self.curfields.values():
node.escape_if_startbox(memo, cpu)
- else:
- for key, node in self.curfields.items():
- if self.vdesc is not None and av_list_in(self.vdesc, key):
- node.initialize_virtualizable(cpu)
- node.escape_if_startbox(memo, cpu)
- # we also need to escape fields that are only read, never written,
- # if they're not marked specifically as ones that does not escape
- for key, node in self.origfields.items():
- if key not in self.curfields:
- if self.vdesc is not None and av_list_in(self.vdesc, key):
- node.initialize_virtualizable(cpu)
- node.escape_if_startbox(memo, cpu)
+## else:
+## for key, node in self.curfields.items():
+## if self.vdesc is not None and av_list_in(self.vdesc, key):
+## node.initialize_virtualizable(cpu)
+## node.escape_if_startbox(memo, cpu)
+## # we also need to escape fields that are only read, never written,
+## # if they're not marked specifically as ones that does not escape
+## for key, node in self.origfields.items():
+## if key not in self.curfields:
+## if self.vdesc is not None and av_list_in(self.vdesc, key):
+## node.initialize_virtualizable(cpu)
+## node.escape_if_startbox(memo, cpu)
- def initialize_virtualizable(self, cpu):
- self.virtualized = True
- if self.cls is None or not isinstance(self.cls.source, FixedList):
- # XXX this is of course wrong, but let's at least not
- # explode
- self.allfields = self.origfields.keys()
- if self.cls is None:
- self.cls = InstanceNode(FixedClass(), const=True)
- else:
- fx = self.cls.source
- assert isinstance(fx, FixedList)
- ad = fx.arraydescr
- lgtbox = cpu.do_arraylen_gc([self.source], ad)
- self.allfields = [ConstInt(i) for i in range(lgtbox.getint())]
+## def initialize_virtualizable(self, cpu):
+## self.virtualized = True
+## if self.cls is None or not isinstance(self.cls.source, FixedList):
+## # XXX this is of course wrong, but let's at least not
+## # explode
+## self.allfields = self.origfields.keys()
+## if self.cls is None:
+## self.cls = InstanceNode(FixedClass(), const=True)
+## else:
+## fx = self.cls.source
+## assert isinstance(fx, FixedList)
+## ad = fx.arraydescr
+## lgtbox = cpu.do_arraylen_gc([self.source], ad)
+## self.allfields = [ConstInt(i) for i in range(lgtbox.getint())]
def add_to_dependency_graph(self, other, dep_graph):
dep_graph.append((self, other))
for ofs, node in self.origfields.items():
if ofs in other.curfields:
node.add_to_dependency_graph(other.curfields[ofs], dep_graph)
- if (self.virtualized and self.vdesc is not None and
- av_list_in(self.vdesc, ofs)):
- node.add_to_dependency_graph(other.origfields[ofs], dep_graph)
+## if (self.virtualized and self.vdesc is not None and
+## av_list_in(self.vdesc, ofs)):
+## node.add_to_dependency_graph(other.origfields[ofs], dep_graph)
def intersect(self, other, nodes):
if not other.cls:
@@ -128,15 +126,16 @@
known_class = self.cls.source
else:
known_class = other.cls.source
- if (other.escaped and not other.virtualized):# and
- assert not self.virtualized
+ if (other.escaped): ## and not other.virtualized):# and
#not self.expanded_fields):
+ ## assert not self.virtualized
if self.cls is None:
return NotSpecNode()
if isinstance(known_class, FixedList):
return NotSpecNode()
return FixedClassSpecNode(known_class)
- if not other.escaped:
+ else:
+## if not other.escaped:
assert self is not other
fields = []
d = other.curfields
@@ -165,31 +164,31 @@
# if isinstance(known_class, FixedList):
# return DelayedFixedListSpecNode(known_class, fields)
# return DelayedSpecNode(known_class, fields)
- assert other.virtualized
- assert self is other
- offsets = self.allfields
- if offsets is None:
- return None
- sort_descrs(offsets)
- fields = []
- for ofs in offsets:
- if ofs in other.curfields:
- node = other.curfields[ofs]
- if ofs not in self.origfields:
- box = node.source.clonebox()
- self.origfields[ofs] = InstanceNode(box, escaped=False)
- self.origfields[ofs].cls = node.cls
- nodes[box] = self.origfields[ofs]
- specnode = self.origfields[ofs].intersect(node, nodes)
- elif ofs in self.origfields:
- node = self.origfields[ofs]
- specnode = node.intersect(node, nodes)
- else:
- specnode = MatchEverythingSpecNode()
- fields.append((ofs, specnode))
- if isinstance(known_class, FixedList):
- return VirtualizableListSpecNode(known_class, fields)
- return VirtualizableSpecNode(known_class, fields)
+## assert other.virtualized
+## assert self is other
+## offsets = self.allfields
+## if offsets is None:
+## return None
+## sort_descrs(offsets)
+## fields = []
+## for ofs in offsets:
+## if ofs in other.curfields:
+## node = other.curfields[ofs]
+## if ofs not in self.origfields:
+## box = node.source.clonebox()
+## self.origfields[ofs] = InstanceNode(box, escaped=False)
+## self.origfields[ofs].cls = node.cls
+## nodes[box] = self.origfields[ofs]
+## specnode = self.origfields[ofs].intersect(node, nodes)
+## elif ofs in self.origfields:
+## node = self.origfields[ofs]
+## specnode = node.intersect(node, nodes)
+## else:
+## specnode = MatchEverythingSpecNode()
+## fields.append((ofs, specnode))
+## if isinstance(known_class, FixedList):
+## return VirtualizableListSpecNode(known_class, fields)
+## return VirtualizableSpecNode(known_class, fields)
def __repr__(self):
flags = ''
@@ -197,7 +196,7 @@
if self.startbox: flags += 's'
if self.const: flags += 'c'
if self.virtual: flags += 'v'
- if self.virtualized: flags += 'V'
+## if self.virtualized: flags += 'V'
return "<InstanceNode %s (%s)>" % (self.source, flags)
def optimize_loop(options, old_loops, loop, cpu=None):
@@ -383,16 +382,16 @@
#self.nodes[instnode.source] = InstanceNode(op.args[1],
# const=True)
continue
- elif opnum == rop.GUARD_NONVIRTUALIZED:
- instnode = self.getnode(op.args[0])
- if instnode.startbox:
- instnode.virtualized = True
- if instnode.cls is None:
- instnode.cls = InstanceNode(op.args[1], const=True)
- if op.vdesc:
- instnode.vdesc = op.vdesc.virtuals
- instnode.allfields = op.vdesc.fields
- continue
+## elif opnum == rop.GUARD_NONVIRTUALIZED:
+## instnode = self.getnode(op.args[0])
+## if instnode.startbox:
+## instnode.virtualized = True
+## if instnode.cls is None:
+## instnode.cls = InstanceNode(op.args[1], const=True)
+## if op.vdesc:
+## instnode.vdesc = op.vdesc.virtuals
+## instnode.allfields = op.vdesc.fields
+## continue
elif op.is_always_pure():
is_pure = True
for arg in op.args:
@@ -441,7 +440,7 @@
while not done:
done = True
for instnode, fieldnode in self.dependency_graph:
- if instnode.escaped and not instnode.virtualized:
+ if instnode.escaped: ## and not instnode.virtualized:
if not fieldnode.escaped:
fieldnode.escaped = True
done = False
@@ -512,20 +511,20 @@
rebuild_ops.append(op)
return box
memo[box] = None
- if instnode.virtualized:
- for ofs, node in instnode.curfields.items():
- fieldbox = self.prepare_rebuild_ops(node, rebuild_ops, memo)
- if instnode.cls and isinstance(instnode.cls.source, FixedList):
- ld = instnode.cls.source
- assert isinstance(ld, FixedList)
- op = ResOperation(rop.SETARRAYITEM_GC,
- [box, ofs, fieldbox],
- None, descr=ld.arraydescr)
- else:
- assert isinstance(ofs, AbstractDescr)
- op = ResOperation(rop.SETFIELD_GC, [box, fieldbox],
- None, descr=ofs)
- rebuild_ops.append(op)
+## if instnode.virtualized:
+## for ofs, node in instnode.curfields.items():
+## fieldbox = self.prepare_rebuild_ops(node, rebuild_ops, memo)
+## if instnode.cls and isinstance(instnode.cls.source, FixedList):
+## ld = instnode.cls.source
+## assert isinstance(ld, FixedList)
+## op = ResOperation(rop.SETARRAYITEM_GC,
+## [box, ofs, fieldbox],
+## None, descr=ld.arraydescr)
+## else:
+## assert isinstance(ofs, AbstractDescr)
+## op = ResOperation(rop.SETFIELD_GC, [box, fieldbox],
+## None, descr=ofs)
+## rebuild_ops.append(op)
return box
def optimize_guard(self, op):
@@ -540,9 +539,9 @@
continue
self.prepare_rebuild_ops(self.nodes[box], rebuild_ops, memo, box)
# XXX sloooooow!
- for node in self.nodes.values():
- if node.virtualized:
- self.prepare_rebuild_ops(node, rebuild_ops, memo)
+## for node in self.nodes.values():
+## if node.virtualized:
+## self.prepare_rebuild_ops(node, rebuild_ops, memo)
# # start of code for dirtyfields support
# for node in self.nodes.values():
@@ -599,15 +598,15 @@
if instnode.virtual:
assert ofs in instnode.curfields
return True # this means field is never actually
- elif instnode.virtualized:
- if ofs in instnode.curfields:
- return True
- # this means field comes from a virtualizable but is never
- # written.
- node = InstanceNode(box)
- self.nodes[box] = node
- instnode.curfields[ofs] = node
- return True
+## elif instnode.virtualized:
+## if ofs in instnode.curfields:
+## return True
+## # this means field comes from a virtualizable but is never
+## # written.
+## node = InstanceNode(box)
+## self.nodes[box] = node
+## instnode.curfields[ofs] = node
+## return True
#if ofs in instnode.cleanfields:
# self.nodes[box] = instnode.cleanfields[ofs]
# return True
@@ -618,7 +617,7 @@
def optimize_setfield(self, instnode, ofs, valuenode, valuebox):
assert isinstance(ofs, AbstractValue)
- if instnode.virtual or instnode.virtualized:
+ if instnode.virtual: ## or instnode.virtualized:
instnode.curfields[ofs] = valuenode
return True
else:
@@ -687,12 +686,12 @@
instnode.const = True
newoperations.append(self.optimize_guard(op))
continue
- elif opnum == rop.GUARD_NONVIRTUALIZED:
- instnode = self.nodes[op.args[0]]
- if instnode.virtualized or instnode.virtual:
- continue
- newoperations.append(self.optimize_guard(op))
- continue
+## elif opnum == rop.GUARD_NONVIRTUALIZED:
+## instnode = self.nodes[op.args[0]]
+## if instnode.virtualized or instnode.virtual:
+## continue
+## newoperations.append(self.optimize_guard(op))
+## continue
elif opnum == rop.GETFIELD_GC:
instnode = self.nodes[op.args[0]]
if self.optimize_getfield(instnode, op.descr, op.result):
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/optimize2.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/optimize2.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/optimize2.py Tue Jun 16 18:50:36 2009
@@ -22,9 +22,7 @@
self.cleanfields = {}
self.origfields = {}
self.arrayfields = {}
- self.virtualized = False
self.allocated_in_loop = False
- self.vdesc = None
self.escaped = escaped
self.virtual = False
self.size = None
@@ -35,7 +33,6 @@
#if self.startbox: flags += 's'
if self.const: flags += 'c'
if self.virtual: flags += 'v'
- if self.virtualized: flags += 'V'
return "<InstanceNode %s (%s)>" % (self.source, flags)
class Specializer(object):
@@ -126,13 +123,6 @@
newboxes.append(box)
return newboxes
- def _guard_for_node(self, node):
- gop = ResOperation(rop.GUARD_NONVIRTUALIZED,
- [node.source], None)
- gop.vdesc = node.vdesc
- gop.suboperations = [ResOperation(rop.FAIL, [], None)]
- return gop
-
def rebuild_virtual(self, ops, node):
assert node.virtual
if node.cls is not None:
@@ -164,35 +154,10 @@
def rebuild_virtuals(self, ops, args):
self.already_build_nodes = {}
- rebuild = False
for arg in args:
node = self.getnode(arg)
if node.virtual:
self.rebuild_virtual(ops, node)
- if node.virtualized:
- rebuild = True
- # modification in place. Reason for this is explained in mirror
- # in optimize.py
- # XXX in general, it's probably not correct, but should work
- # because we always pass frame anyway
- if rebuild:
- for node, d in self.additional_stores.iteritems():
- for field, fieldnode in d.iteritems():
- if fieldnode.virtual:
- self.rebuild_virtual(ops, fieldnode)
- gop = self._guard_for_node(node)
- ops.append(gop)
- ops.append(ResOperation(rop.SETFIELD_GC,
- [node.source, fieldnode.source], None, field))
- for node, d in self.additional_setarrayitems.iteritems():
- for field, (fieldnode, descr) in d.iteritems():
- box = fieldnode.source
- if fieldnode.virtual:
- self.rebuild_virtual(ops, fieldnode)
- gop = self._guard_for_node(node)
- ops.append(gop)
- ops.append(ResOperation(rop.SETARRAYITEM_GC,
- [node.source, ConstInt(field), box], None, descr))
def optimize_operations(self):
self.additional_stores = {}
@@ -275,134 +240,7 @@
spec.nodes[op.result] = InstanceNode(ConstInt(0), const=True)
return True
-class SimpleVirtualizableOpt(object):
- @staticmethod
- def find_nodes_setfield_gc(op, spec):
- instnode = spec.getnode(op.args[0])
- if not instnode.virtualized:
- return False
- field = op.descr
- if field not in instnode.vdesc.virtuals:
- return False
- node = spec.getnode(op.args[1])
- instnode.cleanfields[field] = node
- return True
- @staticmethod
- def find_nodes_getfield_gc(op, spec):
- instnode = spec.getnode(op.args[0])
- if not instnode.virtualized:
- return False
- field = op.descr
- if field not in instnode.vdesc.virtuals:
- return False
- node = instnode.cleanfields.get(field, None)
- if node:
- spec.nodes[op.result] = node
- node.virtualized = True
- return True
- node = spec.getnode(op.result)
- instnode.cleanfields[field] = node
- node.virtualized = True
- return False
-
- @staticmethod
- def find_nodes_setarrayitem_gc(op, spec):
- instnode = spec.getnode(op.args[0])
- if not instnode.virtualized:
- return False
- field = op.args[1].getint()
- node = spec.getnode(op.args[2])
- instnode.arrayfields[field] = node
- return True
-
- @staticmethod
- def find_nodes_getarrayitem_gc(op, spec):
- instnode = spec.getnode(op.args[0])
- if not instnode.virtualized:
- return False
- field = op.args[1].getint()
- node = instnode.arrayfields.get(field, None)
- if node is not None:
- spec.nodes[op.result] = node
- return True
- instnode.arrayfields[field] = node
- return False
-
- @staticmethod
- def find_nodes_guard_nonvirtualized(op, spec):
- instnode = spec.getnode(op.args[0])
- if not instnode.allocated_in_loop:
- instnode.virtualized = True
- instnode.vdesc = op.vdesc
- return False
-
- @staticmethod
- def optimize_guard_nonvirtualized(op, spec):
- return True
-
- @staticmethod
- def optimize_getfield_gc(op, spec):
- instnode = spec.getnode(op.args[0])
- if not instnode.virtualized:
- return False
- field = op.descr
- if field not in instnode.vdesc.virtuals:
- return False
- node = instnode.cleanfields.get(field, None)
- if node is not None:
- spec.nodes[op.result] = node
- return True
- node = spec.getnode(op.result)
- instnode.cleanfields[field] = node
- return False
-
- @staticmethod
- def optimize_setfield_gc(op, spec):
- instnode = spec.getnode(op.args[0])
- if not instnode.virtualized:
- return False
- field = op.descr
- if field not in instnode.vdesc.virtuals:
- return False
- node = spec.getnode(op.args[1])
- instnode.cleanfields[field] = node
- # we never set it here
- d = spec.additional_stores.setdefault(instnode, {})
- d[field] = node
- return True
-
- @staticmethod
- def optimize_getarrayitem_gc(op, spec):
- instnode = spec.getnode(op.args[0])
- if not instnode.virtualized:
- return False
- if not spec.getnode(op.args[1]).const:
- raise VirtualizedListAccessedWithVariableArg()
- field = spec.getnode(op.args[1]).source.getint()
- node = instnode.arrayfields.get(field, None)
- if node is not None:
- spec.nodes[op.result] = node
- return True
- node = spec.getnode(op.result)
- instnode.arrayfields[field] = node
- return False
-
- @staticmethod
- def optimize_setarrayitem_gc(op, spec):
- instnode = spec.getnode(op.args[0])
- if not instnode.virtualized:
- return False
- argnode = spec.getnode(op.args[1])
- if not argnode.const:
- raise VirtualizedListAccessedWithVariableArg()
- fieldnode = spec.getnode(op.args[2])
- field = argnode.source.getint()
- instnode.arrayfields[field] = fieldnode
- d = spec.additional_setarrayitems.setdefault(instnode, {})
- d[field] = (fieldnode, op.descr)
- return True
-
class SimpleVirtualOpt(object):
@staticmethod
def optimize_new_with_vtable(op, spec):
@@ -461,8 +299,7 @@
return True
-specializer = Specializer([SimpleVirtualizableOpt(),
- SimpleVirtualOpt(),
+specializer = Specializer([SimpleVirtualOpt(),
ConsecutiveGuardClassRemoval()])
def optimize_loop(options, old_loops, loop, cpu=None, spec=specializer):
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/pyjitpl.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/pyjitpl.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/pyjitpl.py Tue Jun 16 18:50:36 2009
@@ -675,15 +675,6 @@
## 'len', [builtin.len_func, box], 'int')
## self.generate_guard(pc, "guard_len", box, [intbox])
- @arguments("orgpc", "box", "virtualizabledesc", "descr")
- def opimpl_guard_nonvirtualized(self, pc, box, vdesc, guard_field):
- clsbox = self.cls_of_box(box)
- op = self.generate_guard(pc, rop.GUARD_NONVIRTUALIZED, box,
- [clsbox])
- if op:
- op.vdesc = vdesc
- op.setdescr(guard_field)
-
@arguments("box")
def opimpl_keepalive(self, box):
pass # xxx?
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/resoperation.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/resoperation.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/resoperation.py Tue Jun 16 18:50:36 2009
@@ -9,9 +9,6 @@
suboperations = None
optimized = None
- # for 'guard_nonvirtualizable'
- vdesc = None
-
# for x86 backend and guards
inputargs = None
@@ -39,7 +36,6 @@
def clone(self):
res = ResOperation(self.opnum, self.args, self.result, self.descr)
res.jump_target = self.jump_target
- res.vdesc = self.vdesc
return res
def __repr__(self):
@@ -115,7 +111,6 @@
GUARD_VALUE = 10
GUARD_CLASS = 11
_GUARD_FOLDABLE_LAST = 11
- GUARD_NONVIRTUALIZED = 12
GUARD_NO_EXCEPTION = 13
GUARD_EXCEPTION = 14
_GUARD_LAST = 19 # ----- end of guard operations -----
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/simple_optimize.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/simple_optimize.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/simple_optimize.py Tue Jun 16 18:50:36 2009
@@ -9,12 +9,6 @@
assert len(old_loops) == 1
return old_loops[0]
else:
- newoperations = []
- for op in loop.operations:
- if op.opnum == rop.GUARD_NONVIRTUALIZED:
- continue
- newoperations.append(op)
- loop.operations = newoperations
return None
def optimize_bridge(options, old_loops, loop, cpu=None):
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/test/oparser.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/test/oparser.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/test/oparser.py Tue Jun 16 18:50:36 2009
@@ -77,44 +77,37 @@
raise ParseError("invalid line: %s" % line)
argspec = line[num + 1:endnum]
if not argspec.strip():
- return opnum, [], None, None
+ return opnum, [], None
allargs = argspec.split(",")
args = []
descr = None
- vdesc = None
poss_descr = allargs[-1].strip()
if poss_descr.startswith('descr='):
descr = self.consts[poss_descr[len('descr='):]]
allargs = allargs[:-1]
- poss_vdesc = allargs[-1].strip()
- if poss_vdesc.startswith('vdesc='):
- vdesc = self.consts[poss_vdesc[len('vdesc='):]]
- allargs = allargs[:-1]
for arg in allargs:
arg = arg.strip()
try:
args.append(self.getvar(arg))
except KeyError:
raise ParseError("Unknown var: %s" % arg)
- return opnum, args, descr, vdesc
+ return opnum, args, descr
def parse_result_op(self, line):
res, op = line.split("=", 1)
res = res.strip()
op = op.strip()
- opnum, args, descr, vdesc = self.parse_op(op)
+ opnum, args, descr = 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)
self.vars[res] = rvar
res = ResOperation(opnum, args, rvar, descr)
- res.vdesc = vdesc
return res
def parse_op_no_result(self, line):
- opnum, args, descr, vdesc = self.parse_op(line)
+ opnum, args, descr = self.parse_op(line)
res = ResOperation(opnum, args, None, descr)
- res.vdesc = vdesc
return res
def parse_next_op(self, line):
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_oparser.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_oparser.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_oparser.py Tue Jun 16 18:50:36 2009
@@ -64,18 +64,3 @@
stuff = Xyz()
loop = parse(x, None, locals())
assert loop.operations[0].descr is stuff
-
-def test_vdesc():
- class Xyz(AbstractDescr):
- pass
-
- x = """
- [p0]
- guard_nonvirtualized(p0, vdesc=stuff)
- fail()
- """
- stuff = Xyz()
- loop = parse(x, None, locals())
- assert loop.operations[0].vdesc is stuff
-
-
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_optimize2.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_optimize2.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_optimize2.py Tue Jun 16 18:50:36 2009
@@ -9,12 +9,10 @@
from pypy.jit.backend.llgraph import runner
from pypy.jit.metainterp.optimize2 import (optimize_loop,
- ConsecutiveGuardClassRemoval, Specializer, SimpleVirtualizableOpt,
- SimpleVirtualOpt)
+ ConsecutiveGuardClassRemoval, Specializer, SimpleVirtualOpt)
from pypy.jit.metainterp.test.test_optimize import ANY
from pypy.jit.metainterp.test.oparser import parse
-from pypy.jit.metainterp.virtualizable import VirtualizableDesc
def equaloplists(oplist1, oplist2):
#saved = Box._extended_display
@@ -74,7 +72,6 @@
list_desc = cpu.fielddescrof(XY, 'inst_list')
list_node_desc = cpu.fielddescrof(XY, 'inst_item_list')
other_field_desc = cpu.fielddescrof(XY, 'inst_other_field')
- vdesc = VirtualizableDesc(cpu, XY, XY)
xy_vtable = lltype.malloc(OBJECT_VTABLE, immortal=True)
namespace = locals()
@@ -113,7 +110,6 @@
list_desc = cpu.fielddescrof(XY, 'olist')
list_node_desc = cpu.fielddescrof(XY, 'oitem_list')
other_field_desc = cpu.fielddescrof(XY, 'oother_field')
- vdesc = VirtualizableDesc(cpu, XY, XY)
xy_vtable = ootype.runtimeClass(XY)
namespace = locals()
@@ -189,50 +185,6 @@
[ConsecutiveGuardClassRemoval()]),
expected)
- def test_basic_virtualizable(self):
- pre_op = """
- [p0]
- guard_nonvirtualized(p0, ConstClass(xy_vtable), vdesc=vdesc)
- fail()
- i1 = getfield_gc(p0, descr=field_desc)
- i2 = getfield_gc(p0, descr=field_desc)
- i3 = int_add(i1, i2)
- """
- expected = """
- [p0]
- i1 = getfield_gc(p0, descr=field_desc)
- i3 = int_add(i1, i1)
- """
- self.assert_equal(self.optimize(pre_op, [SimpleVirtualizableOpt()]),
- expected)
-
- def test_virtualizable_setfield_rebuild_ops(self):
- pre_op = """
- [p0]
- guard_nonvirtualized(p0, ConstClass(xy_vtable), vdesc=vdesc)
- fail()
- i1 = getfield_gc(p0, descr=field_desc)
- i2 = getfield_gc(p0, descr=other_field_desc)
- setfield_gc(p0, i2, descr=field_desc)
- # ^^^ this should be gone
- i3 = getfield_gc(p0, descr=field_desc)
- # ^^^ this one as well
- guard_true(i3)
- fail(p0)
- """
- expected = """
- [p0]
- i1 = getfield_gc(p0, descr=field_desc)
- i2 = getfield_gc(p0, descr=other_field_desc)
- guard_true(i2)
- guard_nonvirtualized(p0)
- fail()
- setfield_gc(p0, i2, descr=field_desc)
- fail(p0)
- """
- self.assert_equal(self.optimize(pre_op, [SimpleVirtualizableOpt()]),
- expected)
-
def test_const_guard_value(self):
pre_op = """
[]
@@ -250,103 +202,6 @@
"""
self.assert_equal(self.optimize(pre_op, []), pre_op)
- def test_virtualized_list_on_virtualizable(self):
- pre_op = """
- [p0]
- guard_nonvirtualized(p0, ConstClass(xy_vtable), vdesc=vdesc)
- fail()
- p1 = getfield_gc(p0, descr=list_desc)
- setarrayitem_gc(p1, 0, 1, descr=array_descr)
- i1 = getarrayitem_gc(p1, 0)
- i2 = int_add(i1, i1)
- i3 = int_is_true(i2)
- guard_true(i3)
- fail()
- """
- pre_op = self.parse(pre_op)
- # cheat
- pre_op.operations[-2].result.value = 1
- expected = """
- [p0]
- p1 = getfield_gc(p0, descr=list_desc)
- """
- self.assert_equal(self.optimize(pre_op, [SimpleVirtualizableOpt()]),
- expected)
-
-
- def test_virtualized_list_on_virtualizable_2(self):
- pre_op = """
- [p0, i0]
- guard_nonvirtualized(p0, ConstClass(xy_vtable), vdesc=vdesc)
- fail()
- p1 = getfield_gc(p0, descr=list_desc)
- setarrayitem_gc(p1, 0, i0, descr=array_descr)
- i1 = getarrayitem_gc(p1, 0)
- i2 = int_add(i1, i1)
- i3 = int_is_true(i2)
- guard_true(i3)
- fail(p0)
- """
- pre_op = self.parse(pre_op)
- expected = """
- [p0, i0]
- p1 = getfield_gc(p0, descr=list_desc)
- i2 = int_add(i0, i0)
- i3 = int_is_true(i2)
- guard_true(i3)
- guard_nonvirtualized(p1)
- fail()
- setarrayitem_gc(p1, 0, i0, descr=array_descr)
- fail(p0)
- """
- self.assert_equal(self.optimize(pre_op, [SimpleVirtualizableOpt()]),
- expected)
-
- def test_virtualized_list_on_virtualizable_3(self):
- pre_op = """
- [p0, i0, i1]
- guard_nonvirtualized(p0, ConstClass(xy_vtable), vdesc=vdesc)
- fail()
- p1 = getfield_gc(p0, descr=list_desc)
- setarrayitem_gc(p1, 0, i0, descr=array_descr)
- i2 = getarrayitem_gc(p1, 0)
- setarrayitem_gc(p1, 0, i1, descr=array_descr)
- i3 = getarrayitem_gc(p1, 0)
- i4 = int_add(i2, i3)
- i5 = int_is_true(i4)
- guard_true(i5)
- fail(p0)
- """
- expected = """
- [p0, i0, i1]
- p1 = getfield_gc(p0, descr=list_desc)
- i4 = int_add(i0, i1)
- i5 = int_is_true(i4)
- guard_true(i5)
- guard_nonvirtualized(p1)
- fail()
- setarrayitem_gc(p1, 0, i1, descr=array_descr)
- fail(p0)
- """
- self.assert_equal(self.optimize(pre_op, [SimpleVirtualizableOpt()]),
- expected)
-
- def test_newly_allocated_virtualizable_is_not_virtualized(self):
- pre_op = """
- []
- p0 = new_with_vtable(ConstClass(xy_vtable))
- guard_nonvirtualized(p0, vdesc=vdesc)
- fail()
- setfield_gc(p0, 3, descr=field_desc)
- """
- expected = """
- []
- p0 = new_with_vtable(ConstClass(xy_vtable))
- setfield_gc(p0, 3, descr=field_desc)
- """
- self.assert_equal(self.optimize(pre_op, [SimpleVirtualizableOpt()]),
- expected)
-
def test_escape_analysis(self):
ops = """
[i0]
@@ -385,20 +240,6 @@
optimize_loop(None, [], loop, self.cpu, spec=spec)
assert not spec.nodes[loop.operations[0].result].escaped
- def test_escape_analysis_on_virtualizable(self):
- ops = """
- [p0]
- guard_nonvirtualized(p0, vdesc=vdesc)
- fail()
- i1 = getfield_gc(p0, descr=field_desc)
- setfield_gc(p0, i1, descr=field_desc)
- i2 = int_add(i1, i1)
- """
- spec = Specializer([SimpleVirtualizableOpt()])
- loop = self.parse(ops)
- optimize_loop(None, [], loop, self.cpu, spec=spec)
- assert not spec.nodes[loop.operations[0].result].escaped
-
def test_simple_virtual(self):
pre_op = """
[]
@@ -414,28 +255,6 @@
self.assert_equal(self.optimize(pre_op, [SimpleVirtualOpt()]),
expected)
- def test_virtual_with_virtualizable(self):
- pre_op = """
- [p0]
- p1 = new_with_vtable(ConstClass(node_vtable))
- setfield_gc(p1, 1, descr=nodedescr)
- guard_nonvirtualized(p0, vdesc=vdesc)
- fail()
- p2 = getfield_gc(p0, descr=list_node_desc)
- setarrayitem_gc(p2, 0, p1)
- p3 = getarrayitem_gc(p2, 0)
- i3 = getfield_gc(p3, descr=nodedescr)
- fail(i3)
- """
- expected = """
- [p0]
- p2 = getfield_gc(p0, descr=list_node_desc)
- fail(1)
- """
- self.assert_equal(self.optimize(pre_op, [SimpleVirtualizableOpt(),
- SimpleVirtualOpt()]),
- expected)
-
def test_rebuild_ops(self):
pre_op = """
[i1]
@@ -454,76 +273,6 @@
self.assert_equal(self.optimize(pre_op, [SimpleVirtualOpt()]),
expected)
-
- def test_virtual_with_virtualizable_escapes(self):
- pre_op = """
- [p0]
- p1 = new_with_vtable(ConstClass(node_vtable))
- setfield_gc(p1, 1, descr=nodedescr)
- guard_nonvirtualized(p0, vdesc=vdesc)
- fail()
- p2 = getfield_gc(p0, descr=list_node_desc)
- setarrayitem_gc(p2, 0, p1)
- p3 = getarrayitem_gc(p2, 0)
- fail(p3)
- """
- expected = """
- [p0]
- p1 = new_with_vtable(ConstClass(node_vtable))
- setfield_gc(p1, 1, descr=nodedescr)
- p2 = getfield_gc(p0, descr=list_node_desc)
- fail(p1)
- """
- self.assert_equal(self.optimize(pre_op, [SimpleVirtualizableOpt(),
- SimpleVirtualOpt()]),
- expected)
-
- def test_virtualizable_double_read(self):
- pre_op = """
- [p0]
- p3 = new_with_vtable(ConstClass(node_vtable))
- guard_nonvirtualized(p0, vdesc=vdesc)
- fail()
- p1 = getfield_gc(p0, descr=list_node_desc)
- setarrayitem_gc(p1, 0, p3)
- p2 = getfield_gc(p0, descr=list_node_desc)
- p4 = getarrayitem_gc(p2, 0)
- fail(p4)
- """
- expected = """
- [p0]
- p3 = new_with_vtable(ConstClass(node_vtable))
- p1 = getfield_gc(p0, descr=list_node_desc)
- fail(p3)
- """
- self.assert_equal(self.optimize(pre_op, [SimpleVirtualizableOpt(),
- SimpleVirtualOpt()]),
- expected)
-
-
- def test_virtualizable_fail_forces(self):
- pre_op = """
- [p0]
- p3 = new_with_vtable(ConstClass(node_vtable))
- guard_nonvirtualized(p0, vdesc=vdesc)
- fail()
- p1 = getfield_gc(p0, descr=list_node_desc)
- setarrayitem_gc(p1, 0, p3)
- fail(p0)
- """
- expected = """
- [p0]
- p1 = getfield_gc(p0, descr=list_node_desc)
- p3 = new_with_vtable(ConstClass(node_vtable))
- guard_nonvirtualized(p1)
- fail()
- setarrayitem_gc(p1, 0, p3)
- fail(p0)
- """
- self.assert_equal(self.optimize(pre_op, [SimpleVirtualizableOpt(),
- SimpleVirtualOpt()]),
- expected)
-
def test_virtual_without_vtable(self):
pre_op = """
[i1]
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_tl.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_tl.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_tl.py Tue Jun 16 18:50:36 2009
@@ -95,6 +95,7 @@
def test_tl_base(self):
res = self.meta_interp(self.main.im_func, [0, 6], listops=True)
assert res == 5040
+ py.test.skip("waiting for virtualizables")
self.check_loops({'int_mul':1, 'jump':1,
'int_sub':1, 'int_is_true':1, 'int_le':1,
'guard_false':1, 'guard_value':1})
@@ -102,6 +103,7 @@
def test_tl_2(self):
res = self.meta_interp(self.main.im_func, [1, 10], listops=True)
assert res == self.main.im_func(1, 10)
+ py.test.skip("waiting for virtualizables")
self.check_loops({'int_sub':1, 'int_le':1,
'int_is_true':1, 'guard_false':1, 'jump':1,
'guard_value':1})
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_vable_optimize.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_vable_optimize.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_vable_optimize.py Tue Jun 16 18:50:36 2009
@@ -1,4 +1,5 @@
import py
+py.test.skip("redo me")
from pypy.rpython.lltypesystem import lltype, rclass, llmemory
from pypy.rpython.lltypesystem.rvirtualizable2 import VABLERTIPTR
More information about the Pypy-commit
mailing list