Author: Armin Rigo <[email protected]>
Branch: stm-gc
Changeset: r52308:ac82cd981a40
Date: 2012-02-09 16:54 +0100
http://bitbucket.org/pypy/pypy/changeset/ac82cd981a40/
Log: Hack hack hack.
diff --git a/pypy/rpython/lltypesystem/lloperation.py
b/pypy/rpython/lltypesystem/lloperation.py
--- a/pypy/rpython/lltypesystem/lloperation.py
+++ b/pypy/rpython/lltypesystem/lloperation.py
@@ -401,6 +401,7 @@
'stm_become_inevitable':LLOp(),
'stm_descriptor_init': LLOp(),
'stm_descriptor_done': LLOp(),
+ 'stm_writebarrier': LLOp(sideeffects=False),
# __________ address operations __________
diff --git a/pypy/rpython/memory/gc/stmgc.py b/pypy/rpython/memory/gc/stmgc.py
--- a/pypy/rpython/memory/gc/stmgc.py
+++ b/pypy/rpython/memory/gc/stmgc.py
@@ -4,7 +4,7 @@
from pypy.rpython.memory.gc.base import GCBase
from pypy.rpython.annlowlevel import llhelper
from pypy.rlib.rarithmetic import LONG_BIT
-from pypy.rlib.debug import ll_assert, debug_start, debug_stop
+from pypy.rlib.debug import ll_assert, debug_start, debug_stop, fatalerror
from pypy.module.thread import ll_thread
@@ -35,7 +35,7 @@
_alloc_flavor_ = "raw"
inline_simple_malloc = True
inline_simple_malloc_varsize = True
- needs_write_barrier = "stm"
+ #needs_write_barrier = "stm"
prebuilt_gc_objects_are_static_roots = False
malloc_zero_filled = True # xxx?
@@ -265,11 +265,11 @@
stm_operations = self.stm_operations
#
@always_inline
- def write_barrier(obj):
+ def stm_writebarrier(obj):
if self.header(obj).tid & GCFLAG_GLOBAL != 0:
obj = _stm_write_barrier_global(obj)
return obj
- self.write_barrier = write_barrier
+ self.stm_writebarrier = stm_writebarrier
#
@dont_inline
def _stm_write_barrier_global(obj):
diff --git a/pypy/rpython/memory/gctransform/framework.py
b/pypy/rpython/memory/gctransform/framework.py
--- a/pypy/rpython/memory/gctransform/framework.py
+++ b/pypy/rpython/memory/gctransform/framework.py
@@ -357,7 +357,7 @@
getfn(GCClass.writebarrier_before_copy.im_func,
[s_gc] + [annmodel.SomeAddress()] * 2 +
[annmodel.SomeInteger()] * 3, annmodel.SomeBool())
- elif GCClass.needs_write_barrier and GCClass.needs_write_barrier !=
'stm':
+ elif GCClass.needs_write_barrier:
raise NotImplementedError("GC needs write barrier, but does not
provide writebarrier_before_copy functionality")
# in some GCs we can inline the common case of
diff --git a/pypy/rpython/memory/gctransform/stmframework.py
b/pypy/rpython/memory/gctransform/stmframework.py
--- a/pypy/rpython/memory/gctransform/stmframework.py
+++ b/pypy/rpython/memory/gctransform/stmframework.py
@@ -1,5 +1,6 @@
from pypy.rpython.memory.gctransform.framework import FrameworkGCTransformer
from pypy.rpython.memory.gctransform.framework import BaseRootWalker
+from pypy.rpython.lltypesystem import llmemory
from pypy.annotation import model as annmodel
@@ -14,6 +15,9 @@
self.teardown_thread_ptr = getfn(
GCClass.teardown_thread.im_func,
[s_gc], annmodel.s_None)
+ self.stm_writebarrier_ptr = getfn(
+ self.gcdata.gc.stm_writebarrier,
+ [annmodel.SomeAddress()], annmodel.SomeAddress())
def push_roots(self, hop, keep_current_args=False):
pass
@@ -31,6 +35,15 @@
def gct_stm_descriptor_done(self, hop):
hop.genop("direct_call", [self.teardown_thread_ptr, self.c_const_gc])
+ def gct_stm_writebarrier(self, hop):
+ op = hop.spaceop
+ v_adr = hop.genop('cast_ptr_to_adr',
+ [op.args[0]], resulttype=llmemory.Address)
+ v_localadr = hop.genop("direct_call",
+ [self.stm_writebarrier_ptr, v_adr],
+ resulttype=llmemory.Address)
+ hop.genop('cast_adr_to_ptr', [v_localadr], resultvar=op.result)
+
class StmStackRootWalker(BaseRootWalker):
diff --git a/pypy/translator/stm/transform.py b/pypy/translator/stm/transform.py
--- a/pypy/translator/stm/transform.py
+++ b/pypy/translator/stm/transform.py
@@ -134,6 +134,15 @@
op1 = SpaceOperation('stm_getfield', op.args, op.result)
newoperations.append(op1)
+ def with_writebarrier(self, newoperations, op):
+ v_arg = op.args[0]
+ v_local = varoftype(v_arg.concretetype)
+ op0 = SpaceOperation('stm_writebarrier', [v_arg], v_local)
+ newoperations.append(op0)
+ op1 = SpaceOperation('bare_' + op.opname, [v_local] + op.args[1:],
+ op.result)
+ return op1
+
def stt_setfield(self, newoperations, op):
STRUCT = op.args[0].concretetype.TO
if op.args[2].concretetype is lltype.Void:
@@ -141,9 +150,11 @@
elif (STRUCT._immutable_field(op.args[1].value) or
'stm_access_directly' in STRUCT._hints):
op1 = op
- else:
+ elif STRUCT._gckind == 'raw':
turn_inevitable(newoperations, "setfield-raw")
op1 = op
+ else:
+ op1 = self.with_writebarrier(newoperations, op)
newoperations.append(op1)
def stt_getarrayitem(self, newoperations, op):
@@ -169,9 +180,11 @@
op1 = op
#elif op.args[0] in self.access_directly:
# op1 = op
- else:
+ elif ARRAY._gckind == 'raw':
turn_inevitable(newoperations, "setarrayitem-raw")
op1 = op
+ else:
+ op1 = self.with_writebarrier(newoperations, op)
newoperations.append(op1)
def stt_getinteriorfield(self, newoperations, op):
@@ -197,7 +210,7 @@
turn_inevitable(newoperations, "setinteriorfield-raw")
op1 = op
else:
- op1 = SpaceOperation('stm_setinteriorfield', op.args, op.result)
+ op1 = self.with_writebarrier(newoperations, op)
newoperations.append(op1)
## def stt_stm_transaction_boundary(self, newoperations, op):
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit