[pypy-svn] r62695 - in pypy/branch/pyjitpl5/pypy: . config jit/backend jit/metainterp jit/tl translator translator/goal translator/test
arigo at codespeak.net
arigo at codespeak.net
Sat Mar 7 13:01:18 CET 2009
Author: arigo
Date: Sat Mar 7 13:01:14 2009
New Revision: 62695
Added:
pypy/branch/pyjitpl5/pypy/jit/backend/detect_cpu.py
- copied, changed from r62149, pypy/branch/oo-jit/pypy/jit/codegen/detect_cpu.py
Modified:
pypy/branch/pyjitpl5/pypy/config/translationoption.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/warmspot.py
pypy/branch/pyjitpl5/pypy/jit/tl/targettlc.py
pypy/branch/pyjitpl5/pypy/jit/tl/tlc.py
pypy/branch/pyjitpl5/pypy/testrunner_cfg.py
pypy/branch/pyjitpl5/pypy/translator/driver.py
pypy/branch/pyjitpl5/pypy/translator/goal/translate.py
pypy/branch/pyjitpl5/pypy/translator/test/test_driver.py
Log:
Port the driver to the new JIT.
Adapt targettlc (although it still crashes).
Modified: pypy/branch/pyjitpl5/pypy/config/translationoption.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/config/translationoption.py (original)
+++ pypy/branch/pyjitpl5/pypy/config/translationoption.py Sat Mar 7 13:01:14 2009
@@ -108,6 +108,11 @@
BoolOption("rweakref", "The backend supports RPython-level weakrefs",
default=True),
+ # JIT generation
+ BoolOption("jit", "generate a JIT",
+ default=False, cmdline="--jit",
+ requires=[("translation.gc", "boehm")]),
+
# misc
BoolOption("verbose", "Print extra information", default=False),
BoolOption("debug", "Record extra annotation information",
@@ -126,7 +131,7 @@
ChoiceOption("fork_before",
"(UNIX) Create restartable checkpoint before step",
["annotate", "rtype", "backendopt", "database", "source",
- "hintannotate", "timeshift"],
+ "pyjitpl"],
default=None, cmdline="--fork-before"),
ArbitraryOption("instrumentctl", "internal",
Copied: pypy/branch/pyjitpl5/pypy/jit/backend/detect_cpu.py (from r62149, pypy/branch/oo-jit/pypy/jit/codegen/detect_cpu.py)
==============================================================================
--- pypy/branch/oo-jit/pypy/jit/codegen/detect_cpu.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/detect_cpu.py Sat Mar 7 13:01:14 2009
@@ -39,3 +39,11 @@
}[mach]
except KeyError:
raise ProcessorAutodetectError, "unsupported processor '%s'" % mach
+
+def getcpuclass():
+ cpu = autodetect()
+ if cpu == 'i386':
+ from pypy.jit.backend.x86.runner import CPU
+ else:
+ raise Exception('Unsuported cpu %r' % cpu)
+ return CPU
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 Sat Mar 7 13:01:14 2009
@@ -19,6 +19,13 @@
# ____________________________________________________________
# Bootstrapping
+def apply_jit(translator, **kwds):
+ from pypy.jit.backend.detect_cpu import getcpuclass
+ warmrunnerdesc = WarmRunnerDesc(translator, CPUClass=getcpuclass(),
+ translate_support_code=True,
+ **kwds)
+ warmrunnerdesc.finish()
+
def ll_meta_interp(function, args, backendopt=False, **kwds):
interp, graph = get_interpreter(function, args, backendopt=backendopt,
inline_threshold=0)
Modified: pypy/branch/pyjitpl5/pypy/jit/tl/targettlc.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/tl/targettlc.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/tl/targettlc.py Sat Mar 7 13:01:14 2009
@@ -1,8 +1,9 @@
import time
import py
py.magic.autopath()
-from pypy.jit.tl.tlc import interp, interp_eval, interp_nonjit, ConstantPool
-from pypy.jit.codegen.hlinfo import highleveljitinfo
+from pypy.jit.tl.tlc import interp, interp_nonjit, ConstantPool
+from pypy.jit.metainterp.policy import JitPolicy
+from pypy.jit.backend.hlinfo import highleveljitinfo
def entry_point(args):
@@ -57,18 +58,9 @@
# ____________________________________________________________
-from pypy.jit.hintannotator.policy import HintAnnotatorPolicy
-
-class MyHintAnnotatorPolicy(HintAnnotatorPolicy):
- novirtualcontainer = True
- oopspec = True
-
-def portal(driver):
- """Return the 'portal' function, and the hint-annotator policy.
- The portal is the function that gets patched with a call to the JIT
- compiler.
- """
- return interp_eval, MyHintAnnotatorPolicy()
+def jitpolicy(driver):
+ """Returns the JIT policy to use when translating."""
+ return JitPolicy()
if __name__ == '__main__':
import sys
Modified: pypy/branch/pyjitpl5/pypy/jit/tl/tlc.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/tl/tlc.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/tl/tlc.py Sat Mar 7 13:01:14 2009
@@ -251,8 +251,9 @@
pc = frame.pc
while pc < len(code):
- myjitdriver.jit_merge_point(frame=frame, framestack=framestack,
- code=code, pc=pc, pool=pool)
+ if jitted:
+ myjitdriver.jit_merge_point(frame=frame, framestack=framestack,
+ code=code, pc=pc, pool=pool)
opcode = ord(code[pc])
pc += 1
stack = frame.stack
@@ -352,7 +353,7 @@
old_pc = pc
pc += char2int(code[pc])
pc += 1
- if old_pc > pc:
+ if jitted and old_pc > pc:
myjitdriver.can_enter_jit(code=code, pc=pc, frame=frame,
framestack=framestack,
pool=pool)
@@ -362,7 +363,7 @@
if cond.t():
old_pc = pc
pc += char2int(code[pc]) + 1
- if old_pc > pc:
+ if jitted and old_pc > pc:
myjitdriver.can_enter_jit(code=code, pc=pc, frame=frame,
framestack=framestack,
pool=pool)
@@ -374,7 +375,7 @@
if stack.pop().t():
old_pc = pc
pc += offset
- if old_pc > pc:
+ if jitted and old_pc > pc:
myjitdriver.can_enter_jit(code=code, pc=pc, frame=frame,
framestack=framestack,
pool=pool)
Modified: pypy/branch/pyjitpl5/pypy/testrunner_cfg.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/testrunner_cfg.py (original)
+++ pypy/branch/pyjitpl5/pypy/testrunner_cfg.py Sat Mar 7 13:01:14 2009
@@ -1,9 +1,7 @@
# nightly test configuration for the paraller runner
def collect_one_testdir(testdirs, reldir, tests):
- if (reldir.startswith('jit/codegen/i386/') or
- reldir.startswith('jit/timeshifter/') or
- reldir.startswith('translator/c/') or
+ if (reldir.startswith('translator/c/') or
reldir.startswith('rlib/test') or
reldir.startswith('rpython/memory/')):
testdirs.extend(tests)
Modified: pypy/branch/pyjitpl5/pypy/translator/driver.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/translator/driver.py (original)
+++ pypy/branch/pyjitpl5/pypy/translator/driver.py Sat Mar 7 13:01:14 2009
@@ -121,8 +121,7 @@
else:
task, postfix = parts
if task in ('rtype', 'backendopt', 'llinterpret',
- 'prehannotatebackendopt', 'hintannotate',
- 'timeshift'):
+ 'prejitbackendopt', 'pyjitpl'):
if ts:
if ts == postfix:
expose_task(task, explicit_task)
@@ -356,7 +355,7 @@
task_rtype_ootype = taskdef(task_rtype_ootype, ['annotate'], "ootyping")
OOTYPE = 'rtype_ootype'
- def task_prehannotatebackendopt_lltype(self):
+ def task_prejitbackendopt_lltype(self):
from pypy.translator.backendopt.all import backend_optimizations
backend_optimizations(self.translator,
inline_threshold=0,
@@ -365,73 +364,30 @@
raisingop2direct_call=False,
remove_asserts=True)
#
- task_prehannotatebackendopt_lltype = taskdef(
- task_prehannotatebackendopt_lltype,
+ task_prejitbackendopt_lltype = taskdef(
+ task_prejitbackendopt_lltype,
[RTYPE],
- "Backendopt before Hint-annotate")
+ "Backendopt before jitting")
- def task_hintannotate_lltype(self):
- raise NotImplementedError("JIT is not implemented on trunk, look at oo-jit branch instead")
- from pypy.jit.hintannotator.annotator import HintAnnotator
- from pypy.jit.hintannotator.model import OriginFlags
- from pypy.jit.hintannotator.model import SomeLLAbstractConstant
-
- get_portal = self.extra['portal']
- PORTAL, POLICY = get_portal(self)
- t = self.translator
- self.portal_graph = graphof(t, PORTAL)
-
- hannotator = HintAnnotator(base_translator=t, policy=POLICY)
- self.hint_translator = hannotator.translator
- hs = hannotator.build_types(self.portal_graph,
- [SomeLLAbstractConstant(v.concretetype,
- {OriginFlags(): True})
- for v in self.portal_graph.getargs()])
- count = hannotator.bookkeeper.nonstuboriggraphcount
- stubcount = hannotator.bookkeeper.stuboriggraphcount
- self.log.info("The hint-annotator saw %d graphs"
- " (and made stubs for %d graphs)." % (count, stubcount))
- n = len(list(hannotator.translator.graphs[0].iterblocks()))
- self.log.info("portal has %d blocks" % n)
- self.hannotator = hannotator
- #
- task_hintannotate_lltype = taskdef(task_hintannotate_lltype,
- ['prehannotatebackendopt_lltype'],
- "Hint-annotate")
-
- def task_timeshift_lltype(self):
- raise NotImplementedError("JIT is not implemented on trunk, look at oo-jit branch instead")
-
- from pypy.jit.timeshifter.hrtyper import HintRTyper
- from pypy.jit.codegen import detect_cpu
- cpu = detect_cpu.autodetect()
- if cpu == 'i386':
- from pypy.jit.codegen.i386.rgenop import RI386GenOp as RGenOp
- RGenOp.MC_SIZE = 32 * 1024 * 1024
- elif cpu == 'ppc':
- from pypy.jit.codegen.ppc.rgenop import RPPCGenOp as RGenOp
- RGenOp.MC_SIZE = 32 * 1024 * 1024
- else:
- raise Exception('Unsuported cpu %r'%cpu)
-
- del self.hint_translator
- ha = self.hannotator
- t = self.translator
- # make the timeshifted graphs
- hrtyper = HintRTyper(ha, t.rtyper, RGenOp)
- hrtyper.specialize(origportalgraph=self.portal_graph, view=False)
- #
- task_timeshift_lltype = taskdef(task_timeshift_lltype,
- ["hintannotate_lltype"],
- "Timeshift")
+ def task_pyjitpl_lltype(self):
+ get_policy = self.extra['jitpolicy']
+ self.jitpolicy = get_policy(self)
+ #
+ from pypy.jit.metainterp.warmspot import apply_jit
+ apply_jit(self.translator)
+ #
+ self.log.info("the JIT compiler was generated")
+ #
+ task_pyjitpl_lltype = taskdef(task_pyjitpl_lltype,
+ [RTYPE, '?prejitbackendopt_lltype'],
+ "JIT compiler generation")
def task_backendopt_lltype(self):
from pypy.translator.backendopt.all import backend_optimizations
backend_optimizations(self.translator)
#
task_backendopt_lltype = taskdef(task_backendopt_lltype,
- [RTYPE,
- '??timeshift_lltype'],
+ [RTYPE, '??pyjitpl_lltype'],
"lltype back-end optimisations")
BACKENDOPT = 'backendopt_lltype'
Modified: pypy/branch/pyjitpl5/pypy/translator/goal/translate.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/translator/goal/translate.py (original)
+++ pypy/branch/pyjitpl5/pypy/translator/goal/translate.py Sat Mar 7 13:01:14 2009
@@ -20,14 +20,12 @@
GOALS= [
("annotate", "do type inference", "-a --annotate", ""),
("rtype", "do rtyping", "-t --rtype", ""),
- ("prehannotatebackendopt", "backend optimize before hint-annotating",
- "--prehannotatebackendopt", ""),
- ("hintannotate", "hint-annotate", "--hintannotate", ""),
- ("timeshift", "timeshift (jit generation)", "--timeshift", ""),
+ ("prejitbackendopt", "backend optimize before jitting",
+ "--prejitbackendopt", ""),
+ ("pyjitpl", "JIT generation step", "--pyjitpl", ""),
("backendopt", "do backend optimizations", "--backendopt", ""),
("source", "create source", "-s --source", ""),
("compile", "compile", "-c --compile", " (default goal)"),
- ("?jit", "generate JIT", "--jit", ""),
("run", "run the resulting binary", "--run", ""),
("llinterpret", "interpret the rtyped flow graphs", "--llinterpret", ""),
]
@@ -258,10 +256,10 @@
disable=translateconfig.skipped_goals,
default_goal='compile')
log_config(translateconfig, "translate.py configuration")
- if translateconfig.goal_options.jit:
- if 'portal' not in targetspec_dic:
- raise Exception('target has no portal defined.')
- drv.set_extra_goals(['timeshift'])
+ if config.translation.jit:
+ if 'jitpolicy' not in targetspec_dic:
+ raise Exception('target has no jitpolicy defined.')
+ drv.set_extra_goals(['pyjitpl'])
log_config(config.translation, "translation configuration")
pdb_plus_show.expose({'drv': drv, 'prof': prof})
Modified: pypy/branch/pyjitpl5/pypy/translator/test/test_driver.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/translator/test/test_driver.py (original)
+++ pypy/branch/pyjitpl5/pypy/translator/test/test_driver.py Sat Mar 7 13:01:14 2009
@@ -6,8 +6,7 @@
def test_ctr():
td = TranslationDriver()
expected = ['annotate', 'backendopt', 'llinterpret', 'rtype', 'source',
- 'compile', 'run', 'prehannotatebackendopt', 'hintannotate',
- 'timeshift']
+ 'compile', 'run', 'prejitbackendopt', 'pyjitpl']
assert set(td.exposed) == set(expected)
assert td.backend_select_goals(['compile_c']) == ['compile_c']
@@ -37,8 +36,7 @@
'compile_llvm', 'compile_js',
'run_llvm', 'run_c', 'run_js', 'run_cli',
'compile_jvm', 'source_jvm', 'run_jvm',
- 'prehannotatebackendopt_lltype', 'hintannotate_lltype',
- 'timeshift_lltype']
+ 'prejitbackendopt_lltype', 'pyjitpl_lltype']
assert set(td.exposed) == set(expected)
td = TranslationDriver({'backend': None, 'type_system': 'lltype'})
@@ -53,6 +51,6 @@
expected = ['annotate', 'backendopt', 'llinterpret', 'rtype', 'source_c',
'source_llvm', 'compile_c', 'compile_llvm', 'run_llvm',
- 'run_c', 'prehannotatebackendopt', 'hintannotate', 'timeshift']
+ 'run_c', 'prejitbackendopt', 'pyjitpl']
assert set(td.exposed) == set(expected)
More information about the Pypy-commit
mailing list