[pypy-svn] r37368 - pypy/dist/pypy/jit/timeshifter
pedronis at codespeak.net
pedronis at codespeak.net
Fri Jan 26 02:04:54 CET 2007
Author: pedronis
Date: Fri Jan 26 02:04:52 2007
New Revision: 37368
Modified:
pypy/dist/pypy/jit/timeshifter/hrtyper.py
pypy/dist/pypy/jit/timeshifter/transform.py
Log:
don't emit exception checking code for residual calls to graphs that are known not to raise.
Modified: pypy/dist/pypy/jit/timeshifter/hrtyper.py
==============================================================================
--- pypy/dist/pypy/jit/timeshifter/hrtyper.py (original)
+++ pypy/dist/pypy/jit/timeshifter/hrtyper.py Fri Jan 26 02:04:52 2007
@@ -1356,7 +1356,7 @@
translate_op_yellow_call = translate_op_red_call
translate_op_indirect_yellow_call = translate_op_indirect_red_call
- def translate_op_residual_red_call(self, hop, color='red'):
+ def translate_op_residual_red_call(self, hop, color='red', exc=True):
FUNC = originalconcretetype(hop.args_s[0])
[v_funcbox] = hop.inputargs(self.getredrepr(FUNC))
calldesc = rtimeshift.CallDesc(self.RGenOp, FUNC.TO)
@@ -1372,15 +1372,22 @@
[self.s_JITState, s_calldesc, self.s_RedBox],
[v_jitstate, c_calldesc, v_funcbox ],
s_result)
- # XXX do something to do this only if the graph can raise
- hop.llops.genmixlevelhelpercall(self.fetch_global_excdata,
- [self.s_JITState], [v_jitstate],
- annmodel.s_None)
+
+ if exc:
+ hop.llops.genmixlevelhelpercall(self.fetch_global_excdata,
+ [self.s_JITState], [v_jitstate],
+ annmodel.s_None)
return v_res
def translate_op_residual_gray_call(self, hop):
self.translate_op_residual_red_call(hop, color='gray')
+ def translate_op_residual_red_noexc_call(self, hop):
+ return self.translate_op_residual_red_call(hop, exc=False)
+
+ def translate_op_residual_gray_noexc_call(self, hop):
+ self.translate_op_residual_red_call(hop, color='gray', exc=False)
+
def translate_op_after_residual_call(self, hop):
v_jitstate = hop.llops.getjitstate()
return hop.llops.genmixlevelhelpercall(rtimeshift.after_residual_call,
Modified: pypy/dist/pypy/jit/timeshifter/transform.py
==============================================================================
--- pypy/dist/pypy/jit/timeshifter/transform.py (original)
+++ pypy/dist/pypy/jit/timeshifter/transform.py Fri Jan 26 02:04:52 2007
@@ -65,10 +65,14 @@
t = self.hannotator.base_translator
self.sideeffects_analyzer = HasSideeffects(t)
+ self.raise_analyzer = hannotator.exceptiontransformer.raise_analyzer
def has_sideeffects(self, op):
return self.sideeffects_analyzer.analyze(op)
+ def can_raise(self, op):
+ return self.raise_analyzer.analyze(op)
+
def transform(self):
self.compute_merge_points()
self.insert_save_return()
@@ -508,8 +512,10 @@
for graph, tsgraph in self.graphs_from(spaceop):
color = self.graph_calling_color(tsgraph)
colors[color] = tsgraph
- if not colors:
- return 'residual' # cannot follow this call
+ if not colors: # cannot follow this call
+ if not self.can_raise(spaceop):
+ return 'residual_noexc'
+ return 'residual'
assert len(colors) == 1, colors # buggy normalization?
return color
@@ -626,9 +632,9 @@
postconstantblock.recloseblock(Link([], resumeblock))
if nonconstantblock is not None:
- v_res, nonconstantblock2 = self.handle_residual_call_details(nonconstantblock, 0,
- op, color,
- preserve_res = False)
+ v_res, nonconstantblock2 = self.handle_residual_call_details(
+ nonconstantblock, 0, op,
+ color, preserve_res = False)
if color == 'red':
linkargs[0] = v_res
@@ -722,16 +728,21 @@
SSA_to_SSI({block: True,
postblock: False}, self.hannotator)
- def handle_residual_call(self, block, pos):
+ def handle_residual_call(self, block, pos, qualifiers=[]):
op = block.operations[pos]
if op.result.concretetype is lltype.Void:
color = 'gray'
else:
color = 'red'
- v_res, _ = self.handle_residual_call_details(block, pos, op, color)
+ v_res, _ = self.handle_residual_call_details(block, pos, op, color,
+ qualifiers=qualifiers)
return v_res
+
+ def handle_residual_noexc_call(self, block, pos):
+ return self.handle_residual_call(block, pos, qualifiers=['noexc'])
- def handle_residual_call_details(self, block, pos, op, color, preserve_res=True):
+ def handle_residual_call_details(self, block, pos, op, color,
+ preserve_res=True, qualifiers=[]):
if op.opname == 'direct_call':
args_v = op.args[1:]
elif op.opname == 'indirect_call':
@@ -743,7 +754,8 @@
args_v = [v for v in args_v if v.concretetype is not lltype.Void]
self.genop(newops, 'save_locals', args_v)
call_index = len(newops)
- v_res = self.genop(newops, 'residual_%s_call' % (color,),
+ qualifiers = '_'.join([color] + qualifiers)
+ v_res = self.genop(newops, 'residual_%s_call' % (qualifiers,),
[op.args[0]], result_like = op.result)
v_shape = self.genop(newops, 'after_residual_call', [], resulttype=lltype.Signed, red=True)
reshape_index = len(newops)
More information about the Pypy-commit
mailing list