Author: Armin Rigo <[email protected]>
Branch: guard-compatible
Changeset: r90033:2e67cb4a66b5
Date: 2017-02-10 16:49 +0100
http://bitbucket.org/pypy/pypy/changeset/2e67cb4a66b5/
Log: Pass the first test
diff --git a/rpython/jit/backend/llsupport/guard_compat.py
b/rpython/jit/backend/llsupport/guard_compat.py
--- a/rpython/jit/backend/llsupport/guard_compat.py
+++ b/rpython/jit/backend/llsupport/guard_compat.py
@@ -103,7 +103,7 @@
INVOKE_FIND_COMPATIBLE_FUNC = lltype.Ptr(lltype.FuncType(
[lltype.Ptr(P_ARG), lltype.Ptr(jitframe.JITFRAME)],
- lltype.Signed))
+ lltype.Void))
@specialize.memo()
def make_invoke_find_compatible(cpu):
diff --git a/rpython/jit/backend/x86/guard_compat.py
b/rpython/jit/backend/x86/guard_compat.py
--- a/rpython/jit/backend/x86/guard_compat.py
+++ b/rpython/jit/backend/x86/guard_compat.py
@@ -280,7 +280,7 @@
# the _backend_choices object from the second word of the array (the
# GC may have moved it, or it may be a completely new object).
if IS_X86_64:
- mc.MOV_rs(r11, 0) # MOV R11, [RSP]
+ mc.MOV_rs(r11, 1 * WORD) # MOV R11, [RSP]
mc.JMP_s(2 * WORD) # JMP *[RSP+16]
elif IS_X86_32:
XXX
diff --git a/rpython/jit/backend/x86/test/test_compatible.py
b/rpython/jit/backend/x86/test/test_compatible.py
--- a/rpython/jit/backend/x86/test/test_compatible.py
+++ b/rpython/jit/backend/x86/test/test_compatible.py
@@ -1,5 +1,7 @@
import random
from rpython.jit.backend.x86.guard_compat import *
+from rpython.jit.backend.x86.arch import FRAME_FIXED_SIZE, PASS_ON_MY_FRAME
+from rpython.jit.backend.x86.arch import DEFAULT_FRAME_BYTES
from rpython.jit.backend.x86.test.test_basic import Jit386Mixin
from rpython.jit.backend.detect_cpu import getcpuclass
from rpython.jit.metainterp.test import test_compatible
@@ -18,8 +20,14 @@
for i in range(4 * WORD):
mc.writechar('\x00') # 4 gctable entries; 'bchoices' will be #3
#
+ # extracted from _call_header()
+ mc.SUB_ri(regloc.esp.value, FRAME_FIXED_SIZE * WORD)
+ mc.MOV_sr(PASS_ON_MY_FRAME * WORD, regloc.ebp.value)
+ for i, loc in enumerate(cpu.CALLEE_SAVE_REGISTERS):
+ mc.MOV_sr((PASS_ON_MY_FRAME + i + 1) * WORD, loc.value)
+ #
if IS_X86_64:
- mc.MOV(regloc.ecx, regloc.edx) # jitframe
+ mc.MOV(regloc.ebp, regloc.edx) # jitframe
mc.MOV(regloc.r11, regloc.edi) # _backend_choices
mc.MOV(regloc.eax, regloc.esi) # guarded value
elif IS_X86_32:
@@ -28,10 +36,6 @@
mc.MOV_rs(regloc.eax.value, 8)
mc.MOV_rs(regloc.ecx.value, 12)
#
- mc.PUSH(regloc.ebp)
- mc.SUB(regloc.esp, regloc.imm(144 - 2*WORD)) # make a frame, and align
stack
- mc.MOV(regloc.ebp, regloc.ecx)
- #
mc.MOV(regloc.ecx, regloc.imm(0xdddd))
mc.PUSH(regloc.imm(0xaaaa))
# jump to guard_compat_search_tree, but carefully: don't overwrite R11
@@ -40,21 +44,23 @@
mc.INT3()
sequel = mc.get_relative_pos()
#
- mc.force_frame_size(144)
+ mc.force_frame_size(DEFAULT_FRAME_BYTES)
mc.SUB(regloc.eax, regloc.ecx)
- mc.ADD(regloc.esp, regloc.imm(144 - 2*WORD))
- mc.POP(regloc.ebp)
- mc.RET()
+ #
+ def call_footer():
+ mc.MOV_rs(regloc.ebp.value, PASS_ON_MY_FRAME * WORD)
+ for i, loc in enumerate(cpu.CALLEE_SAVE_REGISTERS):
+ mc.MOV_rs(loc.value, (PASS_ON_MY_FRAME + i + 1) * WORD)
+ mc.ADD_ri(regloc.esp.value, FRAME_FIXED_SIZE * WORD)
+ mc.RET()
+ call_footer()
#
extra_paths = []
for i in range(11):
- mc.force_frame_size(144)
+ mc.force_frame_size(DEFAULT_FRAME_BYTES)
extra_paths.append(mc.get_relative_pos())
mc.MOV(regloc.eax, regloc.imm(1000000 + i))
- mc.ADD(regloc.esp, regloc.imm(144 - 2*WORD))
- mc.POP(regloc.ebp)
- mc.RET()
- failure = extra_paths[10]
+ call_footer()
rawstart = mc.materialize(cpu, [])
print 'rawstart:', hex(rawstart)
call_me = rffi.cast(lltype.Ptr(lltype.FuncType(
@@ -110,10 +116,11 @@
gcref = rffi.cast(llmemory.GCREF, 123456 + i)
print 'calling with a gcref never seen before'
res = call_me(bchoices, gcref, frame)
- assert res == 1000010
+ assert res == rffi.cast(lltype.Signed, frame)
assert len(seen) == 1 + i
assert bchoices.bc_most_recent.gcref == 123456 + i
- assert bchoices.bc_most_recent.asmaddr == rawstart + failure
+ assert bchoices.bc_most_recent.asmaddr == (
+ cpu.assembler.guard_compat_recovery)
# ---- grow bchoices ----
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit