Author: Armin Rigo <[email protected]>
Branch:
Changeset: r55279:c6a1519817b1
Date: 2012-06-03 11:00 +0200
http://bitbucket.org/pypy/pypy/changeset/c6a1519817b1/
Log: Fix the test.
diff --git a/pypy/jit/backend/test/runner_test.py
b/pypy/jit/backend/test/runner_test.py
--- a/pypy/jit/backend/test/runner_test.py
+++ b/pypy/jit/backend/test/runner_test.py
@@ -1835,12 +1835,12 @@
assert not excvalue
def test_cond_call_gc_wb(self):
- def func_void(a, b):
- record.append((a, b))
+ def func_void(a):
+ record.append(a)
record = []
#
S = lltype.GcStruct('S', ('tid', lltype.Signed))
- FUNC = self.FuncType([lltype.Ptr(S), lltype.Ptr(S)], lltype.Void)
+ FUNC = self.FuncType([lltype.Ptr(S)], lltype.Void)
func_ptr = llhelper(lltype.Ptr(FUNC), func_void)
funcbox = self.get_funcbox(self.cpu, func_ptr)
class WriteBarrierDescr(AbstractDescr):
@@ -1866,26 +1866,25 @@
[BoxPtr(sgcref), ConstPtr(tgcref)],
'void', descr=WriteBarrierDescr())
if cond:
- assert record == [(s, t)]
+ assert record == [s]
else:
assert record == []
def test_cond_call_gc_wb_array(self):
- def func_void(a, b, c):
- record.append((a, b, c))
+ def func_void(a):
+ record.append(a)
record = []
#
S = lltype.GcStruct('S', ('tid', lltype.Signed))
- FUNC = self.FuncType([lltype.Ptr(S), lltype.Signed, lltype.Ptr(S)],
- lltype.Void)
+ FUNC = self.FuncType([lltype.Ptr(S)], lltype.Void)
func_ptr = llhelper(lltype.Ptr(FUNC), func_void)
funcbox = self.get_funcbox(self.cpu, func_ptr)
class WriteBarrierDescr(AbstractDescr):
jit_wb_if_flag = 4096
jit_wb_if_flag_byteofs = struct.pack("i", 4096).index('\x10')
jit_wb_if_flag_singlebyte = 0x10
- jit_wb_cards_set = 0
- def get_write_barrier_from_array_fn(self, cpu):
+ jit_wb_cards_set = 0 # <= without card marking
+ def get_write_barrier_fn(self, cpu):
return funcbox.getint()
#
for cond in [False, True]:
@@ -1902,13 +1901,15 @@
[BoxPtr(sgcref), ConstInt(123), BoxPtr(sgcref)],
'void', descr=WriteBarrierDescr())
if cond:
- assert record == [(s, 123, s)]
+ assert record == [s]
else:
assert record == []
def test_cond_call_gc_wb_array_card_marking_fast_path(self):
- def func_void(a, b, c):
- record.append((a, b, c))
+ def func_void(a):
+ record.append(a)
+ if cond == 1: # the write barrier sets the flag
+ s.data.tid |= 32768
record = []
#
S = lltype.Struct('S', ('tid', lltype.Signed))
@@ -1922,34 +1923,40 @@
('card6', lltype.Char),
('card7', lltype.Char),
('data', S))
- FUNC = self.FuncType([lltype.Ptr(S), lltype.Signed, lltype.Ptr(S)],
- lltype.Void)
+ FUNC = self.FuncType([lltype.Ptr(S)], lltype.Void)
func_ptr = llhelper(lltype.Ptr(FUNC), func_void)
funcbox = self.get_funcbox(self.cpu, func_ptr)
class WriteBarrierDescr(AbstractDescr):
jit_wb_if_flag = 4096
jit_wb_if_flag_byteofs = struct.pack("i", 4096).index('\x10')
jit_wb_if_flag_singlebyte = 0x10
- jit_wb_cards_set = 8192
- jit_wb_cards_set_byteofs = struct.pack("i", 8192).index('\x20')
- jit_wb_cards_set_singlebyte = 0x20
+ jit_wb_cards_set = 32768
+ jit_wb_cards_set_byteofs = struct.pack("i", 32768).index('\x80')
+ jit_wb_cards_set_singlebyte = -0x80
jit_wb_card_page_shift = 7
def get_write_barrier_from_array_fn(self, cpu):
return funcbox.getint()
#
- for BoxIndexCls in [BoxInt, ConstInt]:
- for cond in [False, True]:
+ for BoxIndexCls in [BoxInt, ConstInt]*3:
+ for cond in [-1, 0, 1, 2]:
+ # cond=-1:GCFLAG_TRACK_YOUNG_PTRS, GCFLAG_CARDS_SET are not set
+ # cond=0: GCFLAG_CARDS_SET is never set
+ # cond=1: GCFLAG_CARDS_SET is not set, but the wb sets it
+ # cond=2: GCFLAG_CARDS_SET is already set
print
print '_'*79
print 'BoxIndexCls =', BoxIndexCls
- print 'JIT_WB_CARDS_SET =', cond
+ print 'testing cond =', cond
print
value = random.randrange(-sys.maxint, sys.maxint)
- value |= 4096
- if cond:
- value |= 8192
+ if cond >= 0:
+ value |= 4096
else:
- value &= ~8192
+ value &= ~4096
+ if cond == 2:
+ value |= 32768
+ else:
+ value &= ~32768
s = lltype.malloc(S_WITH_CARDS, immortal=True, zero=True)
s.data.tid = value
sgcref = rffi.cast(llmemory.GCREF, s.data)
@@ -1958,11 +1965,13 @@
self.execute_operation(rop.COND_CALL_GC_WB_ARRAY,
[BoxPtr(sgcref), box_index, BoxPtr(sgcref)],
'void', descr=WriteBarrierDescr())
- if cond:
+ if cond in [0, 1]:
+ assert record == [s.data]
+ else:
assert record == []
+ if cond in [1, 2]:
assert s.card6 == '\x02'
else:
- assert record == [(s.data, (9<<7) + 17, s.data)]
assert s.card6 == '\x00'
assert s.card0 == '\x00'
assert s.card1 == '\x00'
@@ -1971,6 +1980,9 @@
assert s.card4 == '\x00'
assert s.card5 == '\x00'
assert s.card7 == '\x00'
+ if cond == 1:
+ value |= 32768
+ assert s.data.tid == value
def test_force_operations_returning_void(self):
values = []
diff --git a/pypy/jit/backend/x86/assembler.py
b/pypy/jit/backend/x86/assembler.py
--- a/pypy/jit/backend/x86/assembler.py
+++ b/pypy/jit/backend/x86/assembler.py
@@ -2446,6 +2446,13 @@
helper_num = card_marking
if self._regalloc.xrm.reg_bindings:
helper_num += 2
+ if self.wb_slowpath[helper_num] == 0: # tests only
+ assert not we_are_translated()
+ self.cpu.gc_ll_descr.write_barrier_descr = descr
+ self._build_wb_slowpath(card_marking,
+ bool(self._regalloc.xrm.reg_bindings))
+ assert self.wb_slowpath[helper_num] != 0
+ #
self.mc.PUSH(loc_base)
self.mc.CALL(imm(self.wb_slowpath[helper_num]))
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit