[pypy-commit] pypy exc-later: Move transform_xxitem() from rpython.translator.simplify to rpython.translator.transform
rlamy
noreply at buildbot.pypy.org
Tue Mar 17 20:29:35 CET 2015
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: exc-later
Changeset: r76444:0e069ae6a869
Date: 2015-03-15 02:27 +0000
http://bitbucket.org/pypy/pypy/changeset/0e069ae6a869/
Log: Move transform_xxitem() from rpython.translator.simplify to
rpython.translator.transform
diff --git a/rpython/annotator/binaryop.py b/rpython/annotator/binaryop.py
--- a/rpython/annotator/binaryop.py
+++ b/rpython/annotator/binaryop.py
@@ -561,7 +561,7 @@
def getitem((lst1, int2)):
return lst1.listdef.read_item()
- getitem.can_only_throw = []
+ getitem.can_only_throw = [IndexError]
def getitem_idx((lst1, int2)):
return lst1.listdef.read_item()
@@ -580,7 +580,7 @@
def getitem((str1, int2)):
return SomeChar(no_nul=str1.no_nul)
- getitem.can_only_throw = []
+ getitem.can_only_throw = [IndexError]
def getitem_idx((str1, int2)):
return SomeChar(no_nul=str1.no_nul)
@@ -592,7 +592,7 @@
class __extend__(pairtype(SomeUnicodeString, SomeInteger)):
def getitem((str1, int2)):
return SomeUnicodeCodePoint()
- getitem.can_only_throw = []
+ getitem.can_only_throw = [IndexError]
def getitem_idx((str1, int2)):
return SomeUnicodeCodePoint()
diff --git a/rpython/translator/simplify.py b/rpython/translator/simplify.py
--- a/rpython/translator/simplify.py
+++ b/rpython/translator/simplify.py
@@ -178,22 +178,6 @@
exits.append(link)
block.recloseblock(*(preserve + exits))
-def transform_xxxitem(graph):
- # xxx setitem too
- for block in graph.iterblocks():
- if block.canraise:
- last_op = block.raising_op
- if last_op.opname == 'getitem':
- postfx = []
- if any(issubclass(IndexError, exit.exitcase)
- for exit in block.exits if exit.exitcase):
- postfx.append('idx')
- if postfx:
- Op = getattr(op, '_'.join(['getitem'] + postfx))
- newop = Op(*last_op.args)
- newop.result = last_op.result
- block.operations[-1] = newop
-
def remove_dead_exceptions(graph):
"""Exceptions can be removed if they are unreachable"""
@@ -1104,7 +1088,6 @@
remove_assertion_errors,
specialize_exceptions,
remove_dead_exceptions,
- transform_xxxitem,
join_blocks,
]
diff --git a/rpython/translator/transform.py b/rpython/translator/transform.py
--- a/rpython/translator/transform.py
+++ b/rpython/translator/transform.py
@@ -7,6 +7,7 @@
from rpython.flowspace.model import (
SpaceOperation, Variable, Constant, Link, checkgraph)
+from rpython.flowspace.operation import op
from rpython.annotator import model as annmodel
from rpython.rtyper.lltypesystem import lltype
@@ -134,6 +135,23 @@
s_dict.dictdef.generalize_key(self.binding(op.args[1]))
+def transform_getitem(ann, blocks):
+ for block in blocks:
+ if block.canraise:
+ last_op = block.raising_op
+ if last_op.opname == 'getitem':
+ postfx = []
+ if any(issubclass(IndexError, exit.exitcase)
+ for exit in block.exits if exit.exitcase):
+ postfx.append('idx')
+ if postfx:
+ Op = getattr(op, '_'.join(['getitem'] + postfx))
+ newop = Op(*last_op.args)
+ newop.result = last_op.result
+ block.operations[-1] = newop
+
+
+
def transform_dead_op_vars(self, block_subset):
# we redo the same simplification from simplify.py,
# to kill dead (never-followed) links,
@@ -248,6 +266,7 @@
transform_extend_with_str_slice,
transform_extend_with_char_count,
transform_list_contains,
+ transform_getitem,
]
def transform_graph(ann, extra_passes=None, block_subset=None):
More information about the pypy-commit
mailing list