[pypy-commit] pypy default: merge heads
bdkearns
noreply at buildbot.pypy.org
Wed Apr 10 21:54:50 CEST 2013
Author: Brian Kearns <bdkearns at gmail.com>
Branch:
Changeset: r63208:d809fcb12c77
Date: 2013-04-10 15:54 -0400
http://bitbucket.org/pypy/pypy/changeset/d809fcb12c77/
Log: merge heads
diff --git a/pypy/module/pypyjit/test_pypy_c/test_string.py b/pypy/module/pypyjit/test_pypy_c/test_string.py
--- a/pypy/module/pypyjit/test_pypy_c/test_string.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_string.py
@@ -237,3 +237,15 @@
loops = log.loops_by_filename(self.filepath)
loop, = loops
loop.match_by_id('callone', '') # nothing
+
+ def test_lookup_codec(self):
+ log = self.run("""
+ import codecs
+
+ def main(n):
+ for i in xrange(n):
+ codecs.lookup('utf8') # ID: codecs
+ return i
+ """, [1000])
+ loop, = log.loops_by_filename(self.filepath)
+ loop.match_by_id('codecs', '')
diff --git a/rpython/jit/backend/arm/assembler.py b/rpython/jit/backend/arm/assembler.py
--- a/rpython/jit/backend/arm/assembler.py
+++ b/rpython/jit/backend/arm/assembler.py
@@ -30,6 +30,7 @@
class AssemblerARM(ResOpAssembler):
debug = False
+ DEBUG_FRAME_DEPTH = False
def __init__(self, cpu, translate_support_code=False):
ResOpAssembler.__init__(self, cpu, translate_support_code)
@@ -67,6 +68,7 @@
allblocks)
self.mc.datablockwrapper = self.datablockwrapper
self.target_tokens_currently_compiling = {}
+ self.frame_depth_to_patch = []
def teardown(self):
self.current_clt = None
@@ -597,6 +599,7 @@
'e', looptoken.number)
self._call_header_with_stack_check()
+ self._check_frame_depth_debug(self.mc)
regalloc = Regalloc(assembler=self)
operations = regalloc.prepare_loop(inputargs, operations, looptoken,
@@ -670,8 +673,7 @@
self.current_clt.allgcrefs,
self.current_clt.frame_info)
- stack_check_patch_ofs = self._check_frame_depth(self.mc,
- regalloc.get_gcmap())
+ self._check_frame_depth(self.mc, regalloc.get_gcmap())
frame_depth_no_fixed_size = self._assemble(regalloc, inputargs, operations)
@@ -687,6 +689,8 @@
self.patch_trace(faildescr, original_loop_token,
rawstart, regalloc)
+ self.patch_stack_checks(frame_depth_no_fixed_size + JITFRAME_FIXED_SIZE,
+ rawstart)
if not we_are_translated():
if log:
self.mc._dump_trace(rawstart, 'bridge.asm')
@@ -695,7 +699,6 @@
frame_depth = max(self.current_clt.frame_info.jfi_frame_depth,
frame_depth_no_fixed_size + JITFRAME_FIXED_SIZE)
self.fixup_target_tokens(rawstart)
- self._patch_stackadjust(stack_check_patch_ofs + rawstart, frame_depth)
self.update_frame_depth(frame_depth)
self.teardown()
@@ -719,6 +722,11 @@
self._check_frame_depth(self.mc, self._regalloc.get_gcmap(),
expected_size=expected_size)
+ def _patch_frame_depth(self, adr, allocated_depth):
+ mc = InstrBuilder(self.cpu.arch_version)
+ mc.gen_load_int(r.lr.value, allocated_depth)
+ mc.copy_to_raw_memory(adr)
+
def _check_frame_depth(self, mc, gcmap, expected_size=-1):
""" check if the frame is of enough depth to follow this bridge.
Otherwise reallocate the frame in a helper.
@@ -751,7 +759,35 @@
pmc = OverwritingBuilder(mc, jg_location, WORD)
pmc.B_offs(currpos, c.GE)
- return stack_check_cmp_ofs
+ self.frame_depth_to_patch.append(stack_check_cmp_ofs)
+
+ def _check_frame_depth_debug(self, mc):
+ """ double check the depth size. It prints the error (and potentially
+ segfaults later)
+ """
+ if not self.DEBUG_FRAME_DEPTH:
+ return
+ descrs = self.cpu.gc_ll_descr.getframedescrs(self.cpu)
+ ofs = self.cpu.unpack_fielddescr(descrs.arraydescr.lendescr)
+ mc.LDR_ri(r.ip.value, r.fp.value, imm=ofs)
+ stack_check_cmp_ofs = mc.currpos()
+ for _ in range(mc.get_max_size_of_gen_load_int()):
+ mc.NOP()
+ mc.CMP_rr(r.ip.value, r.lr.value)
+
+ jg_location = mc.currpos()
+ mc.BKPT()
+
+ mc.MOV_rr(r.r0.value, r.fp.value)
+ mc.MOV_ri(r.r1.value, r.lr.value)
+
+ self.mc.BL(self.cpu.realloc_frame_crash)
+ # patch the JG above
+ currpos = self.mc.currpos()
+ pmc = OverwritingBuilder(mc, jg_location, WORD)
+ pmc.B_offs(currpos, c.GE)
+
+ self.frame_depth_to_patch.append(stack_check_cmp_ofs)
def build_frame_realloc_slowpath(self):
# this code should do the following steps
@@ -827,6 +863,10 @@
mc.gen_load_int(r.lr.value, allocated_depth)
mc.copy_to_raw_memory(adr)
+ def patch_stack_checks(self, framedepth, rawstart):
+ for ofs in self.frame_depth_to_patch:
+ self._patch_frame_depth(ofs + rawstart, framedepth)
+
def target_arglocs(self, loop_token):
return loop_token._arm_arglocs
diff --git a/rpython/jit/backend/arm/opassembler.py b/rpython/jit/backend/arm/opassembler.py
--- a/rpython/jit/backend/arm/opassembler.py
+++ b/rpython/jit/backend/arm/opassembler.py
@@ -298,6 +298,10 @@
return self._emit_guard(op, locs, fcond, save_exc=False,
is_guard_not_invalidated=True)
+ def emit_op_label(self, op, arglocs, regalloc, fcond):
+ self._check_frame_depth_debug(self.mc)
+ return fcond
+
def emit_op_jump(self, op, arglocs, regalloc, fcond):
target_token = op.getdescr()
assert isinstance(target_token, TargetToken)
diff --git a/rpython/jit/backend/arm/regalloc.py b/rpython/jit/backend/arm/regalloc.py
--- a/rpython/jit/backend/arm/regalloc.py
+++ b/rpython/jit/backend/arm/regalloc.py
@@ -1091,6 +1091,7 @@
#jump_op = self.final_jump_op
#if jump_op is not None and jump_op.getdescr() is descr:
# self._compute_hint_frame_locations_from_descr(descr)
+ return []
def prepare_guard_call_may_force(self, op, guard_op, fcond):
args = self._prepare_call(op, save_all_regs=True)
diff --git a/rpython/rlib/_rsocket_rffi.py b/rpython/rlib/_rsocket_rffi.py
--- a/rpython/rlib/_rsocket_rffi.py
+++ b/rpython/rlib/_rsocket_rffi.py
@@ -346,7 +346,7 @@
])
CConfig.WSAPROTOCOL_INFO = platform.Struct(
- 'WSAPROTOCOL_INFO',
+ 'WSAPROTOCOL_INFOA',
[]) # Struct is just passed between functions
CConfig.FROM_PROTOCOL_INFO = platform.DefinedConstantInteger(
'FROM_PROTOCOL_INFO')
@@ -612,11 +612,11 @@
WSAPROTOCOL_INFO = cConfig.WSAPROTOCOL_INFO
FROM_PROTOCOL_INFO = cConfig.FROM_PROTOCOL_INFO
- WSADuplicateSocket = external('WSADuplicateSocket',
+ WSADuplicateSocket = external('WSADuplicateSocketA',
[socketfd_type, rwin32.DWORD,
lltype.Ptr(WSAPROTOCOL_INFO)],
rffi.INT)
- WSASocket = external('WSASocket',
+ WSASocket = external('WSASocketA',
[rffi.INT, rffi.INT, rffi.INT,
lltype.Ptr(WSAPROTOCOL_INFO),
rwin32.DWORD, rwin32.DWORD],
diff --git a/rpython/rlib/rsocket.py b/rpython/rlib/rsocket.py
--- a/rpython/rlib/rsocket.py
+++ b/rpython/rlib/rsocket.py
@@ -1053,7 +1053,7 @@
if _c.WIN32:
def dup(fd):
- with lltype.scoped_alloc(_c.WSAData, zero=True) as info:
+ with lltype.scoped_alloc(_c.WSAPROTOCOL_INFO, zero=True) as info:
if _c.WSADuplicateSocket(fd, rwin32.GetCurrentProcessId(), info):
raise last_error()
result = _c.WSASocket(
diff --git a/rpython/translator/c/gcc/instruction.py b/rpython/translator/c/gcc/instruction.py
--- a/rpython/translator/c/gcc/instruction.py
+++ b/rpython/translator/c/gcc/instruction.py
@@ -57,11 +57,11 @@
def getlocation(self, framesize, uses_frame_pointer, wordsize):
if (self.hint == 'esp' or not uses_frame_pointer
- or self.ofs_from_frame_end % 2 != 0):
+ or self.ofs_from_frame_end % 1 != 0):
# try to use esp-relative addressing
ofs_from_esp = framesize + self.ofs_from_frame_end
- if ofs_from_esp % 2 == 0:
- return frameloc_esp(ofs_from_esp, wordsize)
+ if ofs_from_esp % 1 == 0:
+ return frameloc_esp(int(ofs_from_esp), wordsize)
# we can get an odd value if the framesize is marked as bogus
# by visit_andl()
assert uses_frame_pointer
@@ -177,12 +177,12 @@
class InsnStackAdjust(Insn):
_args_ = ['delta']
def __init__(self, delta):
- assert delta % 2 == 0 # should be "% 4", but there is the special
- self.delta = delta # case of 'pushw' to handle
+ #assert delta % 4 == 0 --- but not really, gcc generates strange code
+ self.delta = delta
class InsnCannotFollowEsp(InsnStackAdjust):
def __init__(self):
- self.delta = -7 # use an odd value as marker
+ self.delta = -7.25 # use this non-integer value as a marker
class InsnStop(Insn):
_args_ = ['reason']
diff --git a/rpython/translator/c/gcc/test/elf/track_odd_esp.s b/rpython/translator/c/gcc/test/elf/track_odd_esp.s
new file mode 100644
--- /dev/null
+++ b/rpython/translator/c/gcc/test/elf/track_odd_esp.s
@@ -0,0 +1,97 @@
+ .type pypy_g_copy_flags_from_bases, @function
+pypy_g_copy_flags_from_bases:
+.LFB188:
+ .cfi_startproc
+ pushl %ebp
+ .cfi_def_cfa_offset 8
+ .cfi_offset 5, -8
+ xorl %edx, %edx
+ pushl %edi
+ .cfi_def_cfa_offset 12
+ .cfi_offset 7, -12
+ pushl %esi
+ .cfi_def_cfa_offset 16
+ .cfi_offset 6, -16
+ pushl %ebx
+ .cfi_def_cfa_offset 20
+ .cfi_offset 3, -20
+ subl $1, %esp
+ .cfi_def_cfa_offset 21
+ movl 21(%esp), %ebx
+ movb $0, (%esp)
+ movl 16(%ebx), %ebp
+ movl 4(%ebp), %edi
+ .p2align 4,,7
+ .p2align 3
+.L572:
+ cmpl %edi, %edx
+ jge .L573
+.L590:
+.L574:
+ addl $1, %edx
+ movl 4(%ebp,%edx,4), %ecx
+ testl %ecx, %ecx
+ je .L585
+.L576:
+ movl 4(%ecx), %esi
+ movl (%esi), %esi
+ subl $404, %esi
+ cmpl $10, %esi
+ ja .L585
+.L577:
+ cmpb $0, 443(%ebx)
+ movl $1, %esi
+ jne .L578
+.L579:
+ movzbl 443(%ecx), %esi
+.L578:
+ cmpb $0, 444(%ebx)
+ movl %esi, %eax
+ movb %al, 443(%ebx)
+ movl $1, %esi
+ jne .L580
+.L581:
+ movzbl 444(%ecx), %esi
+.L580:
+ cmpb $0, 446(%ebx)
+ movl %esi, %eax
+ movb %al, 444(%ebx)
+ movl $1, %esi
+ jne .L582
+.L583:
+ movzbl 446(%ecx), %esi
+.L582:
+ movl %esi, %eax
+ cmpl %edi, %edx
+ movb %al, 446(%ebx)
+ jl .L590
+.L573:
+ movl 25(%esp), %edx
+ movzbl (%esp), %eax
+ movl 420(%edx), %edx
+ movl %edx, 420(%ebx)
+ addl $1, %esp
+ .cfi_remember_state
+ .cfi_def_cfa_offset 20
+ popl %ebx
+ .cfi_restore 3
+ .cfi_def_cfa_offset 16
+ popl %esi
+ .cfi_restore 6
+ .cfi_def_cfa_offset 12
+ popl %edi
+ .cfi_restore 7
+ .cfi_def_cfa_offset 8
+ popl %ebp
+ .cfi_restore 5
+ .cfi_def_cfa_offset 4
+ ret
+ .p2align 4,,7
+ .p2align 3
+.L585:
+ .cfi_restore_state
+ movb $1, (%esp)
+ jmp .L572
+ .cfi_endproc
+.LFE188:
+ .size pypy_g_copy_flags_from_bases, .-pypy_g_copy_flags_from_bases
More information about the pypy-commit
mailing list