Author: Armin Rigo <[email protected]>
Branch: stmgc-c7
Changeset: r70118:19982e263d93
Date: 2014-03-20 16:22 +0100
http://bitbucket.org/pypy/pypy/changeset/19982e263d93/
Log: in-progress
diff --git a/rpython/jit/backend/x86/stmtlocal.py
b/rpython/jit/backend/x86/stmtlocal.py
--- a/rpython/jit/backend/x86/stmtlocal.py
+++ b/rpython/jit/backend/x86/stmtlocal.py
@@ -11,7 +11,7 @@
eci = ExternalCompilationInfo(post_include_bits=['''
static long pypy__threadlocal_base(void)
{
- /* XXX ONLY LINUX WITH GCC FOR NOW XXX */
+ /* XXX ONLY LINUX WITH GCC/CLANG FOR NOW XXX */
long result;
asm("%s" : "=r"(result));
return result;
@@ -23,8 +23,7 @@
'pypy__threadlocal_base',
[], lltype.Signed,
compilation_info=eci,
- threadsafe=False,
- transactionsafe=True)
+ _nowrapper=True)
def tl_segment_prefix(mc):
@@ -47,9 +46,3 @@
'stm_invalidate_jmp_buf',
[llmemory.Address], lltype.Void,
sandboxsafe=True, _nowrapper=True, transactionsafe=True)
-stm_pointer_equal_fn = rffi.llexternal(
- 'stm_pointer_equal',
- [llmemory.Address, llmemory.Address], lltype.Bool,
- sandboxsafe=True, _nowrapper=True, transactionsafe=True)
-
-
diff --git a/rpython/jit/metainterp/compile.py
b/rpython/jit/metainterp/compile.py
--- a/rpython/jit/metainterp/compile.py
+++ b/rpython/jit/metainterp/compile.py
@@ -502,9 +502,6 @@
rd_virtuals = None
rd_pendingfields = lltype.nullptr(PENDINGFIELDSP.TO)
- rd_stm_busy = False # same as CNT_BUSY_FLAG, in a different field,
- # only for stm
-
status = r_uint(0)
ST_BUSY_FLAG = 0x01 # if set, busy tracing from the guard
@@ -573,30 +570,6 @@
_trace_and_compile_from_bridge._dont_inline_ = True
def must_compile(self, deadframe, metainterp_sd, jitdriver_sd):
- if rgc.stm_is_enabled():
- method = self.must_compile_stm
- else:
- method = self.must_compile_nonstm
- return method(deadframe, metainterp_sd, jitdriver_sd)
-
- def must_compile_stm(self, deadframe, metainterp_sd, jitdriver_sd):
- XXX # fix me
- trace_eagerness = jitdriver_sd.warmstate.trace_eagerness
- with stm_ignored:
- approx_counter = self._counter + 1
- self._counter = approx_counter
-
- # The call to guard_already_patched is necessary because it is
- # possible that the current transaction didn't see the
- # patched JMP yet, but already sees rd_stm_busy as False (because
- # the patching is in raw-memory).
- # Thus it may try to compile a trace too and also patch the assembler.
- # However, this would trigger the assertion in
- # x86.assembler.patch_jump_for_descr.
- return (approx_counter >= trace_eagerness and not self.rd_stm_busy
- and not metainterp_sd.cpu.guard_already_patched(self))
-
- def must_compile_nonstm(self, deadframe, metainterp_sd, jitdriver_sd):
jitcounter = metainterp_sd.warmrunnerdesc.jitcounter
#
if self.status & (self.ST_BUSY_FLAG | self.ST_TYPE_MASK) == 0:
@@ -638,23 +611,27 @@
intval * 1442968193)
#
increment = jitdriver_sd.warmstate.increment_trace_eagerness
- return jitcounter.tick(hash, increment)
+ result = jitcounter.tick(hash, increment)
+ if rgc.stm_is_enabled():
+ # The call to guard_already_patched is necessary because it is
+ # possible that the current transaction didn't see the
+ # patched JMP yet, but already sees the ST_BUSY_FLAG as 0 (because
+ # the patching is in raw-memory).
+ # Thus it may try to compile a trace too and also patch the
assembler.
+ # However, this would trigger the assertion in
+ # x86.assembler.patch_jump_for_descr.
+ result = result and not
metainterp_sd.cpu.guard_already_patched(self)
+ return result
def start_compiling(self):
# start tracing and compiling from this guard.
- if rgc.stm_is_enabled():
- self.rd_stm_busy = True
- else:
- self.status |= self.ST_BUSY_FLAG
+ self.status |= self.ST_BUSY_FLAG
def done_compiling(self):
# done tracing and compiling from this guard. Note that if the
# bridge has not been successfully compiled, the jitcounter for
# it was reset to 0 already by jitcounter.tick() and not
# incremented at all as long as ST_BUSY_FLAG was set.
- if rgc.stm_is_enabled():
- XXX # review
- self.rd_stm_busy = False
self.status &= ~self.ST_BUSY_FLAG
def compile_and_attach(self, metainterp, new_loop):
diff --git a/rpython/jit/metainterp/counter.py
b/rpython/jit/metainterp/counter.py
--- a/rpython/jit/metainterp/counter.py
+++ b/rpython/jit/metainterp/counter.py
@@ -10,7 +10,10 @@
# keep in sync with the C code in pypy__decay_jit_counters
ENTRY = lltype.Struct('timetable_entry',
('times', lltype.FixedSizeArray(rffi.FLOAT, 5)),
- ('subhashes', lltype.FixedSizeArray(rffi.USHORT, 5)))
+ ('subhashes', lltype.FixedSizeArray(rffi.USHORT, 5)),
+ hints={'stm_dont_track_raw_accesses': True})
+ENTRY_ARRAY = lltype.Array(ENTRY, hints={'nolength': True,
+ 'stm_dont_track_raw_accesses': True})
class JitCounter:
@@ -29,7 +32,7 @@
# and we're getting a 32-bytes-long entry; then this entry
# contains 5 possible ways, each occupying 6 bytes: 4 bytes
# for a float, and the 2 lowest bytes from the original hash.
- self.timetable = lltype.malloc(rffi.CArray(ENTRY), self.size,
+ self.timetable = lltype.malloc(ENTRY_ARRAY, self.size,
flavor='raw', zero=True,
track_allocation=False)
self._nexthash = r_uint(0)
@@ -205,7 +208,8 @@
pypy__decay_jit_counters = rffi.llexternal(
"pypy__decay_jit_counters", [rffi.CCHARP, lltype.Float, lltype.Signed],
- lltype.Void, compilation_info=eci, _nowrapper=True, sandboxsafe=True)
+ lltype.Void, compilation_info=eci, _nowrapper=True, sandboxsafe=True,
+ transactionsafe=True)
# ____________________________________________________________
diff --git a/rpython/jit/metainterp/optimizeopt/__init__.py
b/rpython/jit/metainterp/optimizeopt/__init__.py
--- a/rpython/jit/metainterp/optimizeopt/__init__.py
+++ b/rpython/jit/metainterp/optimizeopt/__init__.py
@@ -35,7 +35,7 @@
def build_opt_chain(metainterp_sd, enable_opts):
optimizations = []
unroll = 'unroll' in enable_opts # 'enable_opts' is normally a dict
- if config.translation.stm:
+ if metainterp_sd.config.translation.stm:
optimizations.append(OptSTM())
for name, opt in unroll_all_opts:
diff --git a/rpython/jit/metainterp/test/test_warmstate.py
b/rpython/jit/metainterp/test/test_warmstate.py
--- a/rpython/jit/metainterp/test/test_warmstate.py
+++ b/rpython/jit/metainterp/test/test_warmstate.py
@@ -4,7 +4,6 @@
from rpython.jit.metainterp.warmstate import wrap, unwrap, specialize_value
from rpython.jit.metainterp.warmstate import equal_whatever, hash_whatever
from rpython.jit.metainterp.warmstate import WarmEnterState
-from rpython.jit.metainterp.warmstate import MODE_HAVE_PROC, MODE_TRACING
from rpython.jit.metainterp.history import BoxInt, BoxFloat, BoxPtr
from rpython.jit.metainterp.history import ConstInt, ConstFloat, ConstPtr
from rpython.jit.metainterp.counter import DeterministicJitCounter
diff --git a/rpython/jit/metainterp/warmstate.py
b/rpython/jit/metainterp/warmstate.py
--- a/rpython/jit/metainterp/warmstate.py
+++ b/rpython/jit/metainterp/warmstate.py
@@ -1,7 +1,3 @@
-XXX
-this file here is from default. It's missing some changes related to stm
-that were conflicting (see the stmgc-c4 branch). We need to review
carefully...
-XXX
import sys
import weakref
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit