Armin Rigo avatar Armin Rigo committed 9ee7b6e

Get started.

Comments (0)

Files changed (4)

pypy/jit/backend/x86/arch.py

 # Constants that depend on whether we are on 32-bit or 64-bit
 
-# The frame size gives the standard fixed part at the start of
-# every assembler frame: the saved value of some registers,
-# one word for the force_index, and some extra space used only
-# during a malloc that needs to go via its slow path.
-
 import sys
 if sys.maxint == (2**31 - 1):
     WORD = 4
-    # ebp + ebx + esi + edi + 4 extra words + force_index = 9 words
-    FRAME_FIXED_SIZE = 9
-    FORCE_INDEX_OFS = -8*WORD
-    MY_COPY_OF_REGS = -7*WORD
     IS_X86_32 = True
     IS_X86_64 = False
 else:
     WORD = 8
-    # rbp + rbx + r12 + r13 + r14 + r15 + 11 extra words + force_index = 18
-    FRAME_FIXED_SIZE = 18
-    FORCE_INDEX_OFS = -17*WORD
-    MY_COPY_OF_REGS = -16*WORD
     IS_X86_32 = False
     IS_X86_64 = True
 
-# The extra space has room for almost all registers, apart from eax and edx
+# The stack for a JIT call is fixed, but it contains only scratch space
+# used e.g. for storing arguments to further calls:
+#
+#        +--------------------+    <== aligned to 16 bytes
+#        |   return address   |
+#        +--------------------+
+#        |   scratch          |
+#        |      space         |
+#        +--------------------+    <== aligned to 16 bytes
+
+if WORD == 4:
+    SCRATCH_SIZE = 7     # total size: 32 bytes
+else:
+    SCRATCH_SIZE = 3     # total size: 32 bytes
+
+# All the rest of the data is in a GC-managed variable-size "frame".
+# This frame object's address is always stored in the register EBP/RBP.
+# A frame is a jit.backend.llsupport.llmodel.FRAME = GcArray(Signed).
+# The following locations are indices in this array.
+
+# The frame's fixed size gives the standard fixed part at the
+# start of every frame: the saved value of some registers,
+# one word for the force_index, and some extra space used only
+# during a malloc that needs to go via its slow path.
+
+if WORD == 4:
+    # ebp + ebx + esi + edi + 4 extra words + force_index = 9 words
+    FRAME_FIXED_SIZE = 9
+    FORCE_INDEX_OFS = 0
+    SAVED_REGISTERS = 1    # range(1, 5)
+    MY_COPY_OF_REGS = 5    # range(5, 9)
+else:
+    # rbp + rbx + r12 + r13 + r14 + r15 + 11 extra words + force_index = 18
+    FRAME_FIXED_SIZE = 18
+    FORCE_INDEX_OFS = 0
+    SAVED_REGISTERS = 1    # range(1, 7)
+    MY_COPY_OF_REGS = 7    # range(7, 18)
+
+# "My copy of regs" has room for almost all registers, apart from eax and edx
 # which are used in the malloc itself.  They are:
 #   ecx, ebx, esi, edi               [32 and 64 bits]
 #   r8, r9, r10, r12, r13, r14, r15    [64 bits only]

pypy/jit/backend/x86/assembler.py

 from pypy.rlib.objectmodel import we_are_translated, specialize
 from pypy.jit.backend.x86 import rx86, regloc, codebuf
 from pypy.jit.metainterp.resoperation import rop, ResOperation
-from pypy.jit.backend.x86.support import values_array
 from pypy.jit.backend.x86 import support
 from pypy.rlib.debug import (debug_print, debug_start, debug_stop,
                              have_debug_prints)
         self.cpu = cpu
         self.verbose = False
         self.rtyper = cpu.rtyper
-        self.fail_boxes_int = values_array(lltype.Signed, failargs_limit)
-        self.fail_boxes_ptr = values_array(llmemory.GCREF, failargs_limit)
-        self.fail_boxes_float = values_array(longlong.FLOATSTORAGE,
-                                             failargs_limit)
-        self.fail_ebp = 0
         self.loop_run_counters = []
         self.float_const_neg_addr = 0
         self.float_const_abs_addr = 0
         self.setup_failure_recovery()
         self._debug = False
         self.debug_counter_descr = cpu.fielddescrof(DEBUG_COUNTER, 'i')
-        self.fail_boxes_count = 0
         self.datablockwrapper = None
         self.stack_check_slowpath = 0
         self.propagate_exception_path = 0

pypy/jit/backend/x86/regalloc.py

 
 def get_ebp_ofs(position):
     # Argument is a frame position (0, 1, 2...).
-    # Returns (ebp-20), (ebp-24), (ebp-28)...
+    # Returns (ebp+36), (ebp+40), (ebp+44)...
     # i.e. the n'th word beyond the fixed frame size.
-    return -WORD * (FRAME_FIXED_SIZE + position)
+    return WORD * (FRAME_FIXED_SIZE + position)
 
 def _valid_addressing_size(size):
     return size == 1 or size == 2 or size == 4 or size == 8

pypy/jit/backend/x86/support.py

 from pypy.translator.tool.cbuild import ExternalCompilationInfo
 from pypy.jit.backend.x86.arch import WORD
 
-
-def values_array(TP, size):
-    ATP = lltype.GcArray(TP)
-    
-    class ValuesArray(object):
-        SIZE = size
-
-        def __init__(self):
-            self.ar = lltype.malloc(ATP, size, zero=True, immortal=True)
-
-        def get_addr_for_num(self, i):
-            return rffi.cast(lltype.Signed, lltype.direct_ptradd(
-                lltype.direct_arrayitems(self.ar), i))
-
-        def setitem(self, i, v):
-            self.ar[i] = v
-
-        def getitem(self, i):
-            return self.ar[i]
-
-        def _freeze_(self):
-            return True
-
-    return ValuesArray()
-
 # ____________________________________________________________
 
 memcpy_fn = rffi.llexternal('memcpy', [llmemory.Address, llmemory.Address,
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.