[pypy-commit] pypy continulet-jit-3: Get started.
arigo
noreply at buildbot.pypy.org
Wed Sep 19 01:03:03 CEST 2012
Author: Armin Rigo <arigo at tunes.org>
Branch: continulet-jit-3
Changeset: r57377:9ee7b6e02e74
Date: 2012-09-17 14:23 +0200
http://bitbucket.org/pypy/pypy/changeset/9ee7b6e02e74/
Log: Get started.
diff --git a/pypy/jit/backend/x86/arch.py b/pypy/jit/backend/x86/arch.py
--- a/pypy/jit/backend/x86/arch.py
+++ b/pypy/jit/backend/x86/arch.py
@@ -1,29 +1,54 @@
# 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]
diff --git a/pypy/jit/backend/x86/assembler.py b/pypy/jit/backend/x86/assembler.py
--- a/pypy/jit/backend/x86/assembler.py
+++ b/pypy/jit/backend/x86/assembler.py
@@ -30,7 +30,6 @@
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)
@@ -73,11 +72,6 @@
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
@@ -88,7 +82,6 @@
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
diff --git a/pypy/jit/backend/x86/regalloc.py b/pypy/jit/backend/x86/regalloc.py
--- a/pypy/jit/backend/x86/regalloc.py
+++ b/pypy/jit/backend/x86/regalloc.py
@@ -1468,9 +1468,9 @@
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
diff --git a/pypy/jit/backend/x86/support.py b/pypy/jit/backend/x86/support.py
--- a/pypy/jit/backend/x86/support.py
+++ b/pypy/jit/backend/x86/support.py
@@ -3,31 +3,6 @@
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,
More information about the pypy-commit
mailing list