Author: Maciej Fijalkowski <[email protected]>
Branch: continulet-jit-3
Changeset: r58261:3297b303f4c2
Date: 2012-10-19 21:56 +0200
http://bitbucket.org/pypy/pypy/changeset/3297b303f4c2/
Log: progress
diff --git a/pypy/jit/backend/llgraph/runner.py
b/pypy/jit/backend/llgraph/runner.py
--- a/pypy/jit/backend/llgraph/runner.py
+++ b/pypy/jit/backend/llgraph/runner.py
@@ -169,6 +169,7 @@
class MiniStats:
pass
self.stats = stats or MiniStats()
+ self.TOKEN_TRACING_RESCALL = NotAFrame()
def compile_loop(self, inputargs, operations, looptoken, log=True,
name=''):
clt = model.CompiledLoopToken(self, looptoken.number)
@@ -394,11 +395,13 @@
def bh_getfield_gc(self, p, descr):
if isinstance(descr, JFDescrDescr):
result = p.latest_descr
+ if result is None:
+ return lltype.nullptr(llmemory.GCREF.TO)
# <XXX> HACK
result._TYPE = llmemory.GCREF
result._identityhash = lambda: hash(result) # for rd_hash()
# <XXX/>
- return p.latest_descr
+ return result
p = support.cast_arg(lltype.Ptr(descr.S), p)
return support.cast_result(descr.FIELD, getattr(p, descr.fieldname))
@@ -581,8 +584,20 @@
def bh_read_timestamp(self):
return read_timestamp()
+class NotAFrame(object):
+ _TYPE = llmemory.GCREF
+
+ class latest_descr:
+ pass
+
+ def __eq__(self, other):
+ return isinstance(other, NotAFrame)
+ def __ne__(self, other):
+ return not (self == other)
+
class LLFrame(object):
_TYPE = llmemory.GCREF
+ latest_descr = None
# some obscure hacks to support comparison with llmemory.GCREF
def __ne__(self, other):
diff --git a/pypy/jit/metainterp/pyjitpl.py b/pypy/jit/metainterp/pyjitpl.py
--- a/pypy/jit/metainterp/pyjitpl.py
+++ b/pypy/jit/metainterp/pyjitpl.py
@@ -743,6 +743,10 @@
if not self._establish_nullity(jfbox, orgpc):
return # jfbox is NULL
cpu = self.metainterp.cpu
+ if jfbox.getref_base() == cpu.TOKEN_TRACING_RESCALL:
+ # we're trying to force a virtualizable that is being traced,
+ # abort as bad loop
+ raise SwitchToBlackhole(Counters.ABORT_BAD_LOOP)
descr = cpu.jitframe_get_jfdescr_descr()
jfdescrbox = self._opimpl_getfield_gc_any(jfbox, descr)
jfdescrbox = self.implement_guard_value(orgpc, jfdescrbox)
diff --git a/pypy/jit/metainterp/virtualizable.py
b/pypy/jit/metainterp/virtualizable.py
--- a/pypy/jit/metainterp/virtualizable.py
+++ b/pypy/jit/metainterp/virtualizable.py
@@ -16,6 +16,7 @@
def __init__(self, warmrunnerdesc, VTYPEPTR):
self.warmrunnerdesc = warmrunnerdesc
cpu = warmrunnerdesc.cpu
+ self.TOKEN_TRACING_RESCALL = cpu.TOKEN_TRACING_RESCALL
if cpu.ts.name == 'ootype':
import py
py.test.skip("ootype: fix virtualizables")
@@ -230,7 +231,7 @@
def tracing_before_residual_call(virtualizable):
virtualizable = cast_gcref_to_vtype(virtualizable)
assert virtualizable.jit_frame == jitframe.TOKEN_NONE
- virtualizable.jit_frame = jitframe.TOKEN_TRACING_RESCALL
+ virtualizable.jit_frame = self.TOKEN_TRACING_RESCALL
self.tracing_before_residual_call = tracing_before_residual_call
def tracing_after_residual_call(virtualizable):
@@ -238,7 +239,7 @@
if virtualizable.jit_frame != jitframe.TOKEN_NONE:
# not modified by the residual call; assert that it is still
# set to TOKEN_TRACING_RESCALL and clear it.
- assert virtualizable.jit_frame ==
jitframe.TOKEN_TRACING_RESCALL
+ assert virtualizable.jit_frame == self.TOKEN_TRACING_RESCALL
virtualizable.jit_frame = jitframe.TOKEN_NONE
return False
else:
@@ -248,7 +249,7 @@
def force_now(virtualizable):
token = virtualizable.jit_frame
- if token == jitframe.TOKEN_TRACING_RESCALL:
+ if token == self.TOKEN_TRACING_RESCALL:
# The values in the virtualizable are always correct during
# tracing. We only need to reset jit_frame to TOKEN_NONE
# as a marker for the tracing, to tell it that this
diff --git a/pypy/jit/metainterp/virtualref.py
b/pypy/jit/metainterp/virtualref.py
--- a/pypy/jit/metainterp/virtualref.py
+++ b/pypy/jit/metainterp/virtualref.py
@@ -9,6 +9,7 @@
def __init__(self, warmrunnerdesc):
self.warmrunnerdesc = warmrunnerdesc
self.cpu = warmrunnerdesc.cpu
+ self.TOKEN_TRACING_RESCALL = self.cpu.TOKEN_TRACING_RESCALL
# we make the low-level type of an RPython class directly
self.JIT_VIRTUAL_REF = lltype.GcStruct('JitVirtualRef',
('super', rclass.OBJECT),
@@ -86,7 +87,7 @@
return
vref = lltype.cast_opaque_ptr(lltype.Ptr(self.JIT_VIRTUAL_REF), gcref)
assert vref.jit_frame == jitframe.TOKEN_NONE
- vref.jit_frame = jitframe.TOKEN_TRACING_RESCALL
+ vref.jit_frame = self.TOKEN_TRACING_RESCALL
def tracing_after_residual_call(self, gcref):
if not self.is_virtual_ref(gcref):
@@ -96,7 +97,7 @@
if vref.jit_frame != jitframe.TOKEN_NONE:
# not modified by the residual call; assert that it is still
# set to TOKEN_TRACING_RESCALL and clear it.
- assert vref.jit_frame == jitframe.TOKEN_TRACING_RESCALL
+ assert vref.jit_frame == self.TOKEN_TRACING_RESCALL
vref.jit_frame = jitframe.TOKEN_NONE
return False
else:
@@ -108,7 +109,7 @@
return
assert real_object
vref = lltype.cast_opaque_ptr(lltype.Ptr(self.JIT_VIRTUAL_REF), gcref)
- assert vref.jit_frame != jitframe.TOKEN_TRACING_RESCALL
+ assert vref.jit_frame != self.TOKEN_TRACING_RESCALL
vref.jit_frame = jitframe.TOKEN_NONE
vref.forced = lltype.cast_opaque_ptr(rclass.OBJECTPTR, real_object)
@@ -142,7 +143,7 @@
vref = lltype.cast_pointer(lltype.Ptr(self.JIT_VIRTUAL_REF), inst)
token = vref.jit_frame
if token != jitframe.TOKEN_NONE:
- if token == jitframe.TOKEN_TRACING_RESCALL:
+ if token == self.TOKEN_TRACING_RESCALL:
# The "virtual" is not a virtual at all during tracing.
# We only need to reset jit_frame to TOKEN_NONE
# as a marker for the tracing, to tell it that this
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit