[pypy-svn] r62106 - pypy/branch/pyjitpl5/pypy/jit/metainterp
arigo at codespeak.net
arigo at codespeak.net
Tue Feb 24 12:04:51 CET 2009
Author: arigo
Date: Tue Feb 24 12:04:49 2009
New Revision: 62106
Modified:
pypy/branch/pyjitpl5/pypy/jit/metainterp/compile.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/optimize.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/pyjitpl.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/warmspot.py
Log:
Add a class Options collecting the testing options that
we can enable or disable.
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/compile.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/compile.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/compile.py Tue Feb 24 12:04:49 2009
@@ -117,7 +117,7 @@
history = metainterp.history
loop.operations = history.operations
close_loop(loop, loop.operations[0], endliveboxes)
- old_loop = optimize.optimize_loop(metainterp, old_loops, loop)
+ old_loop = optimize.optimize_loop(metainterp.options, old_loops, loop)
if old_loop is not None:
return old_loop
finish_loop_or_bridge(metainterp, loop, loop.operations[0])
@@ -153,7 +153,7 @@
op = Jump('jump', endliveboxes, [])
operations.append(op)
#
- old_loop = optimize.optimize_bridge(metainterp, old_loops, bridge)
+ old_loop = optimize.optimize_bridge(metainterp.options, old_loops, bridge)
if old_loop is None:
return None
bridge.jump_to = old_loop
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 Feb 24 12:04:49 2009
@@ -206,15 +206,15 @@
return "<InstanceNode %s (%s)>" % (self.source, flags)
-def optimize_loop(metainterp, old_loops, loop):
- if not metainterp._specialize: # for tests only
+def optimize_loop(options, old_loops, loop):
+ if not options.specialize: # for tests only
if old_loops:
return old_loops[0]
else:
return None
# This does "Perfect specialization" as per doc/jitpl5.txt.
- perfect_specializer = PerfectSpecializer(loop)
+ perfect_specializer = PerfectSpecializer(loop, options)
perfect_specializer.find_nodes()
perfect_specializer.intersect_input_and_output()
for old_loop in old_loops:
@@ -223,11 +223,11 @@
perfect_specializer.optimize_loop()
return None
-def optimize_bridge(metainterp, old_loops, operations):
- if not metainterp._specialize: # for tests only
+def optimize_bridge(options, old_loops, bridge):
+ if not options.specialize: # for tests only
return old_loops[0]
- perfect_specializer = PerfectSpecializer(operations)
+ perfect_specializer = PerfectSpecializer(bridge, options)
perfect_specializer.find_nodes()
for old_loop in old_loops:
if perfect_specializer.match(old_loop.operations):
@@ -238,8 +238,9 @@
class PerfectSpecializer(object):
- def __init__(self, loop):
+ def __init__(self, loop, options):
self.loop = loop
+ self.options = options
self.nodes = {}
self.dependency_graph = []
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 Feb 24 12:04:49 2009
@@ -405,32 +405,32 @@
args.append(ConstInt(0))
else:
args.append(ConstPtr(lltype.nullptr(llmemory.GCREF.TO)))
- self.execute_with_exc('newlist', args, 'ptr')
+ return self.execute_with_exc('newlist', args, 'ptr')
@arguments("builtin", "varargs")
def opimpl_append(self, descr, varargs):
args = [descr.append_func] + varargs
- self.execute_with_exc('append', args, 'void')
+ return self.execute_with_exc('append', args, 'void')
@arguments("builtin", "varargs")
def opimpl_insert(self, descr, varargs):
args = [descr.insert_func] + varargs
- self.execute_with_exc('insert', args, 'void')
+ return self.execute_with_exc('insert', args, 'void')
@arguments("builtin", "varargs")
def opimpl_pop(self, descr, varargs):
args = [descr.pop_func] + varargs
- self.execute_with_exc('pop', args, descr.tp)
+ return self.execute_with_exc('pop', args, descr.tp)
@arguments("builtin", "varargs")
def opimpl_len(self, descr, varargs):
args = [descr.len_func] + varargs
- self.execute_with_exc('len', args, 'int')
+ return self.execute_with_exc('len', args, 'int')
@arguments("builtin", "varargs")
def opimpl_listnonzero(self, descr, varargs):
args = [descr.nonzero_func] + varargs
- self.execute_with_exc('listnonzero', args, 'int')
+ return self.execute_with_exc('listnonzero', args, 'int')
@arguments("indirectcallset", "box", "varargs")
def opimpl_indirect_call(self, indirectcallset, box, varargs):
@@ -662,11 +662,11 @@
class OOMetaInterp(object):
num_green_args = 0
- def __init__(self, portal_graph, graphs, cpu, stats, specialize):
+ def __init__(self, portal_graph, graphs, cpu, stats, options):
self.portal_graph = portal_graph
self.cpu = cpu
self.stats = stats
- self._specialize = specialize
+ self.options = options
self.compiled_merge_points = r_dict(history.mp_eq, history.mp_hash)
# { greenkey: list-of-MergePoints }
@@ -1006,3 +1006,10 @@
class GenerateMergePoint(Exception):
def __init__(self, args):
self.argboxes = args
+
+
+class Options:
+ def __init__(self, specialize=True):
+ self.specialize = specialize
+ def _freeze_(self):
+ return True
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/warmspot.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/warmspot.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/warmspot.py Tue Feb 24 12:04:49 2009
@@ -12,7 +12,7 @@
from pypy.rlib.rarithmetic import r_uint
from pypy.jit.metainterp import support, history, pyjitpl
-from pypy.jit.metainterp.pyjitpl import OOMetaInterp
+from pypy.jit.metainterp.pyjitpl import OOMetaInterp, Options
from pypy.jit.backend.llgraph import runner
from pypy.jit.metainterp.policy import JitPolicy
@@ -97,9 +97,9 @@
def _freeze_(self):
return True
- def build_meta_interp(self, specialize=True,
- CPUClass=runner.CPU, view="auto",
- translate_support_code=False):
+ def build_meta_interp(self, CPUClass=runner.CPU, view="auto",
+ translate_support_code=False, **kwds):
+ opt = Options(**kwds)
self.stats = history.Stats()
cpu = CPUClass(self.translator.rtyper, self.stats,
translate_support_code)
@@ -118,8 +118,7 @@
self.translator.graphs.append(graph)
self.portal_graph = graph
self.jitdriver = block.operations[pos].args[1].value
- self.metainterp = OOMetaInterp(graph, graphs, cpu, self.stats,
- specialize)
+ self.metainterp = OOMetaInterp(graph, graphs, cpu, self.stats, opt)
def make_enter_function(self):
WarmEnterState = make_state_class(self)
More information about the Pypy-commit
mailing list