Author: Maciej Fijalkowski <[email protected]>
Branch: jitframe-on-heap
Changeset: r60050:71321730f1c8
Date: 2013-01-14 16:54 +0200
http://bitbucket.org/pypy/pypy/changeset/71321730f1c8/
Log: make execute_token return a frame
diff --git a/pypy/jit/backend/llsupport/gc.py b/pypy/jit/backend/llsupport/gc.py
--- a/pypy/jit/backend/llsupport/gc.py
+++ b/pypy/jit/backend/llsupport/gc.py
@@ -100,6 +100,8 @@
p = v.value
rgc._make_sure_does_not_move(p)
gcrefs_output_list.append(p)
+ if op.is_guard() or op.getopnum() == rop.FINISH:
+ rgc._make_sure_does_not_move(op.getdescr())
def rewrite_assembler(self, cpu, operations, gcrefs_output_list):
rewriter = GcRewriterAssembler(self, cpu)
diff --git a/pypy/jit/backend/test/runner_test.py
b/pypy/jit/backend/test/runner_test.py
--- a/pypy/jit/backend/test/runner_test.py
+++ b/pypy/jit/backend/test/runner_test.py
@@ -430,6 +430,7 @@
def test_int_operations(self):
from pypy.jit.metainterp.test.test_executor import get_int_tests
for opnum, boxargs, retvalue in get_int_tests():
+ print "X"
res = self.execute_operation(opnum, boxargs, 'int')
assert res.value == retvalue
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
@@ -4,10 +4,9 @@
from pypy.jit.metainterp.history import Const, Box, BoxInt, ConstInt
from pypy.jit.metainterp.history import AbstractFailDescr, INT, REF, FLOAT
from pypy.jit.metainterp.history import JitCellToken
-from pypy.jit.backend.llsupport.descr import unpack_arraydescr
from pypy.rpython.lltypesystem import lltype, rffi, rstr, llmemory
from pypy.rpython.lltypesystem.lloperation import llop
-from pypy.rpython.annlowlevel import llhelper
+from pypy.rpython.annlowlevel import llhelper, cast_instance_to_gcref
from pypy.rlib.jit import AsmInfo
from pypy.jit.backend.model import CompiledLoopToken
from pypy.jit.backend.x86.regalloc import (RegAlloc, get_ebp_ofs, _get_scale,
@@ -569,7 +568,6 @@
operations = regalloc.prepare_bridge(inputargs, arglocs,
operations,
self.current_clt.allgcrefs)
-
frame_depth = self._assemble(regalloc, operations)
codeendpos = self.mc.get_relative_pos()
self.write_pending_failure_recoveries()
@@ -1793,7 +1791,6 @@
"""Generate the initial code for handling a failure. We try to
keep it as compact as possible.
"""
- fail_index = self.cpu.get_fail_descr_number(guardtok.faildescr)
mc = self.mc
startpos = mc.get_relative_pos()
withfloats = False
@@ -1803,12 +1800,14 @@
break
exc = guardtok.exc
target = self.failure_recovery_code[exc + 2 * withfloats]
+ fail_descr = cast_instance_to_gcref(guardtok.faildescr)
+ fail_descr = rffi.cast(lltype.Signed, fail_descr)
if WORD == 4:
- mc.PUSH(imm(fail_index))
+ mc.PUSH(imm(fail_descr))
mc.JMP(imm(target))
else:
mc.MOV_ri64(X86_64_SCRATCH_REG.value, target)
- mc.PUSH(imm(fail_index))
+ mc.PUSH(imm(fail_descr))
mc.JMP_r(X86_64_SCRATCH_REG.value)
# write tight data that describes the failure recovery
positions = [0] * len(guardtok.fail_locs)
@@ -1881,7 +1880,11 @@
# _call_header_with_stack_check(). The LEA in _call_footer below
# throws away most of the frame, including all the PUSHes that we
# did just above.
+ ofs = self.cpu.get_ofs_of_frame_field('jf_descr')
+ base_ofs = self.cpu.get_baseofs_of_frame_field()
mc.POP(eax)
+ mc.MOV_br(ofs, eax.value)
+ mc.LEA_rb(eax.value, -base_ofs)
self._call_footer()
rawstart = mc.materialize(self.cpu.asmmemmgr, [])
@@ -1890,16 +1893,18 @@
def genop_finish(self, op, arglocs, result_loc):
if len(arglocs) == 2:
- [return_val, argloc] = arglocs
+ [return_val, fail_descr_loc] = arglocs
if op.getarg(0).type == FLOAT and not IS_X86_64:
size = WORD * 2
else:
size = WORD
self.save_into_mem(raw_stack(0), return_val, imm(size))
else:
- [argloc] = arglocs
- if argloc is not eax:
- self.mov(argloc, eax)
+ [fail_descr_loc] = arglocs
+ ofs = self.cpu.get_ofs_of_frame_field('jf_descr')
+ base_ofs = self.cpu.get_baseofs_of_frame_field()
+ self.mov(fail_descr_loc, RawStackLoc(ofs))
+ self.mc.LEA_rb(eax.value, -base_ofs)
# exit function
self._call_footer()
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
@@ -9,6 +9,7 @@
TargetToken, JitCellToken)
from pypy.jit.backend.x86.regloc import *
from pypy.rpython.lltypesystem import lltype, rffi, rstr
+from pypy.rpython.annlowlevel import cast_instance_to_gcref
from pypy.rlib.objectmodel import we_are_translated
from pypy.rlib import rgc
from pypy.jit.backend.llsupport import symbolic
@@ -201,7 +202,8 @@
return operations
def prepare_bridge(self, inputargs, arglocs, operations, allgcrefs):
- operations = self._prepare(inputargs, operations, allgcrefs)
+ operations = self._prepare(inputargs, operations,
+ allgcrefs)
self._update_bindings(arglocs, inputargs)
self.min_bytes_before_label = 0
return operations
@@ -498,12 +500,12 @@
# the frame is in ebp, but we have to point where in the frame is
# the potential argument to FINISH
descr = op.getdescr()
- fail_no = self.assembler.cpu.get_fail_descr_number(descr)
+ fail_descr = cast_instance_to_gcref(descr)
if op.numargs() == 1:
loc = self.make_sure_var_in_reg(op.getarg(0))
- locs = [loc, imm(fail_no)]
+ locs = [loc, imm(fail_descr)]
else:
- locs = [imm(fail_no)]
+ locs = [imm(fail_descr)]
self.Perform(op, locs, None)
if op.numargs() == 1:
self.possibly_free_var(op.getarg(0))
diff --git a/pypy/jit/backend/x86/regloc.py b/pypy/jit/backend/x86/regloc.py
--- a/pypy/jit/backend/x86/regloc.py
+++ b/pypy/jit/backend/x86/regloc.py
@@ -5,7 +5,7 @@
from pypy.tool.sourcetools import func_with_new_name
from pypy.rlib.objectmodel import specialize, instantiate
from pypy.rlib.rarithmetic import intmask
-from pypy.jit.metainterp.history import FLOAT
+from pypy.jit.metainterp.history import FLOAT, INT
from pypy.jit.codewriter import longlong
#
@@ -48,7 +48,7 @@
_immutable_ = True
_location_code = 'b'
- def __init__(self, value, type):
+ def __init__(self, value, type=INT):
self.value = value
self.type = type
diff --git a/pypy/jit/backend/x86/runner.py b/pypy/jit/backend/x86/runner.py
--- a/pypy/jit/backend/x86/runner.py
+++ b/pypy/jit/backend/x86/runner.py
@@ -105,7 +105,7 @@
def make_execute_token(self, *ARGS):
FUNCPTR = lltype.Ptr(lltype.FuncType([llmemory.GCREF],
- lltype.Signed))
+ llmemory.GCREF))
#
def execute_token(executable_token, *args):
clt = executable_token.compiled_loop_token
@@ -136,14 +136,12 @@
else:
self.set_ref_value(frame, num, arg)
num += WORD
- descr_no = func(ll_frame)
+ ll_frame = func(ll_frame)
finally:
if not self.translate_support_code:
LLInterpreter.current_interpreter = prev_interpreter
#llop.debug_print(lltype.Void, "<<<< Back")
- descr = self.get_fail_descr_from_number(descr_no)
- frame.jf_descr = cast_instance_to_gcref(descr)
- return frame
+ return ll_frame
return execute_token
def cast_ptr_to_int(x):
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit