[pypy-commit] pypy guard-compatible: Trying to fix for full translation
arigo
pypy.commits at gmail.com
Mon May 23 09:51:05 EDT 2016
Author: Armin Rigo <arigo at tunes.org>
Branch: guard-compatible
Changeset: r84624:29816d0227a5
Date: 2016-05-23 15:51 +0200
http://bitbucket.org/pypy/pypy/changeset/29816d0227a5/
Log: Trying to fix for full translation
diff --git a/rpython/jit/backend/x86/guard_compat.py b/rpython/jit/backend/x86/guard_compat.py
--- a/rpython/jit/backend/x86/guard_compat.py
+++ b/rpython/jit/backend/x86/guard_compat.py
@@ -175,7 +175,7 @@
# ____________________________________________________________
-PAIR = lltype.Struct('PAIR', ('gcref', llmemory.GCREF),
+PAIR = lltype.Struct('PAIR', ('gcref', lltype.Unsigned), # a GC ref or -1
('asmaddr', lltype.Signed))
BACKEND_CHOICES = lltype.GcStruct('BACKEND_CHOICES',
('bc_faildescr', llmemory.GCREF),
@@ -246,6 +246,9 @@
_nowrapper=True,
compilation_info=eci)
+def gcref_to_unsigned(gcref):
+ return rffi.cast(lltype.Unsigned, gcref)
+
INVOKE_FIND_COMPATIBLE_FUNC = lltype.Ptr(lltype.FuncType(
[lltype.Ptr(BACKEND_CHOICES), llmemory.GCREF],
@@ -269,8 +272,9 @@
bchoices_int = rffi.cast(lltype.Signed, bchoices)
llop.raw_store(lltype.Void, choices_addr, 0, bchoices_int)
# ---no GC operation end---
- bchoices.bc_most_recent.gcref = new_gcref
+ bchoices.bc_most_recent.gcref = gcref_to_unsigned(new_gcref)
bchoices.bc_most_recent.asmaddr = result
+ llop.gc_writebarrier(lltype.Void, bchoices)
return result
except: # oops!
if not we_are_translated():
@@ -289,7 +293,7 @@
ofs = _real_number(ofs)
if llop.raw_load(lltype.Unsigned, gcref_base, ofs) != r_uint(-1):
# reallocate
- new_bchoices = lltype.malloc(BACKEND_CHOICES, length * 2 + 1, zero=True)
+ new_bchoices = lltype.malloc(BACKEND_CHOICES, length * 2 + 1)
# --- no GC below: it would mess up the order of bc_list ---
new_bchoices.bc_faildescr = bchoices.bc_faildescr
new_bchoices.bc_most_recent.gcref = bchoices.bc_most_recent.gcref
@@ -310,8 +314,9 @@
i += 1
bchoices = new_bchoices
#
- bchoices.bc_list[length - 1].gcref = new_gcref
+ bchoices.bc_list[length - 1].gcref = gcref_to_unsigned(new_gcref)
bchoices.bc_list[length - 1].asmaddr = new_asmaddr
+ llop.gc_writebarrier(lltype.Void, bchoices)
# --- no GC above ---
addr = llmemory.cast_ptr_to_adr(bchoices)
addr += BCLIST + BCLISTITEMSOFS
@@ -321,10 +326,11 @@
def initial_bchoices(guard_compat_descr, initial_gcref):
bchoices = lltype.malloc(BACKEND_CHOICES, 1)
bchoices.bc_faildescr = cast_instance_to_gcref(guard_compat_descr)
- bchoices.bc_most_recent.gcref = initial_gcref
+ bchoices.bc_most_recent.gcref = gcref_to_unsigned(initial_gcref)
# bchoices.bc_most_recent.asmaddr: patch_guard_compatible()
- bchoices.bc_list[0].gcref = initial_gcref
+ bchoices.bc_list[0].gcref = gcref_to_unsigned(initial_gcref)
# bchoices.bc_list[0].asmaddr: patch_guard_compatible()
+ llop.gc_writebarrier(lltype.Void, bchoices)
return bchoices
def descr_to_bchoices(descr):
@@ -362,7 +368,8 @@
def invalidate_pair(bchoices, pair_ofs):
gcref_base = lltype.cast_opaque_ptr(llmemory.GCREF, bchoices)
llop.raw_store(lltype.Void, gcref_base, _real_number(pair_ofs), r_uint(-1))
- llop.raw_store(lltype.Void, gcref_base, _real_number(pair_ofs), r_uint(-1))
+ ofs = pair_ofs + llmemory.sizeof(lltype.Unsigned)
+ llop.raw_store(lltype.Void, gcref_base, _real_number(ofs), -1)
def invalidate_cache(faildescr):
"""Write -1 inside bchoices.bc_most_recent.gcref."""
diff --git a/rpython/jit/backend/x86/test/test_compatible.py b/rpython/jit/backend/x86/test/test_compatible.py
--- a/rpython/jit/backend/x86/test/test_compatible.py
+++ b/rpython/jit/backend/x86/test/test_compatible.py
@@ -14,16 +14,13 @@
b = lltype.malloc(BACKEND_CHOICES, 4)
invalidate_pair(b, BCMOSTRECENT)
x = b.bc_most_recent.gcref
- assert rffi.cast(lltype.Unsigned, x) == r_uint(-1)
+ assert x == r_uint(-1)
def check_bclist(bchoices, expected):
assert len(bchoices.bc_list) == len(expected)
for i in range(len(bchoices.bc_list)):
pair = bchoices.bc_list[i]
- if lltype.typeOf(expected[i][0]) == llmemory.GCREF:
- assert pair.gcref == expected[i][0]
- else:
- assert rffi.cast(lltype.Signed, pair.gcref) == expected[i][0]
+ assert pair.gcref == rffi.cast(lltype.Unsigned, expected[i][0])
assert pair.asmaddr == expected[i][1]
def test_add_in_tree():
@@ -41,9 +38,9 @@
(0, 0), # null
(0, 0), # null
(new_gcref, new_asmaddr),
- (-1, 0), # invalid
- (-1, 0), # invalid
- (-1, 0), # invalid
+ (-1, -1), # invalid
+ (-1, -1), # invalid
+ (-1, -1), # invalid
])
new_gcref_2 = rffi.cast(llmemory.GCREF, 717000) # lower than before
new_asmaddr_2 = 2345678
@@ -55,8 +52,8 @@
(0, 0), # null
(new_gcref_2, new_asmaddr_2),
(new_gcref, new_asmaddr),
- (-1, 0), # invalid
- (-1, 0), # invalid
+ (-1, -1), # invalid
+ (-1, -1), # invalid
])
new_gcref_3 = rffi.cast(llmemory.GCREF, 717984) # higher than before
new_asmaddr_3 = 3456789
@@ -69,7 +66,7 @@
(new_gcref_2, new_asmaddr_2),
(new_gcref, new_asmaddr),
(new_gcref_3, new_asmaddr_3),
- (-1, 0), # invalid
+ (-1, -1), # invalid
])
def test_guard_compat():
@@ -135,7 +132,7 @@
print 'calling with the standard gcref'
res = call_me(bchoices, gcref)
assert res == 0xaaaa - 0xdddd
- assert bchoices.bc_most_recent.gcref == gcref
+ assert bchoices.bc_most_recent.gcref == 111111
assert bchoices.bc_most_recent.asmaddr == rawstart + sequel
seen = []
@@ -151,7 +148,7 @@
res = call_me(bchoices, gcref)
assert res == 1000010
assert len(seen) == 1 + i
- assert bchoices.bc_most_recent.gcref == gcref
+ assert bchoices.bc_most_recent.gcref == 123456 + i
assert bchoices.bc_most_recent.asmaddr == rawstart + failure
# ---- grow bchoices ----
@@ -173,7 +170,7 @@
print 'calling with new choice', intgcref
res = call_me(bchoices, gcref)
assert res == expected_res
- assert bchoices.bc_most_recent.gcref == gcref
+ assert bchoices.bc_most_recent.gcref == intgcref
assert bchoices.bc_most_recent.asmaddr == expected_asmaddr
More information about the pypy-commit
mailing list