[pypy-svn] r63074 - in pypy/branch/pyjitpl5/pypy/jit/metainterp: . test
arigo at codespeak.net
arigo at codespeak.net
Thu Mar 19 15:36:27 CET 2009
Author: arigo
Date: Thu Mar 19 15:36:26 2009
New Revision: 63074
Modified:
pypy/branch/pyjitpl5/pypy/jit/metainterp/codewriter.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/pyjitpl.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_basic.py
Log:
Make the liveboxes lists more compact, with a test, step 1.
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 Thu Mar 19 15:36:26 2009
@@ -263,6 +263,9 @@
def make_bytecode_block(self, block):
if block.exits == ():
+ # note: the same label might be generated multiple times, but a
+ # jump to this label is free to pick whichever target so it's fine
+ self.emit(label(block))
if len(block.inputargs) == 1:
# return from function
returnvar, = block.inputargs
@@ -316,20 +319,19 @@
self.make_bytecode_block(link.target)
elif (len(block.exits) == 2
and block.exitswitch.concretetype == lltype.Bool):
- self.minimize_variables()
linkfalse, linktrue = block.exits
if linkfalse.llexitcase == True:
linkfalse, linktrue = linktrue, linkfalse
- truerenaming = self.insert_renaming(linktrue.args)
- falserenaming = self.insert_renaming(linkfalse.args)
+ truelist = self.get_renaming_list(linktrue.args)
+ falselist = self.get_renaming_list(linkfalse.args)
self.emit("goto_if_not",
self.var_position(block.exitswitch),
- tlabel(linkfalse))
- self.emit(*truerenaming)
+ tlabel(linkfalse.target))
+ self.emit(len(truelist), *truelist)
+ self.emit(len(falselist), *falselist)
self.make_bytecode_block(linktrue.target)
- self.emit(label(linkfalse))
- self.emit(*falserenaming)
- self.make_bytecode_block(linkfalse.target)
+ if linkfalse.target not in self.seen_blocks:
+ self.make_bytecode_block(linkfalse.target)
else:
self.minimize_variables()
switches = [link for link in block.exits
@@ -411,18 +413,18 @@
self.emit("put_last_exc_value", i)
self.make_bytecode_block(link.target)
- def insert_renaming(self, args, force=False):
+ def get_renaming_list(self, args):
args = [v for v in args if v.concretetype is not lltype.Void]
- if len(args) >= MAX_MAKE_NEW_VARS:
- code = ["make_new_vars", len(args)]
- else:
- code = ["make_new_vars_%d" % len(args)]
- for v in args:
- code.append(self.var_position(v))
- if (not force and len(args) == self.free_vars and
- code[len(code)-len(args):] == range(0, self.free_vars*2, 2)):
+ return [self.var_position(v) for v in args]
+
+ def insert_renaming(self, args, force=False):
+ list = self.get_renaming_list(args)
+ if not force and list == range(0, self.free_vars*2, 2):
return [] # no-op
- return code
+ if len(list) >= MAX_MAKE_NEW_VARS:
+ return ["make_new_vars", len(list)] + list
+ else:
+ return ["make_new_vars_%d" % len(list)] + list
def minimize_variables(self):
if self.dont_minimize_variables:
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 Thu Mar 19 15:36:26 2009
@@ -279,22 +279,28 @@
def opimpl_goto(self, target):
self.pc = target
- @arguments("box", "jumptarget")
- def opimpl_goto_if_not(self, box, target):
+ @arguments("box", "jumptarget", "varargs", "varargs")
+ def opimpl_goto_if_not(self, box, target, truelist, falselist):
switchcase = box.getint()
if switchcase:
currentpc = self.pc
+ currentenv = truelist
targetpc = target
+ targetenv = falselist
opnum = rop.GUARD_TRUE
const_if_fail = history.CONST_FALSE
else:
currentpc = target
+ currentenv = falselist
targetpc = self.pc
+ targetenv = truelist
opnum = rop.GUARD_FALSE
const_if_fail = history.CONST_TRUE
+ self.env = targetenv
self.generate_guard(targetpc, opnum, box, ignore_box=box,
const_if_fail=const_if_fail)
self.pc = currentpc
+ self.env = currentenv
@arguments("orgpc", "box", "constargs", "jumptargets")
def opimpl_switch(self, pc, valuebox, constargs, jumptargets):
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_basic.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_basic.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_basic.py Thu Mar 19 15:36:26 2009
@@ -142,9 +142,16 @@
return res
res = self.meta_interp(f, [6, 7])
assert res == 42
+ self.check_loop_count(1)
self.check_loops({'merge_point': 1, 'guard_true': 1,
'int_add': 1, 'int_sub': 1, 'int_gt': 1,
'jump': 1})
+ if self.basic:
+ for op in get_stats().loops[0].operations:
+ if op.getopname() == 'guard_true':
+ liveboxes = op.liveboxes
+ assert len(liveboxes) == 1
+ assert isinstance(liveboxes[0], history.BoxInt)
def test_string(self):
def f(n):
More information about the Pypy-commit
mailing list