Author: Armin Rigo <[email protected]>
Branch: stmgc-c7
Changeset: r70248:9ddbe2af8e8a
Date: 2014-03-24 13:03 +0100
http://bitbucket.org/pypy/pypy/changeset/9ddbe2af8e8a/

Log:    fixes fixes

diff --git a/rpython/jit/backend/x86/arch.py b/rpython/jit/backend/x86/arch.py
--- a/rpython/jit/backend/x86/arch.py
+++ b/rpython/jit/backend/x86/arch.py
@@ -45,15 +45,19 @@
 
 assert PASS_ON_MY_FRAME >= 12       # asmgcc needs at least JIT_USE_WORDS + 3
 
-# The STM resume buffer (on x86-64) is two words wide.  Actually, clang
+
+# The STM resume buffer (on x86-64) is four words wide.  Actually, clang
 # uses three words (see test_stm.py): rbp, rip, rsp.  But the value of
 # rbp is not interesting for the JIT-generated machine code.  So the
 # STM_JMPBUF_OFS is the offset from the stack top to the start of the
 # buffer, with only words at offset +1 and +2 in this buffer being
-# meaningful -- these are the two words overlapping the STM resume
-# buffer's location in the diagram above.
-STM_RESUME_BUF_WORDS  = 16 / WORD
+# meaningful.  We use ebp, i.e. the word at offset +0, to store the
+# resume counter.
+
+STM_RESUME_BUF_WORDS  = 4     # <-- for alignment, it can't be 3
 STM_FRAME_FIXED_SIZE  = FRAME_FIXED_SIZE + STM_RESUME_BUF_WORDS
-STM_JMPBUF_OFS        = WORD * (FRAME_FIXED_SIZE - 1)
+STM_JMPBUF_OFS        = WORD * FRAME_FIXED_SIZE
+STM_JMPBUF_OFS_RBP    = STM_JMPBUF_OFS + 0 * WORD
 STM_JMPBUF_OFS_RIP    = STM_JMPBUF_OFS + 1 * WORD
 STM_JMPBUF_OFS_RSP    = STM_JMPBUF_OFS + 2 * WORD
+# unused:               STM_JMPBUF_OFS + 3 * WORD
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
@@ -19,7 +19,7 @@
 from rpython.jit.backend.x86.arch import (
     FRAME_FIXED_SIZE, WORD, IS_X86_64, JITFRAME_FIXED_SIZE, IS_X86_32,
     PASS_ON_MY_FRAME, STM_FRAME_FIXED_SIZE, STM_JMPBUF_OFS,
-    STM_JMPBUF_OFS_RIP, STM_JMPBUF_OFS_RSP)
+    STM_JMPBUF_OFS_RIP, STM_JMPBUF_OFS_RSP, STM_JMPBUF_OFS_RBP)
 from rpython.jit.backend.x86.regloc import (eax, ecx, edx, ebx, esp, ebp, esi,
     xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, r8, r9, r10, r11, edi,
     r12, r13, r14, r15, X86_64_SCRATCH_REG, X86_64_XMM_SCRATCH_REG,
@@ -2537,6 +2537,8 @@
         learip_location = mc.get_relative_pos()
         mc.MOV_sr(STM_JMPBUF_OFS_RIP, eax.value)
         mc.MOV_sr(STM_JMPBUF_OFS_RSP, esp.value)
+        mc.XOR(ebp, ebp)
+        mc.MOV_sr(STM_JMPBUF_OFS_RBP, ebp.value)
         #
         offset = mc.get_relative_pos() - learip_location
         assert 0 < offset <= 127
@@ -2545,11 +2547,15 @@
         # (when resuming, ebp is garbage, but the STM_RESUME_BUF is
         # still correct in case of repeated aborting)
         #
-        # call pypy_stm_start_transaction(&jmpbuf)
+        # call pypy_stm_start_transaction(&jmpbuf, &v_counter)
+        # where v_counter is abusively stored in the jmpbuf at
+        # the location for ebp (so that the value in v_counter
+        # is here found in ebp, if we needed it).
         mc.LEA_rs(edi.value, STM_JMPBUF_OFS)
+        mc.LEA_rs(esi.value, STM_JMPBUF_OFS_RBP)
         mc.CALL(imm(rstm.adr_pypy_stm_start_transaction))
         #
-        # reload ebp (the frame) now
+        # reload ebp with the frame now
         self._reload_frame_if_necessary(self.mc)
         #
         # restore regs
diff --git a/rpython/rlib/objectmodel.py b/rpython/rlib/objectmodel.py
--- a/rpython/rlib/objectmodel.py
+++ b/rpython/rlib/objectmodel.py
@@ -206,6 +206,7 @@
 # ____________________________________________________________
 
 class Symbolic(object):
+    _compare_by_id_ = False
 
     def annotation(self):
         return None
@@ -216,11 +217,15 @@
     def __cmp__(self, other):
         if self is other:
             return 0
+        elif self._compare_by_id_ or getattr(other, '_compare_by_id_', False):
+            return cmp(id(self), id(other))
         else:
             raise TypeError("Symbolics cannot be compared! (%r, %r)"
                             % (self, other))
 
     def __hash__(self):
+        if self._compare_by_id_:
+            return object.__hash__(self)
         raise TypeError("Symbolics are not hashable! %r" % (self,))
 
     def __nonzero__(self):
diff --git a/rpython/rlib/rstm.py b/rpython/rlib/rstm.py
--- a/rpython/rlib/rstm.py
+++ b/rpython/rlib/rstm.py
@@ -5,28 +5,31 @@
 from rpython.rtyper.extregistry import ExtRegistryEntry
 from rpython.rlib.jit import dont_look_inside
 
+class CFlexSymbolic(CDefinedIntSymbolic):
+    _compare_by_id_ = True
+
 
 TID = rffi.UINT
-tid_offset = CDefinedIntSymbolic('offsetof(struct rpyobj_s, tid)')
-stm_nb_segments = CDefinedIntSymbolic('STM_NB_SEGMENTS')
-adr_nursery_free = CDefinedIntSymbolic('((long)&STM_SEGMENT->nursery_current)')
-adr_nursery_top  = CDefinedIntSymbolic('((long)&STM_SEGMENT->nursery_end)')
+tid_offset = CFlexSymbolic('offsetof(struct rpyobj_s, tid)')
+stm_nb_segments = CFlexSymbolic('STM_NB_SEGMENTS')
+adr_nursery_free = CFlexSymbolic('((long)&STM_SEGMENT->nursery_current)')
+adr_nursery_top  = CFlexSymbolic('((long)&STM_SEGMENT->nursery_end)')
 adr_pypy_stm_nursery_low_fill_mark = (
-    CDefinedIntSymbolic('((long)&pypy_stm_nursery_low_fill_mark)'))
+    CFlexSymbolic('((long)&pypy_stm_nursery_low_fill_mark)'))
 adr_transaction_read_version = (
-    CDefinedIntSymbolic('((long)&STM_SEGMENT->transaction_read_version)'))
+    CFlexSymbolic('((long)&STM_SEGMENT->transaction_read_version)'))
 adr_jmpbuf_ptr = (
-    CDefinedIntSymbolic('((long)&STM_SEGMENT->jmpbuf_ptr)'))
-adr_write_slowpath = CDefinedIntSymbolic('((long)&_stm_write_slowpath)')
+    CFlexSymbolic('((long)&STM_SEGMENT->jmpbuf_ptr)'))
+adr_write_slowpath = CFlexSymbolic('((long)&_stm_write_slowpath)')
 
 adr_jit_default_msg = (
-    CDefinedIntSymbolic('((long)(char *)"return from JITted function")'))
+    CFlexSymbolic('((long)(char *)"return from JITted function")'))
 adr__stm_become_inevitable = (
-    CDefinedIntSymbolic('((long)&_stm_become_inevitable)'))
+    CFlexSymbolic('((long)&_stm_become_inevitable)'))
 adr_stm_commit_transaction = (
-    CDefinedIntSymbolic('((long)&stm_commit_transaction)'))
+    CFlexSymbolic('((long)&stm_commit_transaction)'))
 adr_pypy_stm_start_transaction = (
-    CDefinedIntSymbolic('((long)&pypy_stm_start_transaction)'))
+    CFlexSymbolic('((long)&pypy_stm_start_transaction)'))
 
 
 def jit_stm_transaction_break_point():
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to