[pypy-svn] r63233 - in pypy/branch/pyjitpl5-simplify/pypy/jit: backend/llgraph metainterp metainterp/test
arigo at codespeak.net
arigo at codespeak.net
Mon Mar 23 16:13:45 CET 2009
Author: arigo
Date: Mon Mar 23 16:13:44 2009
New Revision: 63233
Modified:
pypy/branch/pyjitpl5-simplify/pypy/jit/backend/llgraph/llimpl.py
pypy/branch/pyjitpl5-simplify/pypy/jit/backend/llgraph/runner.py
pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/compile.py
pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/history.py
pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/pyjitpl.py
pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_basic.py
Log:
Still in-progress.
Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/backend/llgraph/llimpl.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/backend/llgraph/llimpl.py (original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/backend/llgraph/llimpl.py Mon Mar 23 16:13:44 2009
@@ -370,6 +370,7 @@
verbose)
except GuardFailed:
assert op.is_guard()
+ _stats.exec_conditional_jumps += 1
operations = op.subloop.operations
opindex = 0
continue
@@ -416,7 +417,7 @@
for i in range(len(values)):
if isinstance(values[i], ComputedIntSymbolic):
values[i] = values[i].compute_fn()
- res = '*'
+ res = NotImplemented
try:
res = ophandler(self, descr, *values)
finally:
@@ -424,7 +425,7 @@
argtypes, restype = TYPES[opname]
if res is None:
resdata = ''
- elif res == '*':
+ elif res is NotImplemented:
resdata = '*fail*'
else:
resdata = '-> ' + repr1(res, restype, self.memocast)
Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/backend/llgraph/runner.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/backend/llgraph/runner.py (original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/backend/llgraph/runner.py Mon Mar 23 16:13:44 2009
@@ -51,6 +51,7 @@
return '<Descr %r, %r, %r>' % (self.ofs, self.type, self.name)
return '<Descr %r, %r>' % (self.ofs, self.type)
+
class CPU(object):
def __init__(self, rtyper, stats=None, translate_support_code=False,
@@ -60,6 +61,7 @@
self.stats = stats or MiniStats()
self.stats.exec_counters = {}
self.stats.exec_jumps = 0
+ self.stats.exec_conditional_jumps = 0
self.memo_cast = llimpl.new_memo_cast()
self.fail_ops = []
llimpl._stats = self.stats
@@ -167,6 +169,18 @@
currentboxes.append(box)
return GuardFailure(op.key, currentboxes)
+ def get_exception(self):
+ return self.cast_adr_to_int(llimpl.get_exception())
+
+ def get_exc_value(self):
+ return llimpl.get_exc_value()
+
+ def clear_exception(self):
+ llimpl.clear_exception()
+
+ def set_overflow_error(self):
+ llimpl.set_overflow_error()
+
@staticmethod
def sizeof(S):
return Descr(symbolic.get_size(S))
@@ -317,22 +331,6 @@
else: # calldescr.type == 'v' # void
llimpl.do_call_void(func, self.memo_cast)
-class GuardFailed(object):
- returns = False
-
- def __init__(self, frame, guard_op):
- self.frame = frame
- self.guard_op = guard_op
-
- def make_ready_for_return(self, retbox):
- self.returns = True
- self.retbox = retbox
-
- def make_ready_for_continuing_at(self, merge_point):
- llimpl.frame_clear(self.frame, merge_point._compiled,
- merge_point._opindex)
- self.merge_point = merge_point
-
# ____________________________________________________________
import pypy.jit.metainterp.executor
Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/compile.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/compile.py (original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/compile.py Mon Mar 23 16:13:44 2009
@@ -111,10 +111,10 @@
loop.inputargs = history.inputargs
loop.operations = history.operations
close_loop(loop, endliveboxes)
- old_loop = optimize.optimize_loop(metainterp.options, old_loops, loop,
- metainterp.cpu)
- if old_loop is not None:
- return old_loop
+ #old_loop = optimize.optimize_loop(metainterp.options, old_loops, loop,
+ # metainterp.cpu)
+ #if old_loop is not None:
+ # return old_loop
send_loop_to_backend(metainterp, loop)
old_loops.append(loop)
return loop
Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/history.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/history.py (original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/history.py Mon Mar 23 16:13:44 2009
@@ -332,9 +332,9 @@
def __init__(self, name):
self.name = name
# self.inputargs = list of distinct Boxes
- # self.operations = ops of the kind 'guard_xxx' contain a further
- # list of operations, which may itself contain
- # 'guard_xxx' and so on, making a tree.
+ # self.operations = list of ResOperations
+ # ops of the kind 'guard_xxx' contain a further list of operations,
+ # which may itself contain 'guard_xxx' and so on, making a tree.
def _all_operations(self):
"NOT_RPYTHON"
@@ -442,11 +442,28 @@
def get_all_loops(self):
return self.loops
+ def check_history(self, expected=None, **check):
+ insns = {}
+ for op in self.history.operations:
+ opname = op.getopname()
+ insns[opname] = insns.get(opname, 0) + 1
+ if expected is not None:
+ # 'fail' operations may be omitted from 'expected'
+ if 'fail' in insns:
+ expected.setdefault('fail', insns['fail'])
+ assert insns == expected
+ for insn, expected_count in check.items():
+ assert insns.get(insn, 0) == expected_count
+ return insns
+
def check_loops(self, expected=None, **check):
insns = {}
for loop in self.loops:
insns = loop.summary(adding_insns=insns)
if expected is not None:
+ # 'fail' operations may be omitted from 'expected'
+ if 'fail' in insns:
+ expected.setdefault('fail', insns['fail'])
assert insns == expected
for insn, expected_count in check.items():
assert insns.get(insn, 0) == expected_count
Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/pyjitpl.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/pyjitpl.py (original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/pyjitpl.py Mon Mar 23 16:13:44 2009
@@ -762,6 +762,8 @@
def create_empty_history(self):
self.history = history.History(self.cpu)
+ if self.stats is not None:
+ self.stats.history = self.history
def delete_history(self):
# XXX call me again later
@@ -799,18 +801,22 @@
def interpret(self):
# Execute the frames forward until we raise a DoneWithThisFrame,
# a ContinueRunningNormally, or a GenerateMergePoint exception.
+ if isinstance(self.history, history.BlackHole):
+ text = ' (BlackHole)'
+ else:
+ text = ''
if not we_are_translated():
- history.log.event('ENTER')
+ history.log.event('ENTER' + text)
else:
- debug_print('~~~ ENTER')
+ debug_print('~~~ ENTER', text)
try:
while True:
self.framestack[-1].run_one_step()
finally:
if not we_are_translated():
- history.log.event('LEAVE')
+ history.log.event('LEAVE' + text)
else:
- debug_print('~~~ LEAVE')
+ debug_print('~~~ LEAVE', text)
def compile_and_run_once(self, *args):
orig_boxes = self.initialize_state_from_start(*args)
Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_basic.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_basic.py (original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_basic.py Mon Mar 23 16:13:44 2009
@@ -62,13 +62,12 @@
graph = cw.unfinished_graphs.pop()
cw.make_one_bytecode(graph, False)
metainterp.portal_code = maingraph
- metainterp.cpu.set_meta_interp(metainterp)
metainterp.delete_history()
metainterp.warmrunnerdesc = FakeWarmRunnderDesc
metainterp.DoneWithThisFrame = DoneWithThisFrame
self.metainterp = metainterp
try:
- metainterp.compile_and_run(*args)
+ metainterp.compile_and_run_once(*args)
except DoneWithThisFrame, e:
if conftest.option.view:
metainterp.stats.view()
@@ -143,15 +142,18 @@
res = self.meta_interp(f, [6, 7])
assert res == 42
self.check_loop_count(1)
- self.check_loops({'merge_point': 1, 'guard_true': 1,
+ self.check_loops({'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
+ found = 0
+ for op in get_stats().loops[0]._all_operations():
+ if op.getopname() == 'fail':
+ liveboxes = op.args
assert len(liveboxes) == 1
assert isinstance(liveboxes[0], history.BoxInt)
+ found += 1
+ assert found == 1
def test_string(self):
def f(n):
More information about the Pypy-commit
mailing list