[pypy-dev] Number of constants in a jitted rpython interpreter
Zariko Taba
zariko.taba at gmail.com
Thu Sep 22 15:01:32 CEST 2011
Hi pypy !
I'm still exploring rpython and I face a problem when adding a jit to an
interpreter.
In Assembler class (pypy.jit.codewriter.assembler), in emit_const method, it
seems to be assumed that there is no more than 256 constants. (constant
seems to be accessed in a array with a 1 byte index).
If I try to translate an interpreter with more than 256 constant objects
(like string ?), I get this error :
[translation:ERROR] Error:
[translation:ERROR] Traceback (most recent call last):
[translation:ERROR] File
"/home/olivier/workspace/talstai_ext/pypy-1.6-src/pypy/translator/goal/translate.py",
line 308, in main
[translation:ERROR] drv.proceed(goals)
[translation:ERROR] File
"/home/olivier/workspace/talstai_ext/pypy-1.6-src/pypy/translator/driver.py",
line 810, in proceed
[translation:ERROR] return self._execute(goals, task_skip =
self._maybe_skip())
[translation:ERROR] File
"/home/olivier/workspace/talstai_ext/pypy-1.6-src/pypy/translator/tool/taskengine.py",
line 116, in _execute
[translation:ERROR] res = self._do(goal, taskcallable, *args, **kwds)
[translation:ERROR] File
"/home/olivier/workspace/talstai_ext/pypy-1.6-src/pypy/translator/driver.py",
line 286, in _do
[translation:ERROR] res = func()
[translation:ERROR] File
"/home/olivier/workspace/talstai_ext/pypy-1.6-src/pypy/translator/driver.py",
line 397, in task_pyjitpl_lltype
[translation:ERROR] backend_name=self.config.translation.jit_backend,
inline=True)
[translation:ERROR] File
"/home/olivier/workspace/talstai_ext/pypy-1.6-src/pypy/jit/metainterp/warmspot.py",
line 42, in apply_jit
[translation:ERROR] **kwds)
[translation:ERROR] File
"/home/olivier/workspace/talstai_ext/pypy-1.6-src/pypy/jit/metainterp/warmspot.py",
line 199, in __init__
[translation:ERROR] self.codewriter.make_jitcodes(verbose=verbose)
[translation:ERROR] File
"/home/olivier/workspace/talstai_ext/pypy-1.6-src/pypy/jit/codewriter/codewriter.py",
line 72, in make_jitcodes
[translation:ERROR] self.transform_graph_to_jitcode(graph, jitcode,
verbose)
[translation:ERROR] File
"/home/olivier/workspace/talstai_ext/pypy-1.6-src/pypy/jit/codewriter/codewriter.py",
line 61, in transform_graph_to_jitcode
[translation:ERROR] self.assembler.assemble(ssarepr, jitcode)
[translation:ERROR] File
"/home/olivier/workspace/talstai_ext/pypy-1.6-src/pypy/jit/codewriter/assembler.py",
line 35, in assemble
[translation:ERROR] self.write_insn(insn)
[translation:ERROR] File
"/home/olivier/workspace/talstai_ext/pypy-1.6-src/pypy/jit/codewriter/assembler.py",
line 135, in write_insn
[translation:ERROR] is_short = self.emit_const(x, kind,
allow_short=True)
[translation:ERROR] File
"/home/olivier/workspace/talstai_ext/pypy-1.6-src/pypy/jit/codewriter/assembler.py",
line 108, in emit_const
[translation:ERROR] self.code.append(chr(self.constants_dict[key]))
[translation:ERROR] ValueError: character code not in range(256)
With this snippet of code :
self.constants_dict[key] = 256 - len(constants)
If len(constants) is 257,
then self.constants_dict[key] is -1
and chr(-1) raise the ValueError.
I attached a (really) stupid example to reproduce.
When I browse pypy sources in rpython, I can't believe there is less than
256 constants of type 'ref'.
What do you think ? Did I miss something ?
Thanks !
Zariko.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pypy-dev/attachments/20110922/d83483f8/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: many_constant.py
Type: text/x-python
Size: 24082 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/pypy-dev/attachments/20110922/d83483f8/attachment-0001.py>
More information about the pypy-dev
mailing list