[pypy-commit] pypy stmgc-c4: test and fix repeat_barriers
Raemi
noreply at buildbot.pypy.org
Tue Oct 22 14:51:00 CEST 2013
Author: Remi Meier <remi.meier at gmail.com>
Branch: stmgc-c4
Changeset: r67514:c8762b1eb64d
Date: 2013-10-22 14:49 +0200
http://bitbucket.org/pypy/pypy/changeset/c8762b1eb64d/
Log: test and fix repeat_barriers
diff --git a/TODO b/TODO
--- a/TODO
+++ b/TODO
@@ -1,3 +1,7 @@
+------------------------------------------------------------
+
+stm-jitdriver with autoreds
+
------------------------------------------------------------
try to let non-atomic inevitable transactions run for longer, until
@@ -59,8 +63,4 @@
* maybe GUARD_NOT_INEVITABLE after call_may_force, call_assembler
which is a small check if we are inevitable and does a transaction_break
if we are.
-** do not access thread-locals through thread_descriptor, but directly
-** have two versions of stm_transaction_break(1/2). One for after calls
- which simply checks if the transaction is inevitable, and one to place
- before JUMPs which calls stm_should_break_transaction()
* look at XXXs for STM everywhere
diff --git a/rpython/jit/backend/x86/assembler.py b/rpython/jit/backend/x86/assembler.py
--- a/rpython/jit/backend/x86/assembler.py
+++ b/rpython/jit/backend/x86/assembler.py
@@ -2555,6 +2555,7 @@
#
# check flags:
if descr.stmcat in ['A2W', 'V2W', 'Q2R']:
+ flags = 0
if descr.stmcat in ['A2W', 'V2W']:
# obj->h_tid & GCFLAG_WRITE_BARRIER) != 0
assert IS_X86_64 and (StmGC.GCFLAG_WRITE_BARRIER >> 32) > 0
@@ -2576,7 +2577,8 @@
mc.J_il8(rx86.Conditions['Z'], 0) # patched below
jz_location = mc.get_relative_pos()
# if flags not set, jump to end
- # jump target slowpath:
+ # jump target slowpath:
+ if jnz_location:
offset = mc.get_relative_pos() - jnz_location
assert 0 < offset <= 127
mc.overwrite(jnz_location - 1, chr(offset))
diff --git a/rpython/jit/backend/x86/test/test_stm_integration.py b/rpython/jit/backend/x86/test/test_stm_integration.py
--- a/rpython/jit/backend/x86/test/test_stm_integration.py
+++ b/rpython/jit/backend/x86/test/test_stm_integration.py
@@ -258,7 +258,7 @@
self.a2wd = cpu.gc_ll_descr.A2Wdescr
self.v2wd = cpu.gc_ll_descr.V2Wdescr
self.a2rd = cpu.gc_ll_descr.A2Rdescr
- self.Q2rd = cpu.gc_ll_descr.Q2Rdescr
+ self.q2rd = cpu.gc_ll_descr.Q2Rdescr
TP = rffi.CArray(lltype.Signed)
self.priv_rev_num = lltype.malloc(TP, 1, flavor='raw')
@@ -358,6 +358,40 @@
descr.llop1.set_cache_item(sgcref, 0)
+ def test_gc_repeat_read_barrier_fastpath(self):
+ from rpython.jit.backend.llsupport.gc import STMReadBarrierDescr
+ descr = STMReadBarrierDescr(self.cpu.gc_ll_descr, 'Q2R')
+
+ called = []
+ def read(obj):
+ called.append(obj)
+ return obj
+
+ functype = lltype.Ptr(lltype.FuncType(
+ [llmemory.Address], llmemory.Address))
+ funcptr = llhelper(functype, read)
+ descr.b_failing_case_ptr = funcptr
+ descr.llop1 = fakellop()
+
+ # -------- TEST --------
+ for flags in [StmGC.GCFLAG_PUBLIC_TO_PRIVATE|StmGC.GCFLAG_MOVED, 0]:
+ called[:] = []
+
+ s = self.allocate_prebuilt_s()
+ sgcref = lltype.cast_opaque_ptr(llmemory.GCREF, s)
+ s.h_tid |= flags
+
+ descr._do_barrier(sgcref,
+ returns_modified_object=True)
+
+ # check if rev-fastpath worked
+ if not flags:
+ # fastpath
+ self.assert_not_in(called, [sgcref])
+ else:
+ self.assert_in(called, [sgcref])
+
+
def test_gc_write_barrier_fastpath(self):
from rpython.jit.backend.llsupport.gc import STMWriteBarrierDescr
descr = STMWriteBarrierDescr(self.cpu.gc_ll_descr, 'A2W')
@@ -384,7 +418,7 @@
descr._do_barrier(sgcref,
returns_modified_object=True)
- # check if rev-fastpath worked
+ # check if fastpath worked
if rev == fakellop.PRIV_REV:
# fastpath
self.assert_not_in(called, [sgcref])
@@ -398,6 +432,36 @@
returns_modified_object=True)
self.assert_in(called, [sgcref])
+ def test_gc_repeat_write_barrier_fastpath(self):
+ from rpython.jit.backend.llsupport.gc import STMWriteBarrierDescr
+ descr = STMWriteBarrierDescr(self.cpu.gc_ll_descr, 'V2W')
+
+ called = []
+ def write(obj):
+ called.append(obj)
+ return obj
+
+ functype = lltype.Ptr(lltype.FuncType(
+ [llmemory.Address], llmemory.Address))
+ funcptr = llhelper(functype, write)
+ descr.b_failing_case_ptr = funcptr
+ descr.llop1 = fakellop()
+
+ # -------- TEST --------
+ s = self.allocate_prebuilt_s()
+ sgcref = lltype.cast_opaque_ptr(llmemory.GCREF, s)
+
+ descr._do_barrier(sgcref,
+ returns_modified_object=True)
+
+ # fastpath (WRITE_BARRIER not set)
+ self.assert_not_in(called, [sgcref])
+
+ # now set WRITE_BARRIER -> always call slowpath
+ s.h_tid |= StmGC.GCFLAG_WRITE_BARRIER
+ descr._do_barrier(sgcref,
+ returns_modified_object=True)
+ self.assert_in(called, [sgcref])
@@ -445,6 +509,40 @@
# not called:
assert not called_on
+ def test_repeat_read_barrier_fastpath(self):
+ cpu = self.cpu
+ cpu.gc_ll_descr.init_nursery(100)
+ cpu.setup_once()
+
+ called_on = cpu.gc_ll_descr.rb_called_on
+ for flags in [StmGC.GCFLAG_PUBLIC_TO_PRIVATE|StmGC.GCFLAG_MOVED, 0]:
+ cpu.gc_ll_descr.clear_lists()
+ self.clear_read_cache()
+
+ s = self.allocate_prebuilt_s()
+ sgcref = lltype.cast_opaque_ptr(llmemory.GCREF, s)
+ s.h_tid |= flags
+
+ p0 = BoxPtr()
+ operations = [
+ ResOperation(rop.COND_CALL_STM_B, [p0], None,
+ descr=self.q2rd),
+ ResOperation(rop.FINISH, [p0], None,
+ descr=BasicFinalDescr(0)),
+ ]
+ inputargs = [p0]
+ looptoken = JitCellToken()
+ cpu.compile_loop(None, inputargs, operations, looptoken)
+ self.cpu.execute_token(looptoken, sgcref)
+
+ # check if rev-fastpath worked
+ if not flags:
+ # fastpath
+ self.assert_not_in(called_on, [sgcref])
+ else:
+ self.assert_in(called_on, [sgcref])
+
+
def test_write_barrier_fastpath(self):
cpu = self.cpu
cpu.gc_ll_descr.init_nursery(100)
@@ -485,6 +583,39 @@
self.cpu.execute_token(looptoken, sgcref)
self.assert_in(called_on, [sgcref])
+ def test_repeat_write_barrier_fastpath(self):
+ cpu = self.cpu
+ cpu.gc_ll_descr.init_nursery(100)
+ cpu.setup_once()
+
+ called_on = cpu.gc_ll_descr.wb_called_on
+ cpu.gc_ll_descr.clear_lists()
+
+ s = self.allocate_prebuilt_s()
+ sgcref = lltype.cast_opaque_ptr(llmemory.GCREF, s)
+
+ p0 = BoxPtr()
+ operations = [
+ ResOperation(rop.COND_CALL_STM_B, [p0], None,
+ descr=self.v2wd),
+ ResOperation(rop.FINISH, [p0], None,
+ descr=BasicFinalDescr(0)),
+ ]
+
+ inputargs = [p0]
+ looptoken = JitCellToken()
+ cpu.compile_loop(None, inputargs, operations, looptoken)
+ self.cpu.execute_token(looptoken, sgcref)
+
+ # fastpath and WRITE_BARRIER not set
+ self.assert_not_in(called_on, [sgcref])
+
+ # now set WRITE_BARRIER -> always call slowpath
+ cpu.gc_ll_descr.clear_lists()
+ s.h_tid |= StmGC.GCFLAG_WRITE_BARRIER
+ self.cpu.execute_token(looptoken, sgcref)
+ self.assert_in(called_on, [sgcref])
+
def test_ptr_eq_fastpath(self):
cpu = self.cpu
More information about the pypy-commit
mailing list