[pypy-svn] pypy arm-backed-float: merge arm-backend-2
bivab
commits-noreply at bitbucket.org
Wed Mar 30 17:31:30 CEST 2011
Author: David Schneider <david.schneider at picle.org>
Branch: arm-backed-float
Changeset: r43018:4a09444cff4d
Date: 2011-03-30 13:54 +0200
http://bitbucket.org/pypy/pypy/changeset/4a09444cff4d/
Log: merge arm-backend-2
diff --git a/pypy/module/readline/test/test_c_readline.py b/pypy/module/readline/test/test_c_readline.py
deleted file mode 100644
--- a/pypy/module/readline/test/test_c_readline.py
+++ /dev/null
@@ -1,16 +0,0 @@
-"""
-Directly test the basic ctypes wrappers.
-"""
-
-import py
-from pypy import conftest; conftest.translation_test_so_skip_if_appdirect()
-from pypy.rpython.tool import rffi_platform as platform
-
-try:
- from pypy.module.readline import c_readline
-except platform.CompilationError, e:
- py.test.skip(e)
-
-
-def test_basic_import():
- c_readline.c_rl_initialize()
diff --git a/pypy/module/__builtin__/app_file_stub.py b/pypy/module/__builtin__/app_file_stub.py
deleted file mode 100644
--- a/pypy/module/__builtin__/app_file_stub.py
+++ /dev/null
@@ -1,20 +0,0 @@
-# NOT_RPYTHON
-
-class file(object):
- """file(name[, mode[, buffering]]) -> file object
-
-Open a file. The mode can be 'r', 'w' or 'a' for reading (default),
-writing or appending. The file will be created if it doesn't exist
-when opened for writing or appending; it will be truncated when
-opened for writing. Add a 'b' to the mode for binary files.
-Add a '+' to the mode to allow simultaneous reading and writing.
-If the buffering argument is given, 0 means unbuffered, 1 means line
-buffered, and larger numbers specify the buffer size.
-Add a 'U' to mode to open the file for input with universal newline
-support. Any line ending in the input file will be seen as a '\n'
-in Python. Also, a file so opened gains the attribute 'newlines';
-the value for this attribute is one of None (no newline read yet),
-'\r', '\n', '\r\n' or a tuple containing all the newline types seen.
-
-Note: open() is an alias for file().
-"""
diff --git a/pypy/module/_rawffi/error.py b/pypy/module/_rawffi/error.py
deleted file mode 100644
--- a/pypy/module/_rawffi/error.py
+++ /dev/null
@@ -1,2 +0,0 @@
-class SegfaultException(Exception):
- pass
diff --git a/pypy/module/_socket/app_socket.py b/pypy/module/_socket/app_socket.py
deleted file mode 100644
--- a/pypy/module/_socket/app_socket.py
+++ /dev/null
@@ -1,15 +0,0 @@
-"""Implementation module for socket operations.
-
-See the socket module for documentation."""
-
-class error(IOError):
- pass
-
-class herror(error):
- pass
-
-class gaierror(error):
- pass
-
-class timeout(error):
- pass
diff --git a/pypy/module/readline/__init__.py b/pypy/module/readline/__init__.py
deleted file mode 100644
--- a/pypy/module/readline/__init__.py
+++ /dev/null
@@ -1,45 +0,0 @@
-# this is a sketch of how one might one day be able to define a pretty simple
-# ctypes-using module, suitable for feeding to the ext-compiler
-
-from pypy.interpreter.mixedmodule import MixedModule
-
-# XXX raw_input needs to check for space.readline_func and use
-# it if its there
-
-class Module(MixedModule):
- """Importing this module enables command line editing using GNU readline."""
- # the above line is the doc string of the translated module
-
- def setup_after_space_initialization(self):
- from pypy.module.readline import c_readline
- c_readline.setup_readline(self.space, self)
-
- interpleveldefs = {
- 'readline' : 'interp_readline.readline',
- }
-
- appleveldefs = {
- 'parse_and_bind': 'app_stub.stub',
- 'get_line_buffer': 'app_stub.stub_str',
- 'insert_text': 'app_stub.stub',
- 'read_init_file': 'app_stub.stub',
- 'read_history_file': 'app_stub.stub',
- 'write_history_file': 'app_stub.stub',
- 'clear_history': 'app_stub.stub',
- 'get_history_length': 'app_stub.stub_int',
- 'set_history_length': 'app_stub.stub',
- 'get_current_history_length': 'app_stub.stub_int',
- 'get_history_item': 'app_stub.stub_str',
- 'remove_history_item': 'app_stub.stub',
- 'replace_history_item': 'app_stub.stub',
- 'redisplay': 'app_stub.stub',
- 'set_startup_hook': 'app_stub.stub',
- 'set_pre_input_hook': 'app_stub.stub',
- 'set_completer': 'app_stub.stub',
- 'get_completer': 'app_stub.stub',
- 'get_begidx': 'app_stub.stub_int',
- 'get_endidx': 'app_stub.stub_int',
- 'set_completer_delims': 'app_stub.stub',
- 'get_completer_delims': 'app_stub.stub_str',
- 'add_history': 'app_stub.stub',
- }
diff --git a/pypy/jit/backend/arm/opassembler.py b/pypy/jit/backend/arm/opassembler.py
--- a/pypy/jit/backend/arm/opassembler.py
+++ b/pypy/jit/backend/arm/opassembler.py
@@ -87,9 +87,9 @@
emit_op_int_and = gen_emit_op_ri('AND')
emit_op_int_or = gen_emit_op_ri('ORR')
emit_op_int_xor = gen_emit_op_ri('EOR')
- emit_op_int_lshift = gen_emit_op_ri('LSL', imm_size=0x1F, allow_zero=False, commutative=False)
- emit_op_int_rshift = gen_emit_op_ri('ASR', imm_size=0x1F, allow_zero=False, commutative=False)
- emit_op_uint_rshift = gen_emit_op_ri('LSR', imm_size=0x1F, allow_zero=False, commutative=False)
+ emit_op_int_lshift = gen_emit_op_ri('LSL')
+ emit_op_int_rshift = gen_emit_op_ri('ASR')
+ emit_op_uint_rshift = gen_emit_op_ri('LSR')
emit_op_int_lt = gen_emit_cmp_op(c.LT)
emit_op_int_le = gen_emit_cmp_op(c.LE)
@@ -133,7 +133,7 @@
_mixin_ = True
- guard_size = 10*WORD
+ guard_size = 5*WORD
def _emit_guard(self, op, arglocs, fcond, save_exc=False):
descr = op.getdescr()
assert isinstance(descr, AbstractFailDescr)
@@ -143,12 +143,9 @@
self.mc.ADD_ri(r.pc.value, r.pc.value, self.guard_size-PC_OFFSET, cond=fcond)
descr._arm_guard_pos = self.mc.currpos()
- self.mc.PUSH([reg.value for reg in r.caller_resp])
- addr = self.cpu.get_on_leave_jitted_int(save_exception=save_exc)
- self.mc.BL(addr)
- self.mc.POP([reg.value for reg in r.caller_resp])
- memaddr = self._gen_path_to_exit_path(op, op.getfailargs(), arglocs)
+ memaddr = self._gen_path_to_exit_path(op, op.getfailargs(),
+ arglocs, save_exc=save_exc)
descr._failure_recovery_code = memaddr
return c.AL
@@ -235,17 +232,19 @@
else:
target = descr._arm_bootstrap_code + descr._arm_loop_code
self.mc.B(target, fcond)
+ new_fd = max(regalloc.frame_manager.frame_depth, descr._arm_frame_depth)
+ regalloc.frame_manager.frame_depth = new_fd
return fcond
def emit_op_finish(self, op, arglocs, regalloc, fcond):
self._gen_path_to_exit_path(op, op.getarglist(), arglocs, c.AL)
return fcond
- def emit_op_call(self, op, args, regalloc, fcond, spill_all_regs=False):
+ def emit_op_call(self, op, args, regalloc, fcond):
adr = args[0].value
arglist = op.getarglist()[1:]
cond = self._emit_call(adr, arglist, regalloc, fcond,
- op.result, spill_all_regs=spill_all_regs)
+ op.result)
descr = op.getdescr()
#XXX Hack, Hack, Hack
if op.result and not we_are_translated() and not isinstance(descr, LoopToken):
@@ -256,10 +255,9 @@
return cond
# XXX improve this interface
- # XXX and get rid of spill_all_regs in favor of pushing them in
# emit_op_call_may_force
# XXX improve freeing of stuff here
- def _emit_call(self, adr, args, regalloc, fcond=c.AL, result=None, spill_all_regs=False):
+ def _emit_call(self, adr, args, regalloc, fcond=c.AL, result=None):
n = 0
n_args = len(args)
reg_args = min(n_args, 4)
@@ -268,16 +266,17 @@
l = regalloc.make_sure_var_in_reg(args[i],
selected_reg=r.all_regs[i])
# save caller saved registers
- if spill_all_regs:
- regalloc.before_call(save_all_regs=spill_all_regs)
+ if result:
+ # XXX hack if the call has a result force the value in r0 to be
+ # spilled
+ if reg_args == 0 or (isinstance(args[0], Box) and
+ regalloc.stays_alive(args[0])):
+ t = TempBox()
+ regalloc.force_allocate_reg(t, selected_reg=regalloc.call_result_location(t))
+ regalloc.possibly_free_var(t)
+ self.mc.PUSH([reg.value for reg in r.caller_resp][1:])
else:
- if result:
- # XXX maybe move instance check to llsupport/regalloc
- if reg_args > 0 and isinstance(args[0], Box) and regalloc.stays_alive(args[0]):
- regalloc.force_spill_var(args[0])
- self.mc.PUSH([reg.value for reg in r.caller_resp][1:])
- else:
- self.mc.PUSH([reg.value for reg in r.caller_resp])
+ self.mc.PUSH([reg.value for reg in r.caller_resp])
# all arguments past the 4th go on the stack
if n_args > 4:
@@ -297,14 +296,11 @@
self._adjust_sp(-n, fcond=fcond)
# restore the argumets stored on the stack
- if spill_all_regs:
+ if result is not None:
regalloc.after_call(result)
+ self.mc.POP([reg.value for reg in r.caller_resp][1:])
else:
- if result is not None:
- regalloc.after_call(result)
- self.mc.POP([reg.value for reg in r.caller_resp][1:])
- else:
- self.mc.POP([reg.value for reg in r.caller_resp])
+ self.mc.POP([reg.value for reg in r.caller_resp])
return fcond
def emit_op_same_as(self, op, arglocs, regalloc, fcond):
@@ -351,11 +347,20 @@
def emit_op_setfield_gc(self, op, arglocs, regalloc, fcond):
value_loc, base_loc, ofs, size = arglocs
if size.value == 4:
- self.mc.STR_ri(value_loc.value, base_loc.value, ofs.value)
+ if ofs.is_imm():
+ self.mc.STR_ri(value_loc.value, base_loc.value, ofs.value)
+ else:
+ self.mc.STR_rr(value_loc.value, base_loc.value, ofs.value)
elif size.value == 2:
- self.mc.STRH_ri(value_loc.value, base_loc.value, ofs.value)
+ if ofs.is_imm():
+ self.mc.STRH_ri(value_loc.value, base_loc.value, ofs.value)
+ else:
+ self.mc.STRH_rr(value_loc.value, base_loc.value, ofs.value)
elif size.value == 1:
- self.mc.STRB_ri(value_loc.value, base_loc.value, ofs.value)
+ if ofs.is_imm():
+ self.mc.STRB_ri(value_loc.value, base_loc.value, ofs.value)
+ else:
+ self.mc.STRB_rr(value_loc.value, base_loc.value, ofs.value)
else:
assert 0
return fcond
@@ -365,11 +370,20 @@
def emit_op_getfield_gc(self, op, arglocs, regalloc, fcond):
base_loc, ofs, res, size = arglocs
if size.value == 4:
- self.mc.LDR_ri(res.value, base_loc.value, ofs.value)
+ if ofs.is_imm():
+ self.mc.LDR_ri(res.value, base_loc.value, ofs.value)
+ else:
+ self.mc.LDR_rr(res.value, base_loc.value, ofs.value)
elif size.value == 2:
- self.mc.LDRH_ri(res.value, base_loc.value, ofs.value)
+ if ofs.is_imm():
+ self.mc.LDRH_ri(res.value, base_loc.value, ofs.value)
+ else:
+ self.mc.LDRH_rr(res.value, base_loc.value, ofs.value)
elif size.value == 1:
- self.mc.LDRB_ri(res.value, base_loc.value, ofs.value)
+ if ofs.is_imm():
+ self.mc.LDRB_ri(res.value, base_loc.value, ofs.value)
+ else:
+ self.mc.LDRB_rr(res.value, base_loc.value, ofs.value)
else:
assert 0
@@ -633,11 +647,16 @@
# from: ../x86/assembler.py:1668
# XXX Split into some helper methods
def emit_guard_call_assembler(self, op, guard_op, arglocs, regalloc, fcond):
+ faildescr = guard_op.getdescr()
+ fail_index = self.cpu.get_fail_descr_number(faildescr)
+ self._write_fail_index(fail_index)
+
descr = op.getdescr()
assert isinstance(descr, LoopToken)
+ assert op.numargs() == len(descr._arm_arglocs)
resbox = TempBox()
self._emit_call(descr._arm_direct_bootstrap_code, op.getarglist(),
- regalloc, fcond, result=resbox, spill_all_regs=True)
+ regalloc, fcond, result=resbox)
if op.result is None:
value = self.cpu.done_with_this_frame_void_v
else:
@@ -650,56 +669,56 @@
value = self.cpu.done_with_this_frame_float_v
else:
raise AssertionError(kind)
- assert value <= 0xff
-
# check value
- resloc = regalloc.force_allocate_reg(resbox)
+ resloc = regalloc.try_allocate_reg(resbox)
+ assert resloc is r.r0
self.mc.gen_load_int(r.ip.value, value)
self.mc.CMP_rr(resloc.value, r.ip.value)
+ regalloc.possibly_free_var(resbox)
fast_jmp_pos = self.mc.currpos()
- #fast_jmp_location = self.mc.curraddr()
self.mc.NOP()
- #if values are equal we take the fast pat
+ # Path A: use assembler helper
+ #if values are equal we take the fast path
# Slow path, calling helper
# jump to merge point
jd = descr.outermost_jitdriver_sd
assert jd is not None
asm_helper_adr = self.cpu.cast_adr_to_int(jd.assembler_helper_adr)
- self._emit_call(asm_helper_adr, [resbox, op.getarg(0)], regalloc, fcond, op.result)
- regalloc.possibly_free_var(resbox)
+ self.mc.PUSH([reg.value for reg in r.caller_resp][1:])
+ # resbox is allready in r0
+ self.mov_loc_loc(arglocs[1], r.r1)
+ self.mc.BL(asm_helper_adr)
+ self.mc.POP([reg.value for reg in r.caller_resp][1:])
+ if op.result:
+ regalloc.after_call(op.result)
# jump to merge point
jmp_pos = self.mc.currpos()
#jmp_location = self.mc.curraddr()
self.mc.NOP()
+ # Path B: load return value and reset token
# Fast Path using result boxes
# patch the jump to the fast path
offset = self.mc.currpos() - fast_jmp_pos
pmc = OverwritingBuilder(self.mc, fast_jmp_pos, WORD)
- #pmc = ARMv7InMemoryBuilder(fast_jmp_location, WORD)
pmc.ADD_ri(r.pc.value, r.pc.value, offset - PC_OFFSET, cond=c.EQ)
# Reset the vable token --- XXX really too much special logic here:-(
- # XXX Enable and fix this once the stange errors procuded by its
- # presence are fixed
- #if jd.index_of_virtualizable >= 0:
- # from pypy.jit.backend.llsupport.descr import BaseFieldDescr
- # size = jd.portal_calldescr.get_result_size(self.cpu.translate_support_code)
- # vable_index = jd.index_of_virtualizable
- # regalloc._sync_var(op.getarg(vable_index))
- # vable = regalloc.frame_manager.loc(op.getarg(vable_index))
- # fielddescr = jd.vable_token_descr
- # assert isinstance(fielddescr, BaseFieldDescr)
- # ofs = fielddescr.offset
- # self.mc.MOV(eax, arglocs[1])
- # self.mc.MOV_mi((eax.value, ofs), 0)
- # # in the line above, TOKEN_NONE = 0
+ if jd.index_of_virtualizable >= 0:
+ from pypy.jit.backend.llsupport.descr import BaseFieldDescr
+ fielddescr = jd.vable_token_descr
+ assert isinstance(fielddescr, BaseFieldDescr)
+ ofs = fielddescr.offset
+ resloc = regalloc.force_allocate_reg(resbox)
+ self.mov_loc_loc(arglocs[1], r.ip)
+ self.mc.MOV_ri(resloc.value, 0)
+ self.mc.STR_ri(resloc.value, r.ip.value, ofs)
+ regalloc.possibly_free_var(resbox)
if op.result is not None:
# load the return value from fail_boxes_xxx[0]
- resloc = regalloc.force_allocate_reg(op.result)
kind = op.result.type
if kind == INT:
adr = self.fail_boxes_int.get_addr_for_num(0)
@@ -707,22 +726,35 @@
adr = self.fail_boxes_ptr.get_addr_for_num(0)
else:
raise AssertionError(kind)
+ resloc = regalloc.force_allocate_reg(op.result)
+ regalloc.possibly_free_var(resbox)
self.mc.gen_load_int(r.ip.value, adr)
self.mc.LDR_ri(resloc.value, r.ip.value)
+ # merge point
offset = self.mc.currpos() - jmp_pos
- pmc = OverwritingBuilder(self.mc, jmp_pos, WORD)
- pmc.ADD_ri(r.pc.value, r.pc.value, offset - PC_OFFSET)
+ if offset - PC_OFFSET >= 0:
+ pmc = OverwritingBuilder(self.mc, jmp_pos, WORD)
+ pmc.ADD_ri(r.pc.value, r.pc.value, offset - PC_OFFSET)
self.mc.LDR_ri(r.ip.value, r.fp.value)
self.mc.CMP_ri(r.ip.value, 0)
self._emit_guard(guard_op, regalloc._prepare_guard(guard_op), c.GE)
- regalloc.possibly_free_vars_for_op(op)
- if op.result:
- regalloc.possibly_free_var(op.result)
return fcond
+
+ # ../x86/assembler.py:668
+ def redirect_call_assembler(self, oldlooptoken, newlooptoken):
+ # we overwrite the instructions at the old _x86_direct_bootstrap_code
+ # to start with a JMP to the new _x86_direct_bootstrap_code.
+ # Ideally we should rather patch all existing CALLs, but well.
+ oldadr = oldlooptoken._arm_direct_bootstrap_code
+ target = newlooptoken._arm_direct_bootstrap_code
+ mc = ARMv7Builder()
+ mc.B(target)
+ mc.copy_to_raw_memory(oldadr)
+
def emit_guard_call_may_force(self, op, guard_op, arglocs, regalloc, fcond):
self.mc.LDR_ri(r.ip.value, r.fp.value)
self.mc.CMP_ri(r.ip.value, 0)
diff --git a/pypy/jit/metainterp/test/test_executor.py b/pypy/jit/metainterp/test/test_executor.py
--- a/pypy/jit/metainterp/test/test_executor.py
+++ b/pypy/jit/metainterp/test/test_executor.py
@@ -10,6 +10,7 @@
from pypy.jit.metainterp.history import BoxFloat, ConstFloat
from pypy.jit.metainterp.history import AbstractDescr, Box
from pypy.jit.metainterp import history
+from pypy.jit.codewriter import longlong
from pypy.jit.backend.model import AbstractCPU
from pypy.rpython.lltypesystem import llmemory, rffi
@@ -59,11 +60,17 @@
def bh_call_f(self, func, calldescr, args_i, args_r, args_f):
self.fakecalled = (func, calldescr, args_i, args_r, args_f)
- return 42.5
+ return longlong.getfloatstorage(42.5)
def bh_strsetitem(self, string, index, newvalue):
self.fakestrsetitem = (string, index, newvalue)
+def boxfloat(x):
+ return BoxFloat(longlong.getfloatstorage(x))
+
+def constfloat(x):
+ return ConstFloat(longlong.getfloatstorage(x))
+
def test_execute():
cpu = FakeCPU()
@@ -76,12 +83,14 @@
def test_execute_varargs():
cpu = FakeCPU()
descr = FakeCallDescr()
- argboxes = [BoxInt(99999), BoxInt(321), ConstFloat(2.25), ConstInt(123),
- BoxPtr(), BoxFloat(5.5)]
+ argboxes = [BoxInt(99999), BoxInt(321), constfloat(2.25), ConstInt(123),
+ BoxPtr(), boxfloat(5.5)]
box = execute_varargs(cpu, FakeMetaInterp(), rop.CALL, argboxes, descr)
- assert box.value == 42.5
+ assert box.getfloat() == 42.5
assert cpu.fakecalled == (99999, descr, [321, 123],
- [ConstPtr.value], [2.25, 5.5])
+ [ConstPtr.value],
+ [longlong.getfloatstorage(2.25),
+ longlong.getfloatstorage(5.5)])
def test_execute_nonspec():
cpu = FakeCPU()
@@ -91,7 +100,7 @@
argboxes = [BoxInt(321), ConstInt(123)]
box = execute_nonspec(cpu, FakeMetaInterp(), rop.CALL,
argboxes, FakeCallDescr())
- assert box.value == 42.5
+ assert box.getfloat() == 42.5
# arity == 0
box = execute_nonspec(cpu, None, rop.NEW, [], descr)
assert box.value.fakeargs == ('new', descr)
@@ -100,7 +109,7 @@
box = execute_nonspec(cpu, None, rop.ARRAYLEN_GC, [box1], descr)
assert box.value == 55
# arity == 2
- box2 = BoxFloat(222.2)
+ box2 = boxfloat(222.2)
fielddescr = FakeFieldDescr()
execute_nonspec(cpu, None, rop.SETFIELD_GC, [box1, box2], fielddescr)
assert cpu.fakesetfield == (box1.value, box2.value, fielddescr)
@@ -289,7 +298,7 @@
boxargs = []
for x in args:
if isinstance(x, float):
- boxargs.append(BoxFloat(x))
+ boxargs.append(boxfloat(x))
else:
boxargs.append(BoxInt(x))
yield opnum, boxargs, rettype, retvalue
@@ -300,7 +309,7 @@
if (isinstance(args[0], float) and
isinstance(args[1], float) and
args[0] == args[1]):
- commonbox = BoxFloat(args[0])
+ commonbox = boxfloat(args[0])
yield opnum, [commonbox, commonbox], rettype, retvalue
def test_float_ops():
@@ -320,8 +329,8 @@
arg1 = ConstInt(a)
arg2 = ConstInt(b)
elif n[0:5] == 'FLOAT':
- arg1 = ConstFloat(float(a))
- arg2 = ConstFloat(float(b))
+ arg1 = constfloat(float(a))
+ arg2 = constfloat(float(b))
elif n[0:3] == 'PTR':
arg1 = ConstPtr(rffi.cast(llmemory.GCREF, a))
arg2 = ConstPtr(rffi.cast(llmemory.GCREF, b))
diff --git a/pypy/module/thread/app_thread.py b/pypy/module/thread/app_thread.py
deleted file mode 100644
--- a/pypy/module/thread/app_thread.py
+++ /dev/null
@@ -1,7 +0,0 @@
-class error(Exception):
- pass
-
-def exit():
- """This is synonymous to ``raise SystemExit''. It will cause the current
-thread to exit silently unless the exception is caught."""
- raise SystemExit
diff --git a/pypy/translator/c/test/test_dtoa.py b/pypy/translator/c/test/test_dtoa.py
deleted file mode 100644
--- a/pypy/translator/c/test/test_dtoa.py
+++ /dev/null
@@ -1,92 +0,0 @@
-from __future__ import with_statement
-from pypy.translator.tool.cbuild import ExternalCompilationInfo
-from pypy.tool.autopath import pypydir
-from pypy.rpython.lltypesystem import lltype, rffi
-from pypy.rlib.rstring import StringBuilder
-import py
-
-includes = []
-libraries = []
-
-cdir = py.path.local(pypydir) / 'translator' / 'c'
-files = [cdir / 'src' / 'dtoa.c']
-include_dirs = [cdir]
-
-eci = ExternalCompilationInfo(
- include_dirs = include_dirs,
- libraries = libraries,
- separate_module_files = files,
- separate_module_sources = ['''
- #include <stdlib.h>
- #include <assert.h>
- #define WITH_PYMALLOC
- #include "src/obmalloc.c"
- '''],
- export_symbols = ['_Py_dg_strtod',
- '_Py_dg_dtoa',
- '_Py_dg_freedtoa',
- ],
-)
-
-dg_strtod = rffi.llexternal(
- '_Py_dg_strtod', [rffi.CCHARP, rffi.CCHARPP], rffi.DOUBLE,
- compilation_info=eci)
-
-dg_dtoa = rffi.llexternal(
- '_Py_dg_dtoa', [rffi.DOUBLE, rffi.INT, rffi.INT,
- rffi.INTP, rffi.INTP, rffi.CCHARPP], rffi.CCHARP,
- compilation_info=eci)
-
-dg_freedtoa = rffi.llexternal(
- '_Py_dg_freedtoa', [rffi.CCHARP], lltype.Void,
- compilation_info=eci)
-
-def strtod(input):
- with lltype.scoped_alloc(rffi.CCHARPP.TO, 1) as end_ptr:
- with rffi.scoped_str2charp(input) as ll_input:
- result = dg_strtod(ll_input, end_ptr)
- if end_ptr[0] and ord(end_ptr[0][0]):
- offset = (rffi.cast(rffi.LONG, end_ptr[0]) -
- rffi.cast(rffi.LONG, ll_input))
- raise ValueError("invalid input at position %d" % (offset,))
- return result
-
-def dtoa(value, mode=0, precision=0):
- builder = StringBuilder(20)
- with lltype.scoped_alloc(rffi.INTP.TO, 1) as decpt_ptr:
- with lltype.scoped_alloc(rffi.INTP.TO, 1) as sign_ptr:
- with lltype.scoped_alloc(rffi.CCHARPP.TO, 1) as end_ptr:
- output_ptr = dg_dtoa(value, mode, precision,
- decpt_ptr, sign_ptr, end_ptr)
- try:
- buflen = (rffi.cast(rffi.LONG, end_ptr[0]) -
- rffi.cast(rffi.LONG, output_ptr))
- intpart = rffi.cast(lltype.Signed, decpt_ptr[0])
- if intpart <= buflen:
- builder.append(rffi.charpsize2str(output_ptr, intpart))
- else:
- builder.append(rffi.charpsize2str(output_ptr, buflen))
- while buflen < intpart:
- builder.append('0')
- intpart -= 1
- builder.append('.')
- fracpart = buflen - intpart
- if fracpart > 0:
- ptr = rffi.ptradd(output_ptr, intpart)
- builder.append(rffi.charpsize2str(ptr, fracpart))
- finally:
- dg_freedtoa(output_ptr)
- return builder.build()
-
-def test_strtod():
- assert strtod("12345") == 12345.0
- assert strtod("1.1") == 1.1
- assert strtod("3.47") == 3.47
- raises(ValueError, strtod, "123A")
-
-def test_dtoa():
- assert dtoa(3.47) == "3.47"
- assert dtoa(1.1) == "1.1"
- assert dtoa(12.3577) == "12.3577"
- assert dtoa(10) == "10."
- assert dtoa(1e100) == "1" + "0" * 100 + "."
diff --git a/pypy/module/mmap/app_mmap.py b/pypy/module/mmap/app_mmap.py
deleted file mode 100644
--- a/pypy/module/mmap/app_mmap.py
+++ /dev/null
@@ -1,5 +0,0 @@
-ACCESS_READ = 1
-ACCESS_WRITE = 2
-ACCESS_COPY = 3
-
-error = EnvironmentError
diff --git a/pypy/jit/backend/arm/regalloc.py b/pypy/jit/backend/arm/regalloc.py
--- a/pypy/jit/backend/arm/regalloc.py
+++ b/pypy/jit/backend/arm/regalloc.py
@@ -276,27 +276,26 @@
boxes.append(box)
self.possibly_free_vars(boxes)
+ self.possibly_free_vars_for_op(op)
res = self.force_allocate_reg(op.result)
self.possibly_free_var(op.result)
return [reg1, reg2, res]
def prepare_guard_int_mul_ovf(self, op, guard, fcond):
- args = []
boxes = list(op.getarglist())
a0, a1 = boxes
- reg1, box = self._ensure_value_is_boxed(a0,forbidden_vars=boxes)
+ reg1, box = self._ensure_value_is_boxed(a0, forbidden_vars=boxes)
boxes.append(box)
- reg2, box = self._ensure_value_is_boxed(a1,forbidden_vars=boxes)
+ reg2, box = self._ensure_value_is_boxed(a1, forbidden_vars=boxes)
boxes.append(box)
- res = self.force_allocate_reg(op.result, boxes)
+ res = self.force_allocate_reg(op.result)
+ args = self._prepare_guard(guard, [reg1, reg2, res])
- args.append(reg1)
- args.append(reg2)
- args.append(res)
- args = self._prepare_guard(guard, args)
self.possibly_free_vars(boxes)
+ self.possibly_free_vars_for_op(op)
self.possibly_free_var(op.result)
+ self.possibly_free_vars(guard.getfailargs())
return args
@@ -363,6 +362,7 @@
arg = op.getarg(i)
if arg:
args.append(self.loc(arg))
+ self.possibly_free_var(arg)
else:
args.append(None)
return args
@@ -371,6 +371,7 @@
l0, box = self._ensure_value_is_boxed(op.getarg(0))
args = self._prepare_guard(op, [l0])
self.possibly_free_var(box)
+ self.possibly_free_vars(op.getfailargs())
return args
prepare_op_guard_false = prepare_op_guard_true
@@ -391,10 +392,13 @@
assert op.result is None
arglocs = self._prepare_guard(op, [l0, l1])
self.possibly_free_vars(boxes)
+ self.possibly_free_vars(op.getfailargs())
return arglocs
def prepare_op_guard_no_overflow(self, op, fcond):
- return self._prepare_guard(op)
+ locs = self._prepare_guard(op)
+ self.possibly_free_vars(op.getfailargs())
+ return locs
prepare_op_guard_overflow = prepare_op_guard_no_overflow
@@ -415,6 +419,7 @@
pos_exception = imm(self.cpu.pos_exception())
arglocs = self._prepare_guard(op, [loc, loc1, resloc, pos_exc_value, pos_exception])
self.possibly_free_vars(boxes)
+ self.possibly_free_vars(op.getfailargs())
return arglocs
def prepare_op_guard_no_exception(self, op, fcond):
@@ -422,6 +427,7 @@
ConstInt(self.cpu.pos_exception()))
arglocs = self._prepare_guard(op, [loc])
self.possibly_free_var(box)
+ self.possibly_free_vars(op.getfailargs())
return arglocs
def prepare_op_guard_class(self, op, fcond):
@@ -447,6 +453,7 @@
boxes.append(offset_box)
arglocs = self._prepare_guard(op, [x, y, offset_loc])
self.possibly_free_vars(boxes)
+ self.possibly_free_vars(op.getfailargs())
return arglocs
@@ -454,7 +461,8 @@
def prepare_op_jump(self, op, fcond):
descr = op.getdescr()
assert isinstance(descr, LoopToken)
- return [self.loc(op.getarg(i)) for i in range(op.numargs())]
+ locs = [self.loc(op.getarg(i)) for i in range(op.numargs())]
+ return locs
def prepare_op_setfield_gc(self, op, fcond):
@@ -465,8 +473,14 @@
boxes.append(base_box)
value_loc, value_box = self._ensure_value_is_boxed(a1, boxes)
boxes.append(value_box)
+ c_ofs = ConstInt(ofs)
+ if _check_imm_arg(c_ofs):
+ ofs_loc = imm(ofs)
+ else:
+ ofs_loc, ofs_box = self._ensure_value_is_boxed(c_ofs, boxes)
+ boxes.append(ofs_box)
self.possibly_free_vars(boxes)
- return [value_loc, base_loc, imm(ofs), imm(size)]
+ return [value_loc, base_loc, ofs_loc, imm(size)]
prepare_op_setfield_raw = prepare_op_setfield_gc
@@ -474,11 +488,17 @@
a0 = op.getarg(0)
ofs, size, ptr = self._unpack_fielddescr(op.getdescr())
base_loc, base_box = self._ensure_value_is_boxed(a0)
+ c_ofs = ConstInt(ofs)
+ if _check_imm_arg(c_ofs):
+ ofs_loc = imm(ofs)
+ else:
+ ofs_loc, ofs_box = self._ensure_value_is_boxed(c_ofs, [base_box])
+ self.possibly_free_var(ofs_box)
self.possibly_free_var(a0)
self.possibly_free_var(base_box)
res = self.force_allocate_reg(op.result)
self.possibly_free_var(op.result)
- return [base_loc, imm(ofs), res, imm(size)]
+ return [base_loc, ofs_loc, res, imm(size)]
prepare_op_getfield_raw = prepare_op_getfield_gc
prepare_op_getfield_raw_pure = prepare_op_getfield_gc
@@ -651,7 +671,6 @@
else:
argloc, box = self._ensure_value_is_boxed(arg)
self.possibly_free_var(box)
- self.possibly_free_vars_for_op(op)
resloc = self.force_allocate_reg(op.result)
self.possibly_free_var(op.result)
@@ -743,16 +762,28 @@
fail_index = self.cpu.get_fail_descr_number(faildescr)
self.assembler._write_fail_index(fail_index)
args = [imm(rffi.cast(lltype.Signed, op.getarg(0).getint()))]
- # force all reg values to be spilled when calling
- self.assembler.emit_op_call(op, args, self, fcond, spill_all_regs=True)
-
- return self._prepare_guard(guard_op)
+ for v in guard_op.getfailargs():
+ if v in self.reg_bindings:
+ self.force_spill_var(v)
+ self.assembler.emit_op_call(op, args, self, fcond)
+ locs = self._prepare_guard(guard_op)
+ self.possibly_free_vars(guard_op.getfailargs())
+ return locs
def prepare_guard_call_assembler(self, op, guard_op, fcond):
- faildescr = guard_op.getdescr()
- fail_index = self.cpu.get_fail_descr_number(faildescr)
- self.assembler._write_fail_index(fail_index)
- return []
+ descr = op.getdescr()
+ assert isinstance(descr, LoopToken)
+ jd = descr.outermost_jitdriver_sd
+ assert jd is not None
+ size = jd.portal_calldescr.get_result_size(self.cpu.translate_support_code)
+ vable_index = jd.index_of_virtualizable
+ if vable_index >= 0:
+ self._sync_var(op.getarg(vable_index))
+ vable = self.frame_manager.loc(op.getarg(vable_index))
+ else:
+ vable = imm(0)
+ self.possibly_free_vars(guard_op.getfailargs())
+ return [imm(size), vable]
def _prepare_args_for_new_op(self, new_args):
gc_ll_descr = self.cpu.gc_ll_descr
diff --git a/pypy/module/readline/c_readline.py b/pypy/module/readline/c_readline.py
deleted file mode 100644
--- a/pypy/module/readline/c_readline.py
+++ /dev/null
@@ -1,77 +0,0 @@
-from pypy.rpython.tool import rffi_platform as platform
-from pypy.rpython.lltypesystem import lltype, rffi
-from pypy.interpreter.error import OperationError
-from pypy.interpreter.gateway import ObjSpace, interp2app
-from pypy.translator.tool.cbuild import ExternalCompilationInfo
-
-# On various platforms, linking only with libreadline is not enough;
-# we also need to link with some variant of curses or libtermcap.
-# We follow the logic of CPython below.
-def try_with_lib(extralibs, **kwds):
- global most_recent_error
- # at least on Gentoo Linux, readline.h doesn't compile if stdio.h is not
- # included before
- eci = ExternalCompilationInfo(
- includes = ["stdio.h", "readline/readline.h", "readline/history.h"],
- libraries = extralibs + ['readline'],
- )
- try:
- platform.verify_eci(eci)
- return eci
- except platform.CompilationError, e:
- most_recent_error = e
- return None
-
-eci = (try_with_lib([]) or
- try_with_lib(['ncursesw']) or
- try_with_lib(['ncurses']) or
- try_with_lib(['curses']) or
- try_with_lib(['termcap'], library_dirs=['/usr/lib/termcap']))
-if eci is None:
- raise most_recent_error
-
-# ____________________________________________________________
-
-def external(name, args, result):
- return rffi.llexternal(name, args, result, compilation_info=eci)
-
-# get a binding to c library functions and define their args and return types
-# char *readline(char *)
-c_readline = external('readline', [rffi.CCHARP], rffi.CCHARP)
-
-# void rl_initiliaze(void)
-c_rl_initialize = external('rl_initialize', [], lltype.Void)
-
-# void using_history(void)
-c_using_history = external('using_history', [], lltype.Void)
-
-# void add_history(const char *)
-c_add_history = external('add_history', [rffi.CCHARP], lltype.Void)
-
-#------------------------------------------------------------
-# special initialization of readline
-
-class ReadlineState(object):
- lastline = "" # XXX possibly temporary hack
-readlinestate = ReadlineState()
-
-def setup_readline(space, w_module):
- c_using_history()
- # XXX CPython initializes more stuff here
- c_rl_initialize()
- # install sys.__raw_input__, a hook that will be used by raw_input()
- space.setitem(space.sys.w_dict, space.wrap('__raw_input__'),
- space.wrap(app_readline_func))
-
-def readline_func(space, prompt):
- ll_res = c_readline(prompt)
- if not ll_res:
- raise OperationError(space.w_EOFError, space.w_None)
- res = rffi.charp2str(ll_res)
- if res and res != readlinestate.lastline:
- readlinestate.lastline = res
- c_add_history(res)
- return space.wrap(res)
-
-readline_func.unwrap_spec = [ObjSpace, str]
-app_readline_func = interp2app(readline_func)
diff --git a/pypy/doc/config/objspace.usemodules.readline.txt b/pypy/doc/config/objspace.usemodules.readline.txt
deleted file mode 100644
--- a/pypy/doc/config/objspace.usemodules.readline.txt
+++ /dev/null
@@ -1,1 +0,0 @@
-Use the 'readline' module.
diff --git a/pypy/module/readline/app_stub.py b/pypy/module/readline/app_stub.py
deleted file mode 100644
--- a/pypy/module/readline/app_stub.py
+++ /dev/null
@@ -1,13 +0,0 @@
-# NOT_RPYTHON
-
-def stub(*args, **kwds):
- import warnings
- warnings.warn("the 'readline' module is only a stub so far")
-
-def stub_str(*args, **kwds):
- stub()
- return ''
-
-def stub_int(*args, **kwds):
- stub()
- return 0
diff --git a/pypy/translator/c/src/math.c b/pypy/translator/c/src/math.c
deleted file mode 100644
--- a/pypy/translator/c/src/math.c
+++ /dev/null
@@ -1,256 +0,0 @@
-/* Definitions of some C99 math library functions, for those platforms
- that don't implement these functions already. */
-
-#include <errno.h>
-
-/* The following macros are copied from CPython header files */
-
-#ifdef _MSC_VER
-#include <float.h>
-#define PyPy_IS_NAN _isnan
-#define PyPy_IS_INFINITY(X) (!_finite(X) && !_isnan(X))
-#define copysign _copysign
-#else
-#define PyPy_IS_NAN(X) ((X) != (X))
-#define PyPy_IS_INFINITY(X) ((X) && \
- (Py_FORCE_DOUBLE(X)*0.5 == Py_FORCE_DOUBLE(X)))
-#endif
-
-#undef PyPy_NAN
-
-int
-_pypy_math_isinf(double x)
-{
- return PyPy_IS_INFINITY(x);
-}
-
-int
-_pypy_math_isnan(double x)
-{
- return PyPy_IS_NAN(x);
-}
-
-/* The following copyright notice applies to the original
- implementations of acosh, asinh and atanh. */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-double _pypy_math_log1p(double x);
-
-static const double ln2 = 6.93147180559945286227E-01;
-static const double two_pow_m28 = 3.7252902984619141E-09; /* 2**-28 */
-static const double two_pow_p28 = 268435456.0; /* 2**28 */
-static const double zero = 0.0;
-
-/* acosh(x)
- * Method :
- * Based on
- * acosh(x) = log [ x + sqrt(x*x-1) ]
- * we have
- * acosh(x) := log(x)+ln2, if x is large; else
- * acosh(x) := log(2x-1/(sqrt(x*x-1)+x)) if x>2; else
- * acosh(x) := log1p(t+sqrt(2.0*t+t*t)); where t=x-1.
- *
- * Special cases:
- * acosh(x) is NaN with signal if x<1.
- * acosh(NaN) is NaN without signal.
- */
-
-double
-_pypy_math_acosh(double x)
-{
- if (PyPy_IS_NAN(x)) {
- return x+x;
- }
- if (x < 1.) { /* x < 1; return a signaling NaN */
- errno = EDOM;
-#ifdef PyPy_NAN
- return PyPy_NAN;
-#else
- return (x-x)/(x-x);
-#endif
- }
- else if (x >= two_pow_p28) { /* x > 2**28 */
- if (PyPy_IS_INFINITY(x)) {
- return x+x;
- } else {
- return log(x)+ln2; /* acosh(huge)=log(2x) */
- }
- }
- else if (x == 1.) {
- return 0.0; /* acosh(1) = 0 */
- }
- else if (x > 2.) { /* 2 < x < 2**28 */
- double t = x*x;
- return log(2.0*x - 1.0 / (x + sqrt(t - 1.0)));
- }
- else { /* 1 < x <= 2 */
- double t = x - 1.0;
- return _pypy_math_log1p(t + sqrt(2.0*t + t*t));
- }
-}
-
-
-/* asinh(x)
- * Method :
- * Based on
- * asinh(x) = sign(x) * log [ |x| + sqrt(x*x+1) ]
- * we have
- * asinh(x) := x if 1+x*x=1,
- * := sign(x)*(log(x)+ln2)) for large |x|, else
- * := sign(x)*log(2|x|+1/(|x|+sqrt(x*x+1))) if|x|>2, else
- * := sign(x)*log1p(|x| + x^2/(1 + sqrt(1+x^2)))
- */
-
-double
-_pypy_math_asinh(double x)
-{
- double w;
- double absx = fabs(x);
-
- if (PyPy_IS_NAN(x) || PyPy_IS_INFINITY(x)) {
- return x+x;
- }
- if (absx < two_pow_m28) { /* |x| < 2**-28 */
- return x; /* return x inexact except 0 */
- }
- if (absx > two_pow_p28) { /* |x| > 2**28 */
- w = log(absx)+ln2;
- }
- else if (absx > 2.0) { /* 2 < |x| < 2**28 */
- w = log(2.0*absx + 1.0 / (sqrt(x*x + 1.0) + absx));
- }
- else { /* 2**-28 <= |x| < 2= */
- double t = x*x;
- w = _pypy_math_log1p(absx + t / (1.0 + sqrt(1.0 + t)));
- }
- return copysign(w, x);
-
-}
-
-/* atanh(x)
- * Method :
- * 1.Reduced x to positive by atanh(-x) = -atanh(x)
- * 2.For x>=0.5
- * 1 2x x
- * atanh(x) = --- * log(1 + -------) = 0.5 * log1p(2 * --------)
- * 2 1 - x 1 - x
- *
- * For x<0.5
- * atanh(x) = 0.5*log1p(2x+2x*x/(1-x))
- *
- * Special cases:
- * atanh(x) is NaN if |x| >= 1 with signal;
- * atanh(NaN) is that NaN with no signal;
- *
- */
-
-double
-_pypy_math_atanh(double x)
-{
- double absx;
- double t;
-
- if (PyPy_IS_NAN(x)) {
- return x+x;
- }
- absx = fabs(x);
- if (absx >= 1.) { /* |x| >= 1 */
- errno = EDOM;
-#ifdef PyPy_NAN
- return PyPy_NAN;
-#else
- return x/zero;
-#endif
- }
- if (absx < two_pow_m28) { /* |x| < 2**-28 */
- return x;
- }
- if (absx < 0.5) { /* |x| < 0.5 */
- t = absx+absx;
- t = 0.5 * _pypy_math_log1p(t + t*absx / (1.0 - absx));
- }
- else { /* 0.5 <= |x| <= 1.0 */
- t = 0.5 * _pypy_math_log1p((absx + absx) / (1.0 - absx));
- }
- return copysign(t, x);
-}
-
-/* Mathematically, expm1(x) = exp(x) - 1. The expm1 function is designed
- to avoid the significant loss of precision that arises from direct
- evaluation of the expression exp(x) - 1, for x near 0. */
-
-double
-_pypy_math_expm1(double x)
-{
- /* For abs(x) >= log(2), it's safe to evaluate exp(x) - 1 directly; this
- also works fine for infinities and nans.
-
- For smaller x, we can use a method due to Kahan that achieves close to
- full accuracy.
- */
-
- if (fabs(x) < 0.7) {
- double u;
- u = exp(x);
- if (u == 1.0)
- return x;
- else
- return (u - 1.0) * x / log(u);
- }
- else
- return exp(x) - 1.0;
-}
-
-/* log1p(x) = log(1+x). The log1p function is designed to avoid the
- significant loss of precision that arises from direct evaluation when x is
- small. */
-
-double
-_pypy_math_log1p(double x)
-{
- /* For x small, we use the following approach. Let y be the nearest float
- to 1+x, then
-
- 1+x = y * (1 - (y-1-x)/y)
-
- so log(1+x) = log(y) + log(1-(y-1-x)/y). Since (y-1-x)/y is tiny, the
- second term is well approximated by (y-1-x)/y. If abs(x) >=
- DBL_EPSILON/2 or the rounding-mode is some form of round-to-nearest
- then y-1-x will be exactly representable, and is computed exactly by
- (y-1)-x.
-
- If abs(x) < DBL_EPSILON/2 and the rounding mode is not known to be
- round-to-nearest then this method is slightly dangerous: 1+x could be
- rounded up to 1+DBL_EPSILON instead of down to 1, and in that case
- y-1-x will not be exactly representable any more and the result can be
- off by many ulps. But this is easily fixed: for a floating-point
- number |x| < DBL_EPSILON/2., the closest floating-point number to
- log(1+x) is exactly x.
- */
-
- double y;
- if (fabs(x) < DBL_EPSILON/2.) {
- return x;
- } else if (-0.5 <= x && x <= 1.) {
- /* WARNING: it's possible than an overeager compiler
- will incorrectly optimize the following two lines
- to the equivalent of "return log(1.+x)". If this
- happens, then results from log1p will be inaccurate
- for small x. */
- y = 1.+x;
- return log(y)-((y-1.)-x)/y;
- } else {
- /* NaNs and infinities should end up here */
- return log(1.+x);
- }
-}
diff --git a/pypy/jit/backend/arm/codebuilder.py b/pypy/jit/backend/arm/codebuilder.py
--- a/pypy/jit/backend/arm/codebuilder.py
+++ b/pypy/jit/backend/arm/codebuilder.py
@@ -18,7 +18,7 @@
def f(self, c=cond.AL):
"""Generates a call to a helper function, takes its
arguments in r0 and r1, result is placed in r0"""
- addr = rffi.cast(lltype.Signed, llhelper(signature, function))
+ addr = rffi.cast(lltype.Signed, function)
if c == cond.AL:
self.BL(addr)
else:
@@ -131,7 +131,7 @@
assert c == cond.AL
self.LDR_ri(reg.ip.value, reg.pc.value, cond=c)
self.SUB_rr(reg.pc.value, reg.pc.value, reg.ip.value, cond=c)
- target += 2 * WORD
+ target += WORD
self.write32(target)
def BL(self, target, c=cond.AL):
@@ -172,19 +172,30 @@
def currpos(self):
raise NotImplementedError
- size_of_gen_load_int = 4 * WORD
- ofs_shift = zip(range(8, 25, 8), range(12, 0, -4))
+ size_of_gen_load_int = 3 * WORD
def gen_load_int(self, r, value, cond=cond.AL):
"""r is the register number, value is the value to be loaded to the
register"""
- self.MOV_ri(r, (value & 0xFF), cond=cond)
+ from pypy.jit.backend.arm.conditions import AL
+ if cond != AL or 0 <= value <= 0xFFFF:
+ self._load_by_shifting(r, value, cond)
+ else:
+ self.LDR_ri(r, reg.pc.value)
+ self.MOV_rr(reg.pc.value, reg.pc.value)
+ self.write32(value)
+
+ #size_of_gen_load_int = 4 * WORD
+ ofs_shift = zip(range(8, 25, 8), range(12, 0, -4))
+ def _load_by_shifting(self, r, value, c=cond.AL):
+ # to be sure it is only called for the correct cases
+ assert c != cond.AL or 0 <= value <= 0xFFFF
+ self.MOV_ri(r, (value & 0xFF), cond=c)
for offset, shift in self.ofs_shift:
b = (value >> offset) & 0xFF
if b == 0:
continue
t = b | (shift << 8)
- self.ORR_ri(r, r, imm=t, cond=cond)
-
+ self.ORR_ri(r, r, imm=t, cond=c)
class OverwritingBuilder(AbstractARMv7Builder):
def __init__(self, cb, start, size):
diff --git a/pypy/module/readline/test/test_with_pypy.py b/pypy/module/readline/test/test_with_pypy.py
deleted file mode 100644
--- a/pypy/module/readline/test/test_with_pypy.py
+++ /dev/null
@@ -1,27 +0,0 @@
-"""
-Test the readline library on top of PyPy. The following tests run
-in the PyPy interpreter, itself running on top of CPython
-"""
-
-import py
-from pypy.conftest import gettestobjspace
-from pypy.rpython.tool import rffi_platform as platform
-
-try:
- from pypy.module.readline import c_readline
-except platform.CompilationError, e:
- py.test.skip(e)
-
-
-class AppTestReadline:
-
- def setup_class(cls):
- # enable usage of the readline mixedmodule
- space = gettestobjspace(usemodules=('readline',))
- cls.space = space
-
- def test_basic_import(self):
- # this is interpreted by PyPy
- import readline
- readline.readline
- # XXX test more
diff --git a/pypy/module/signal/app_signal.py b/pypy/module/signal/app_signal.py
deleted file mode 100644
--- a/pypy/module/signal/app_signal.py
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-def default_int_handler(signum, frame):
- """
- default_int_handler(...)
-
- The default handler for SIGINT installed by Python.
- It raises KeyboardInterrupt.
- """
- raise KeyboardInterrupt()
diff --git a/pypy/module/itertools/test/errors.txt b/pypy/module/itertools/test/errors.txt
deleted file mode 100644
--- a/pypy/module/itertools/test/errors.txt
+++ /dev/null
@@ -1,67 +0,0 @@
-
-
-Here are the remaining errors of CPython 2.5's test_itertools. FWIW I
-consider them all as obscure undocumented implementation details.
-
-
-======================================================================
-ERROR: test_islice (__main__.TestBasicOps)
-----------------------------------------------------------------------
-Traceback (most recent call last):
- File "test_itertools.py", line 285, in test_islice
- self.assertRaises(ValueError, islice, xrange(10), 'a')
- File "/home/arigo/pypysrc/lib-python/2.4.1/unittest.py", line 322, in failUnlessRaises
- return
- File "/home/arigo/pypysrc/lib-python/2.4.1/unittest.py", line 320, in failUnlessRaises
- callableObj(*args, **kwargs)
-TypeError: expected integer, got str object
-
-======================================================================
-ERROR: test_tee (__main__.TestBasicOps)
-----------------------------------------------------------------------
-Traceback (most recent call last):
- File "itest25.py", line 376, in test_tee
- c = type(a)('def')
-TypeError: default __new__ takes no parameters
-
-======================================================================
-ERROR: test_repeat (__main__.LengthTransparency)
-----------------------------------------------------------------------
-Traceback (most recent call last):
- File "itest25.py", line 690, in test_repeat
- from test.test_iterlen import len
-ImportError: cannot import name 'len'
-
-======================================================================
-ERROR: test_keywords_in_subclass (__main__.SubclassWithKwargsTest)
-----------------------------------------------------------------------
-Traceback (most recent call last):
- File "itest25.py", line 760, in test_keywords_in_subclass
- class Subclass(cls):
-TypeError: type 'repeat' is not an acceptable base class
-
-======================================================================
-FAIL: test_count (__main__.TestBasicOps)
-----------------------------------------------------------------------
-Traceback (most recent call last):
- File "itest25.py", line 59, in test_count
- self.assertEqual(repr(c), 'count(3)')
-AssertionError: '<count object at 0x08fcdcac>' != 'count(3)'
-
-======================================================================
-FAIL: test_izip (__main__.TestBasicOps)
-----------------------------------------------------------------------
-Traceback (most recent call last):
- File "itest25.py", line 199, in test_izip
- self.assertEqual(min(ids), max(ids))
-AssertionError: 149283404 != 150789644
-
-======================================================================
-FAIL: test_repeat (__main__.TestBasicOps)
-----------------------------------------------------------------------
-Traceback (most recent call last):
- File "itest25.py", line 214, in test_repeat
- self.assertEqual(repr(r), 'repeat((1+0j))')
-AssertionError: '<repeat object at 0x09124a2c>' != 'repeat((1+0j))'
-
-----------------------------------------------------------------------
diff --git a/pypy/jit/backend/arm/runner.py b/pypy/jit/backend/arm/runner.py
--- a/pypy/jit/backend/arm/runner.py
+++ b/pypy/jit/backend/arm/runner.py
@@ -60,6 +60,12 @@
def get_latest_value_count(self):
return self.assembler.fail_boxes_count
+ def get_latest_value_count(self):
+ return self.assembler.fail_boxes_count
+
+ def get_latest_force_token(self):
+ return self.assembler.fail_force_index
+
def clear_latest_values(self, count):
setitem = self.assembler.fail_boxes_ptr.setitem
null = lltype.nullptr(llmemory.GCREF.TO)
@@ -111,3 +117,6 @@
# end of "no gc operation!" block
assert fail_index == fail_index_2
return faildescr
+
+ def redirect_call_assembler(self, oldlooptoken, newlooptoken):
+ self.assembler.redirect_call_assembler(oldlooptoken, newlooptoken)
diff --git a/pypy/module/math/_genmath.py b/pypy/module/math/_genmath.py
deleted file mode 100644
--- a/pypy/module/math/_genmath.py
+++ /dev/null
@@ -1,62 +0,0 @@
-# ONESHOT SCRIPT (probably can go away soon)
-# to generate the mixed module 'math' (see same directory)
-import py
-import math
-import re
-import sys
-rex_arg = re.compile(".*\((.*)\).*")
-
-if __name__ == '__main__':
- print py.code.Source("""
- import math
- from pypy.interpreter.gateway import ObjSpace
-
- """)
- names = []
- for name, func in math.__dict__.items():
- if not callable(func):
- continue
- sig = func.__doc__.split('\n')[0].strip()
- sig = sig.split('->')[0].strip()
- m = rex_arg.match(sig)
- assert m
- args = m.group(1)
- args = ", ".join(args.split(','))
- sig = sig.replace('(', '(space,')
- sig = ", ".join(sig.split(','))
- argc = len(args.split(','))
- unwrap_spec = ['ObjSpace']
- unwrap_spec += ['float'] * argc
- unwrap_spec = ", ".join(unwrap_spec)
- doc = func.__doc__.replace('\n', '\n ')
-
- print py.code.Source('''
- def %(sig)s:
- """%(doc)s
- """
- return space.wrap(math.%(name)s(%(args)s))
- %(name)s.unwrap_spec = [%(unwrap_spec)s]
- ''' % locals())
- names.append(name)
-
- print >>sys.stderr, py.code.Source("""
- # Package initialisation
- from pypy.interpreter.mixedmodule import MixedModule
-
- class Module(MixedModule):
- appleveldefs = {
- }
- interpleveldefs = {
- """)
-
- for name in names:
- space = " " * (15-len(name))
- print >>sys.stderr, (
- " %(name)r%(space)s: 'interp_math.%(name)s'," % locals())
- print >>sys.stderr, py.code.Source("""
- }
- """)
-
-
-
-
diff --git a/pypy/module/zlib/app_zlib.py b/pypy/module/zlib/app_zlib.py
deleted file mode 100644
--- a/pypy/module/zlib/app_zlib.py
+++ /dev/null
@@ -1,11 +0,0 @@
-
-"""
-Application-level definitions for the zlib module.
-
-NOT_RPYTHON
-"""
-
-class error(Exception):
- """
- Raised by zlib operations.
- """
diff --git a/pypy/jit/backend/arm/test/test_assembler.py b/pypy/jit/backend/arm/test/test_assembler.py
--- a/pypy/jit/backend/arm/test/test_assembler.py
+++ b/pypy/jit/backend/arm/test/test_assembler.py
@@ -60,6 +60,18 @@
self.a.gen_func_epilog()
assert run_asm(self.a) == -3
+ def test_load_int1(self):
+ self.a.gen_func_prolog()
+ self.a.mc.gen_load_int(r.r0.value, 440)
+ self.a.gen_func_epilog()
+ assert run_asm(self.a) == 440
+
+ def test_load_int2(self):
+ self.a.gen_func_prolog()
+ self.a.mc.gen_load_int(r.r0.value, 464)
+ self.a.gen_func_epilog()
+ assert run_asm(self.a) == 464
+
def test_or(self):
self.a.gen_func_prolog()
@@ -167,7 +179,7 @@
# call to div
self.a.mc.PUSH(range(2, 12))
- div_addr = rffi.cast(lltype.Signed, llhelper(arm_int_div_sign, arm_int_div))
+ div_addr = rffi.cast(lltype.Signed, arm_int_div)
self.a.mc.BL(div_addr)
self.a.mc.POP(range(2, 12))
self.a.gen_func_epilog()
@@ -221,8 +233,16 @@
self.a.mov_loc_loc(imm(2478), r.r0)
self.a.gen_func_epilog()
assert run_asm(self.a) == 2478
-
+ def test_load_store(self):
+ x = 0x60002224
+ self.a.gen_func_prolog()
+ self.a.mc.gen_load_int(r.r1.value, x)
+ self.a.mc.MOV_ri(r.r3.value, 8)
+ self.a.mc.STR_rr(r.r1.value, r.fp.value, r.r3.value)
+ self.a.mc.LDR_ri(r.r0.value, r.fp.value, 8)
+ self.a.gen_func_epilog()
+ assert run_asm(self.a) == x
def callme(inp):
i = inp + 10
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
@@ -14,9 +14,15 @@
from pypy.rpython.ootypesystem import ootype
from pypy.rpython.annlowlevel import llhelper
from pypy.rpython.llinterp import LLException
-from pypy.jit.codewriter import heaptracker
+from pypy.jit.codewriter import heaptracker, longlong
from pypy.rlib.rarithmetic import intmask
+def boxfloat(x):
+ return BoxFloat(longlong.getfloatstorage(x))
+
+def constfloat(x):
+ return ConstFloat(longlong.getfloatstorage(x))
+
class Runner(object):
@@ -36,7 +42,7 @@
self.cpu.set_future_value_ref(j, box.getref_base())
j += 1
elif isinstance(box, BoxFloat):
- self.cpu.set_future_value_float(j, box.getfloat())
+ self.cpu.set_future_value_float(j, box.getfloatstorage())
j += 1
else:
raise NotImplementedError(box)
@@ -360,7 +366,10 @@
from pypy.jit.metainterp.test.test_executor import get_float_tests
for opnum, boxargs, rettype, retvalue in get_float_tests(self.cpu):
res = self.execute_operation(opnum, boxargs, rettype)
- assert res.value == retvalue
+ if isinstance(res, BoxFloat):
+ assert res.getfloat() == retvalue
+ else:
+ assert res.value == retvalue
def test_ovf_operations(self, reversed=False):
minint = -sys.maxint-1
@@ -432,6 +441,8 @@
assert x == ord('B')
if cpu.supports_floats:
def func(f, i):
+ assert isinstance(f, float)
+ assert isinstance(i, int)
return f - float(i)
FPTR = self.Ptr(self.FuncType([lltype.Float, lltype.Signed],
lltype.Float))
@@ -440,8 +451,8 @@
calldescr = cpu.calldescrof(FTP, FTP.ARGS, FTP.RESULT)
x = cpu.bh_call_f(self.get_funcbox(cpu, func_ptr).value,
calldescr,
- [42], None, [3.5])
- assert x == 3.5 - 42
+ [42], None, [longlong.getfloatstorage(3.5)])
+ assert longlong.getrealfloat(x) == 3.5 - 42
def test_call(self):
from pypy.rlib.libffi import types
@@ -495,13 +506,13 @@
func_ptr = llhelper(FPTR, func)
calldescr = cpu.calldescrof(FUNC, FUNC.ARGS, FUNC.RESULT)
funcbox = self.get_funcbox(cpu, func_ptr)
- args = ([BoxFloat(.1) for i in range(7)] +
- [BoxInt(1), BoxInt(2), BoxFloat(.2), BoxFloat(.3),
- BoxFloat(.4)])
+ args = ([boxfloat(.1) for i in range(7)] +
+ [BoxInt(1), BoxInt(2), boxfloat(.2), boxfloat(.3),
+ boxfloat(.4)])
res = self.execute_operation(rop.CALL,
[funcbox] + args,
'float', descr=calldescr)
- assert abs(res.value - 4.6) < 0.0001
+ assert abs(res.getfloat() - 4.6) < 0.0001
def test_call_many_arguments(self):
# Test calling a function with a large number of arguments (more than
@@ -563,6 +574,22 @@
descr=calldescr)
assert res.value == ord('a')
+ def test_call_with_const_floats(self):
+ if not self.cpu.supports_floats:
+ py.test.skip("requires floats")
+ def func(f1, f2):
+ return f1 + f2
+
+ FUNC = self.FuncType([lltype.Float, lltype.Float], lltype.Float)
+ FPTR = self.Ptr(FUNC)
+ calldescr = self.cpu.calldescrof(FUNC, FUNC.ARGS, FUNC.RESULT)
+ func_ptr = llhelper(FPTR, func)
+ funcbox = self.get_funcbox(self.cpu, func_ptr)
+ res = self.execute_operation(rop.CALL, [funcbox, constfloat(1.5),
+ constfloat(2.5)], 'float',
+ descr=calldescr)
+ assert res.getfloat() == 4.0
+
def test_field_basic(self):
t_box, T_box = self.alloc_instance(self.T)
@@ -615,17 +642,17 @@
assert res.value == null_const.value
if self.cpu.supports_floats:
floatdescr = self.cpu.fielddescrof(self.S, 'float')
- self.execute_operation(rop.SETFIELD_GC, [t_box, BoxFloat(3.4)],
+ self.execute_operation(rop.SETFIELD_GC, [t_box, boxfloat(3.4)],
'void', descr=floatdescr)
res = self.execute_operation(rop.GETFIELD_GC, [t_box],
'float', descr=floatdescr)
- assert res.value == 3.4
+ assert res.getfloat() == 3.4
#
- self.execute_operation(rop.SETFIELD_GC, [t_box, ConstFloat(-3.6)],
+ self.execute_operation(rop.SETFIELD_GC, [t_box, constfloat(-3.6)],
'void', descr=floatdescr)
res = self.execute_operation(rop.GETFIELD_GC, [t_box],
'float', descr=floatdescr)
- assert res.value == -3.6
+ assert res.getfloat() == -3.6
def test_passing_guards(self):
@@ -641,7 +668,7 @@
(rop.GUARD_ISNULL, [nullbox])
])
if self.cpu.supports_floats:
- all.append((rop.GUARD_VALUE, [BoxFloat(3.5), ConstFloat(3.5)]))
+ all.append((rop.GUARD_VALUE, [boxfloat(3.5), constfloat(3.5)]))
for (opname, args) in all:
assert self.execute_operation(opname, args, 'void') == None
assert not self.guard_failed
@@ -667,7 +694,7 @@
(rop.GUARD_NONNULL, [nullbox]),
(rop.GUARD_ISNULL, [t_box])])
if self.cpu.supports_floats:
- all.append((rop.GUARD_VALUE, [BoxFloat(-1.0), ConstFloat(1.0)]))
+ all.append((rop.GUARD_VALUE, [boxfloat(-1.0), constfloat(1.0)]))
for opname, args in all:
assert self.execute_operation(opname, args, 'void') == None
assert self.guard_failed
@@ -832,17 +859,17 @@
a_box, A = self.alloc_array_of(lltype.Float, 31)
arraydescr = self.cpu.arraydescrof(A)
self.execute_operation(rop.SETARRAYITEM_GC, [a_box, BoxInt(1),
- BoxFloat(3.5)],
+ boxfloat(3.5)],
'void', descr=arraydescr)
self.execute_operation(rop.SETARRAYITEM_GC, [a_box, BoxInt(2),
- ConstFloat(4.5)],
+ constfloat(4.5)],
'void', descr=arraydescr)
r = self.execute_operation(rop.GETARRAYITEM_GC, [a_box, BoxInt(1)],
'float', descr=arraydescr)
- assert r.value == 3.5
+ assert r.getfloat() == 3.5
r = self.execute_operation(rop.GETARRAYITEM_GC, [a_box, BoxInt(2)],
'float', descr=arraydescr)
- assert r.value == 4.5
+ assert r.getfloat() == 4.5
# For platforms where sizeof(INT) != sizeof(Signed) (ie, x86-64)
a_box, A = self.alloc_array_of(rffi.INT, 342)
@@ -942,10 +969,10 @@
assert r.value == u_box.value
if self.cpu.supports_floats:
- r = self.execute_operation(rop.SAME_AS, [ConstFloat(5.5)], 'float')
- assert r.value == 5.5
- r = self.execute_operation(rop.SAME_AS, [BoxFloat(5.5)], 'float')
- assert r.value == 5.5
+ r = self.execute_operation(rop.SAME_AS, [constfloat(5.5)], 'float')
+ assert r.getfloat() == 5.5
+ r = self.execute_operation(rop.SAME_AS, [boxfloat(5.5)], 'float')
+ assert r.getfloat() == 5.5
def test_virtual_ref(self):
pass # VIRTUAL_REF must not reach the backend nowadays
@@ -1016,7 +1043,7 @@
p = lltype.malloc(S)
values.append(lltype.cast_opaque_ptr(llmemory.GCREF, p))
elif isinstance(box, BoxFloat):
- values.append(r.random())
+ values.append(longlong.getfloatstorage(r.random()))
else:
assert 0
values[index_counter] = 11
@@ -1064,7 +1091,7 @@
faildescr1 = BasicFailDescr(1)
faildescr2 = BasicFailDescr(2)
operations = [
- ResOperation(rop.FLOAT_LE, [fboxes[0], ConstFloat(9.2)], i2),
+ ResOperation(rop.FLOAT_LE, [fboxes[0], constfloat(9.2)], i2),
ResOperation(rop.GUARD_TRUE, [i2], None, descr=faildescr1),
ResOperation(rop.FINISH, fboxes, None, descr=faildescr2),
]
@@ -1075,20 +1102,22 @@
fboxes2 = [BoxFloat() for i in range(12)]
f3 = BoxFloat()
bridge = [
- ResOperation(rop.FLOAT_SUB, [fboxes2[0], ConstFloat(1.0)], f3),
+ ResOperation(rop.FLOAT_SUB, [fboxes2[0], constfloat(1.0)], f3),
ResOperation(rop.JUMP, [f3] + fboxes2[1:], None, descr=looptoken),
]
self.cpu.compile_bridge(faildescr1, fboxes2, bridge, looptoken)
for i in range(len(fboxes)):
- self.cpu.set_future_value_float(i, 13.5 + 6.73 * i)
+ x = 13.5 + 6.73 * i
+ self.cpu.set_future_value_float(i, longlong.getfloatstorage(x))
fail = self.cpu.execute_token(looptoken)
assert fail.identifier == 2
res = self.cpu.get_latest_value_float(0)
- assert res == 8.5
+ assert longlong.getrealfloat(res) == 8.5
for i in range(1, len(fboxes)):
- assert self.cpu.get_latest_value_float(i) == 13.5 + 6.73 * i
+ got = longlong.getrealfloat(self.cpu.get_latest_value_float(i))
+ assert got == 13.5 + 6.73 * i
def test_integers_and_guards(self):
for opname, compare in [
@@ -1165,11 +1194,11 @@
if combinaison[0] == 'b':
fbox1 = BoxFloat()
else:
- fbox1 = ConstFloat(-4.5)
+ fbox1 = constfloat(-4.5)
if combinaison[1] == 'b':
fbox2 = BoxFloat()
else:
- fbox2 = ConstFloat(-4.5)
+ fbox2 = constfloat(-4.5)
b1 = BoxInt()
faildescr1 = BasicFailDescr(1)
faildescr2 = BasicFailDescr(2)
@@ -1193,10 +1222,12 @@
if test2 == -4.5 or combinaison[1] == 'b':
n = 0
if combinaison[0] == 'b':
- cpu.set_future_value_float(n, test1)
+ cpu.set_future_value_float(
+ n, longlong.getfloatstorage(test1))
n += 1
if combinaison[1] == 'b':
- cpu.set_future_value_float(n, test2)
+ cpu.set_future_value_float(
+ n, longlong.getfloatstorage(test2))
n += 1
fail = cpu.execute_token(looptoken)
#
@@ -1246,7 +1277,7 @@
if isinstance(box, BoxInt):
self.cpu.set_future_value_int(i, box.getint())
elif isinstance(box, BoxFloat):
- self.cpu.set_future_value_float(i, box.getfloat())
+ self.cpu.set_future_value_float(i, box.getfloatstorage())
else:
assert 0
#
@@ -1257,15 +1288,15 @@
if not self.cpu.supports_floats:
py.test.skip("requires floats")
- from pypy.rlib.rarithmetic import INFINITY, NAN, isinf, isnan
+ from pypy.rlib.rfloat import INFINITY, NAN, isinf, isnan
from pypy.jit.metainterp.resoperation import opname
- fzer = BoxFloat(0.0)
- fone = BoxFloat(1.0)
- fmqr = BoxFloat(-0.25)
- finf = BoxFloat(INFINITY)
- fmnf = BoxFloat(-INFINITY)
- fnan = BoxFloat(NAN)
+ fzer = boxfloat(0.0)
+ fone = boxfloat(1.0)
+ fmqr = boxfloat(-0.25)
+ finf = boxfloat(INFINITY)
+ fmnf = boxfloat(-INFINITY)
+ fnan = boxfloat(NAN)
all_cases_unary = [(a,) for a in [fzer,fone,fmqr,finf,fmnf,fnan]]
all_cases_binary = [(a, b) for a in [fzer,fone,fmqr,finf,fmnf,fnan]
@@ -1275,7 +1306,7 @@
def nan_and_infinity(opnum, realoperation, testcases):
for testcase in testcases:
- realvalues = [b.value for b in testcase]
+ realvalues = [b.getfloat() for b in testcase]
expected = realoperation(*realvalues)
if isinstance(expected, float):
expectedtype = 'float'
@@ -1284,15 +1315,17 @@
got = self.execute_operation(opnum, list(testcase),
expectedtype)
if isnan(expected):
- ok = isnan(got.value)
+ ok = isnan(got.getfloat())
elif isinf(expected):
- ok = isinf(got.value)
+ ok = isinf(got.getfloat())
+ elif isinstance(got, BoxFloat):
+ ok = (got.getfloat() == expected)
else:
- ok = (got.value == expected)
+ ok = got.value == expected
if not ok:
raise AssertionError("%s(%s): got %r, expected %r" % (
opname[opnum], ', '.join(map(repr, realvalues)),
- got.value, expected))
+ got.getfloat(), expected))
# if we expect a boolean, also check the combination with
# a GUARD_TRUE or GUARD_FALSE
if isinstance(expected, bool):
@@ -1312,7 +1345,8 @@
self.cpu.compile_loop(unique_testcase_list, operations,
looptoken)
for i, box in enumerate(unique_testcase_list):
- self.cpu.set_future_value_float(i, box.value)
+ self.cpu.set_future_value_float(
+ i, box.getfloatstorage())
fail = self.cpu.execute_token(looptoken)
if fail.identifier != 5 - (expected_id^expected):
if fail.identifier == 4:
@@ -1783,7 +1817,8 @@
self.cpu.set_future_value_int(1, 0)
fail = self.cpu.execute_token(looptoken)
assert fail.identifier == 0
- assert self.cpu.get_latest_value_float(0) == 42.5
+ x = self.cpu.get_latest_value_float(0)
+ assert longlong.getrealfloat(x) == 42.5
assert values == []
self.cpu.set_future_value_int(0, 10)
@@ -1791,7 +1826,8 @@
fail = self.cpu.execute_token(looptoken)
assert fail.identifier == 1
assert self.cpu.get_latest_value_int(0) == 1
- assert self.cpu.get_latest_value_float(1) == 42.5
+ x = self.cpu.get_latest_value_float(1)
+ assert longlong.getrealfloat(x) == 42.5
assert self.cpu.get_latest_value_int(2) == 10
assert values == [1, 10]
@@ -1826,9 +1862,10 @@
descr_C = cpu.arraydescrof(C)
x = cpu.bh_getarrayitem_gc_f(
descr_C, lltype.cast_opaque_ptr(llmemory.GCREF, c), 3)
- assert x == 3.5
+ assert longlong.getrealfloat(x) == 3.5
cpu.bh_setarrayitem_gc_f(
- descr_C, lltype.cast_opaque_ptr(llmemory.GCREF, c), 4, 4.5)
+ descr_C, lltype.cast_opaque_ptr(llmemory.GCREF, c), 4,
+ longlong.getfloatstorage(4.5))
assert c[4] == 4.5
s = rstr.mallocstr(6)
x = cpu.bh_strlen(lltype.cast_opaque_ptr(llmemory.GCREF, s))
@@ -1882,13 +1919,13 @@
descrfld_z = cpu.fielddescrof(S, 'z')
cpu.bh_setfield_gc_f(
lltype.cast_opaque_ptr(llmemory.GCREF, s),
- descrfld_z, 3.5)
+ descrfld_z, longlong.getfloatstorage(3.5))
assert s.z == 3.5
s.z = 3.2
x = cpu.bh_getfield_gc_f(
lltype.cast_opaque_ptr(llmemory.GCREF, s),
descrfld_z)
- assert x == 3.2
+ assert longlong.getrealfloat(x) == 3.2
### we don't support in the JIT for now GC pointers
### stored inside non-GC structs.
#descrfld_ry = cpu.fielddescrof(RS, 'y')
@@ -2044,7 +2081,8 @@
py.test.skip("requires floats")
called = []
def assembler_helper(failindex, virtualizable):
- assert self.cpu.get_latest_value_float(0) == 1.2 + 3.2
+ x = self.cpu.get_latest_value_float(0)
+ assert longlong.getrealfloat(x) == 1.2 + 3.2
called.append(failindex)
return 13.5
@@ -2070,10 +2108,11 @@
looptoken = LoopToken()
looptoken.outermost_jitdriver_sd = FakeJitDriverSD()
self.cpu.compile_loop(loop.inputargs, loop.operations, looptoken)
- self.cpu.set_future_value_float(0, 1.2)
- self.cpu.set_future_value_float(1, 2.3)
+ self.cpu.set_future_value_float(0, longlong.getfloatstorage(1.2))
+ self.cpu.set_future_value_float(1, longlong.getfloatstorage(2.3))
res = self.cpu.execute_token(looptoken)
- assert self.cpu.get_latest_value_float(0) == 1.2 + 2.3
+ x = self.cpu.get_latest_value_float(0)
+ assert longlong.getrealfloat(x) == 1.2 + 2.3
ops = '''
[f4, f5]
f3 = call_assembler(f4, f5, descr=looptoken)
@@ -2083,10 +2122,11 @@
loop = parse(ops, namespace=locals())
othertoken = LoopToken()
self.cpu.compile_loop(loop.inputargs, loop.operations, othertoken)
- self.cpu.set_future_value_float(0, 1.2)
- self.cpu.set_future_value_float(1, 3.2)
+ self.cpu.set_future_value_float(0, longlong.getfloatstorage(1.2))
+ self.cpu.set_future_value_float(1, longlong.getfloatstorage(3.2))
res = self.cpu.execute_token(othertoken)
- assert self.cpu.get_latest_value_float(0) == 13.5
+ x = self.cpu.get_latest_value_float(0)
+ assert longlong.getrealfloat(x) == 13.5
assert called
# test the fast path, which should not call assembler_helper()
@@ -2095,10 +2135,11 @@
try:
othertoken = LoopToken()
self.cpu.compile_loop(loop.inputargs, loop.operations, othertoken)
- self.cpu.set_future_value_float(0, 1.2)
- self.cpu.set_future_value_float(1, 3.2)
+ self.cpu.set_future_value_float(0, longlong.getfloatstorage(1.2))
+ self.cpu.set_future_value_float(1, longlong.getfloatstorage(3.2))
res = self.cpu.execute_token(othertoken)
- assert self.cpu.get_latest_value_float(0) == 1.2 + 3.2
+ x = self.cpu.get_latest_value_float(0)
+ assert longlong.getrealfloat(x) == 1.2 + 3.2
assert not called
finally:
del self.cpu.done_with_this_frame_float_v
@@ -2132,7 +2173,8 @@
py.test.skip("requires floats")
called = []
def assembler_helper(failindex, virtualizable):
- assert self.cpu.get_latest_value_float(0) == 1.25 + 3.25
+ x = self.cpu.get_latest_value_float(0)
+ assert longlong.getrealfloat(x) == 1.25 + 3.25
called.append(failindex)
return 13.5
@@ -2157,10 +2199,11 @@
looptoken = LoopToken()
looptoken.outermost_jitdriver_sd = FakeJitDriverSD()
self.cpu.compile_loop(loop.inputargs, loop.operations, looptoken)
- self.cpu.set_future_value_float(0, 1.25)
- self.cpu.set_future_value_float(1, 2.35)
+ self.cpu.set_future_value_float(0, longlong.getfloatstorage(1.25))
+ self.cpu.set_future_value_float(1, longlong.getfloatstorage(2.35))
res = self.cpu.execute_token(looptoken)
- assert self.cpu.get_latest_value_float(0) == 1.25 + 2.35
+ x = self.cpu.get_latest_value_float(0)
+ assert longlong.getrealfloat(x) == 1.25 + 2.35
assert not called
ops = '''
@@ -2174,10 +2217,11 @@
self.cpu.compile_loop(loop.inputargs, loop.operations, othertoken)
# normal call_assembler: goes to looptoken
- self.cpu.set_future_value_float(0, 1.25)
- self.cpu.set_future_value_float(1, 3.25)
+ self.cpu.set_future_value_float(0, longlong.getfloatstorage(1.25))
+ self.cpu.set_future_value_float(1, longlong.getfloatstorage(3.25))
res = self.cpu.execute_token(othertoken)
- assert self.cpu.get_latest_value_float(0) == 13.5
+ x = self.cpu.get_latest_value_float(0)
+ assert longlong.getrealfloat(x) == 13.5
assert called
del called[:]
@@ -2195,10 +2239,12 @@
self.cpu.redirect_call_assembler(looptoken, looptoken2)
# now, our call_assembler should go to looptoken2
- self.cpu.set_future_value_float(0, 6.0)
- self.cpu.set_future_value_float(1, 1.5) # 6.0-1.5 == 1.25+3.25
+ self.cpu.set_future_value_float(0, longlong.getfloatstorage(6.0))
+ self.cpu.set_future_value_float(1, longlong.getfloatstorage(1.5))
+ # 6.0-1.5 == 1.25+3.25
res = self.cpu.execute_token(othertoken)
- assert self.cpu.get_latest_value_float(0) == 13.5
+ x = self.cpu.get_latest_value_float(0)
+ assert longlong.getrealfloat(x) == 13.5
assert called
def test_short_result_of_getfield_direct(self):
@@ -2395,6 +2441,66 @@
assert res.value == expected, (
"%r: got %r, expected %r" % (RESTYPE, res.value, expected))
+ def test_supports_longlong(self):
+ if sys.maxint > 2147483647:
+ assert not self.cpu.supports_longlong, (
+ "supports_longlong should be False on 64-bit platforms")
+
+ def test_longlong_result_of_call_direct(self):
+ if not self.cpu.supports_longlong:
+ py.test.skip("longlong test")
+ from pypy.translator.tool.cbuild import ExternalCompilationInfo
+ from pypy.rlib.rarithmetic import r_longlong
+ eci = ExternalCompilationInfo(
+ separate_module_sources=["""
+ long long fn_test_result_of_call(long long x)
+ {
+ return x - 100000000000000;
+ }
+ """],
+ export_symbols=['fn_test_result_of_call'])
+ f = rffi.llexternal('fn_test_result_of_call', [lltype.SignedLongLong],
+ lltype.SignedLongLong,
+ compilation_info=eci, _nowrapper=True)
+ value = r_longlong(0x7ff05af3307a3fff)
+ expected = r_longlong(0x7ff000001fffffff)
+ assert f(value) == expected
+ #
+ FUNC = self.FuncType([lltype.SignedLongLong], lltype.SignedLongLong)
+ FPTR = self.Ptr(FUNC)
+ calldescr = self.cpu.calldescrof(FUNC, FUNC.ARGS, FUNC.RESULT)
+ x = self.cpu.bh_call_f(self.get_funcbox(self.cpu, f).value,
+ calldescr, None, None, [value])
+ assert x == expected
+
+ def test_longlong_result_of_call_compiled(self):
+ if not self.cpu.supports_longlong:
+ py.test.skip("test of longlong result")
+ from pypy.translator.tool.cbuild import ExternalCompilationInfo
+ from pypy.rlib.rarithmetic import r_longlong
+ eci = ExternalCompilationInfo(
+ separate_module_sources=["""
+ long long fn_test_result_of_call(long long x)
+ {
+ return x - 100000000000000;
+ }
+ """],
+ export_symbols=['fn_test_result_of_call'])
+ f = rffi.llexternal('fn_test_result_of_call', [lltype.SignedLongLong],
+ lltype.SignedLongLong,
+ compilation_info=eci, _nowrapper=True)
+ value = r_longlong(0x7ff05af3307a3fff)
+ expected = r_longlong(0x7ff000001fffffff)
+ assert f(value) == expected
+ #
+ FUNC = self.FuncType([lltype.SignedLongLong], lltype.SignedLongLong)
+ FPTR = self.Ptr(FUNC)
+ calldescr = self.cpu.calldescrof(FUNC, FUNC.ARGS, FUNC.RESULT)
+ funcbox = self.get_funcbox(self.cpu, f)
+ res = self.execute_operation(rop.CALL, [funcbox, BoxFloat(value)],
+ 'float', descr=calldescr)
+ assert res.getfloatstorage() == expected
+
def test_free_loop_and_bridges(self):
from pypy.jit.backend.llsupport.llmodel import AbstractLLCPU
if not isinstance(self.cpu, AbstractLLCPU):
diff --git a/pypy/module/parser/app_helpers.py b/pypy/module/parser/app_helpers.py
deleted file mode 100644
--- a/pypy/module/parser/app_helpers.py
+++ /dev/null
@@ -1,2 +0,0 @@
-class ParserError(Exception):
- pass
diff --git a/pypy/module/readline/test/__init__.py b/pypy/module/readline/test/__init__.py
deleted file mode 100644
--- a/pypy/module/readline/test/__init__.py
+++ /dev/null
@@ -1,1 +0,0 @@
-#
diff --git a/pypy/module/select/app_select.py b/pypy/module/select/app_select.py
deleted file mode 100644
--- a/pypy/module/select/app_select.py
+++ /dev/null
@@ -1,2 +0,0 @@
-class error(Exception):
- pass
diff --git a/pypy/objspace/std/test/helper.py b/pypy/objspace/std/test/helper.py
deleted file mode 100644
--- a/pypy/objspace/std/test/helper.py
+++ /dev/null
@@ -1,69 +0,0 @@
-def raises(excp, func, *args):
- try:
- func(*args)
- assert 1 == 0
- except excp:pass
-
-def assertEqual(a, b):
- assert a == b
-
-def assertNotEqual(a, b):
- assert a != b
-
-def assertIs(a, b):
- assert a is b
-
-# complex specific tests
-
-EPS = 1e-9
-
-def assertAlmostEqual(a, b):
- if isinstance(a, complex):
- if isinstance(b, complex):
- assert a.real - b.real < EPS
- assert a.imag - b.imag < EPS
- else:
- assert a.real - b < EPS
- assert a.imag < EPS
- else:
- if isinstance(b, complex):
- assert a - b.real < EPS
- assert b.imag < EPS
- else:
- assert a - b < EPS
-
-def assertCloseAbs(x, y, eps=1e-9):
- """Return true iff floats x and y "are close\""""
- # put the one with larger magnitude second
- if abs(x) > abs(y):
- x, y = y, x
- if y == 0:
- return abs(x) < eps
- if x == 0:
- return abs(y) < eps
- # check that relative difference < eps
- assert abs((x-y)/y) < eps
-
-def assertClose(x, y, eps=1e-9):
- """Return true iff complexes x and y "are close\""""
- assertCloseAbs(x.real, y.real, eps)
- assertCloseAbs(x.imag, y.imag, eps)
-
-
-def check_div(x, y):
- """Compute complex z=x*y, and check that z/x==y and z/y==x."""
- z = x * y
- if x != 0:
- q = z / x
- assertClose(q, y)
- q = z.__div__(x)
- assertClose(q, y)
- q = z.__truediv__(x)
- assertClose(q, y)
- if y != 0:
- q = z / y
- assertClose(q, x)
- q = z.__div__(y)
- assertClose(q, x)
- q = z.__truediv__(y)
- assertClose(q, x)
diff --git a/pypy/module/termios/app_termios.py b/pypy/module/termios/app_termios.py
deleted file mode 100644
--- a/pypy/module/termios/app_termios.py
+++ /dev/null
@@ -1,3 +0,0 @@
-
-class error(Exception):
- pass
diff --git a/pypy/module/_ssl/app_ssl.py b/pypy/module/_ssl/app_ssl.py
deleted file mode 100644
--- a/pypy/module/_ssl/app_ssl.py
+++ /dev/null
@@ -1,7 +0,0 @@
-import _socket
-
-class SSLError(_socket.error):
- pass
-
-__doc__ = """Implementation module for SSL socket operations.
-See the socket module for documentation."""
diff --git a/pypy/module/pyexpat/app_pyexpat.py b/pypy/module/pyexpat/app_pyexpat.py
deleted file mode 100644
--- a/pypy/module/pyexpat/app_pyexpat.py
+++ /dev/null
@@ -1,6 +0,0 @@
-class ExpatError(Exception):
- def __init__(self, msg, code, lineno, colno):
- Exception.__init__(self, msg)
- self.code = code
- self.lineno = lineno
- self.colno = colno
diff --git a/pypy/module/cpyext/include/modsupport.inl b/pypy/module/cpyext/include/modsupport.inl
deleted file mode 100644
--- a/pypy/module/cpyext/include/modsupport.inl
+++ /dev/null
@@ -1,29 +0,0 @@
-/* -*- C -*- */
-/* Module support interface */
-
-#ifndef Py_MODSUPPORT_INL
-#define Py_MODSUPPORT_INL
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifdef PYPY_STANDALONE
-/* XXX1 On translation, forwarddecl.h is included after this file */
-/* XXX2 genc.py transforms "const char*" into "char*" */
-extern PyObject *_Py_InitPyPyModule(char *, PyMethodDef *, char *, PyObject *, int);
-#endif
-
-Py_LOCAL_INLINE(PyObject *) Py_InitModule4(
- const char* name, PyMethodDef* methods,
- const char* doc, PyObject *self,
- int api_version)
-{
- return _Py_InitPyPyModule((char*)name, methods,
- (char*)doc, self,
- api_version);
-}
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* !Py_MODSUPPORT_INL */
diff --git a/pypy/jit/backend/arm/assembler.py b/pypy/jit/backend/arm/assembler.py
--- a/pypy/jit/backend/arm/assembler.py
+++ b/pypy/jit/backend/arm/assembler.py
@@ -5,8 +5,8 @@
from pypy.jit.backend.arm.codebuilder import ARMv7Builder, OverwritingBuilder
from pypy.jit.backend.arm.regalloc import (Regalloc, ARMFrameManager,
_check_imm_arg, TempInt, TempPtr)
+from pypy.jit.backend.llsupport.regalloc import compute_vars_longevity, TempBox
from pypy.jit.backend.llsupport.asmmemmgr import MachineDataBlockWrapper
-from pypy.jit.backend.llsupport.regalloc import compute_vars_longevity, TempBox
from pypy.jit.backend.model import CompiledLoopToken
from pypy.jit.metainterp.history import (Const, ConstInt, ConstPtr,
BoxInt, BoxPtr, AbstractFailDescr,
@@ -19,6 +19,8 @@
from pypy.rpython.annlowlevel import llhelper
from pypy.rpython.lltypesystem import lltype, rffi, llmemory
from pypy.jit.backend.arm.opassembler import ResOpAssembler
+from pypy.rlib.debug import (debug_print, debug_start, debug_stop,
+ have_debug_prints)
# XXX Move to llsupport
from pypy.jit.backend.x86.support import values_array
@@ -58,6 +60,8 @@
self.fail_boxes_int = values_array(lltype.Signed, failargs_limit)
self.fail_boxes_float = values_array(lltype.Float, failargs_limit)
self.fail_boxes_ptr = values_array(llmemory.GCREF, failargs_limit)
+ self.fail_boxes_count = 0
+ self.fail_force_index = 0
self.setup_failure_recovery()
self.mc = None
self.malloc_func_addr = 0
@@ -67,16 +71,12 @@
self.memcpy_addr = 0
self.teardown()
self._exit_code_addr = 0
- self.datablockwrapper = None
- def setup(self, looptoken):
+ def setup(self):
assert self.memcpy_addr != 0, 'setup_once() not called?'
self.mc = ARMv7Builder()
self.guard_descrs = []
- if self.datablockwrapper is None:
- allblocks = self.get_asmmemmgr_blocks(looptoken)
- self.datablockwrapper = MachineDataBlockWrapper(self.cpu.asmmemmgr,
- allblocks)
+ self.blocks = []
def setup_once(self):
# Addresses of functions called by new_xxx operations
@@ -98,6 +98,8 @@
ll_new_unicode)
self.memcpy_addr = self.cpu.cast_ptr_to_int(memcpy_fn)
self._exit_code_addr = self._gen_exit_path()
+ self._leave_jitted_jook_save_exc = self._gen_leave_jitted_hook_code(True)
+ self._leave_jitted_jook = self._gen_leave_jitted_hook_code(False)
def setup_failure_recovery(self):
@@ -168,6 +170,7 @@
assert enc[i] == self.END_OF_LOCS
descr = self.decode32(enc, i+1)
self.fail_boxes_count = fail_index
+ self.fail_force_index = frame_loc
return descr
def decode_inputargs(self, enc, inputargs, regalloc):
@@ -222,13 +225,23 @@
mem[i+2] = chr((n >> 16) & 0xFF)
mem[i+3] = chr((n >> 24) & 0xFF)
+ def _gen_leave_jitted_hook_code(self, save_exc=False):
+ mc = ARMv7Builder()
+ mc.PUSH([reg.value for reg in r.caller_resp] + [r.ip.value])
+ addr = self.cpu.get_on_leave_jitted_int(save_exception=save_exc)
+ mc.BL(addr)
+ mc.POP([reg.value for reg in r.caller_resp]+[r.ip.value])
+ assert self._exit_code_addr != 0
+ mc.B(self._exit_code_addr)
+ return mc.materialize(self.cpu.asmmemmgr, [],
+ self.cpu.gc_ll_descr.gcrootmap)
def _gen_exit_path(self):
mc = ARMv7Builder()
decode_registers_addr = llhelper(self.recovery_func_sign, self.failure_recovery_func)
mc.PUSH([reg.value for reg in r.all_regs]) # registers r0 .. r10
mc.VPUSH([reg.value for reg in r.all_vfp_regs]) # registers d0 .. d15
- mc.MOV_rr(r.r0.value, r.lr.value) # move mem block address, to r0
+ mc.MOV_rr(r.r0.value, r.ip.value) # move mem block address, to r0
mc.MOV_rr(r.r1.value, r.fp.value) # pass the current frame pointer as second param
mc.MOV_rr(r.r2.value, r.sp.value) # pass the current stack pointer as third param
@@ -240,12 +253,11 @@
return mc.materialize(self.cpu.asmmemmgr, [],
self.cpu.gc_ll_descr.gcrootmap)
- def _gen_path_to_exit_path(self, op, args, arglocs, fcond=c.AL):
+ def _gen_path_to_exit_path(self, op, args, arglocs, fcond=c.AL, save_exc=False):
descr = op.getdescr()
if op.getopnum() != rop.FINISH:
assert isinstance(descr, AbstractFailDescr)
descr._arm_frame_depth = arglocs[0].getint()
- reg = r.lr
# The size of the allocated memory is based on the following sizes
# first argloc is the frame depth and not considered for the memory
# allocation
@@ -254,9 +266,12 @@
# 1 byte for the location
# 1 separator byte
# 4 bytes for the faildescr
- # XXX free this memory
- mem = lltype.malloc(rffi.CArray(lltype.Char), (len(arglocs)-1)*6+5,
- flavor='raw', track_allocation=False)
+ memsize = (len(arglocs)-1)*6+5
+ datablockwrapper = MachineDataBlockWrapper(self.cpu.asmmemmgr,
+ self.blocks)
+ memaddr = datablockwrapper.malloc_aligned(memsize, alignment=WORD)
+ datablockwrapper.done()
+ mem = rffi.cast(rffi.CArrayPtr(lltype.Char), memaddr)
i = 0
j = 0
while i < len(args):
@@ -265,21 +280,21 @@
loc = arglocs[i+1]
if arg.type == INT:
mem[j] = self.INT_TYPE
+ j += 1
elif arg.type == REF:
mem[j] = self.REF_TYPE
+ j += 1
elif arg.type == FLOAT:
mem[j] = self.FLOAT_TYPE
+ j += 1
else:
assert 0, 'unknown type'
- j += 1
if loc.is_reg():
mem[j] = chr(loc.value)
j += 1
elif loc.is_imm():
- if not arg.type == INT or arg.type == REF:
- print "Expected INT or REF values"
- assert 0
+ assert arg.type == INT or arg.type == REF
mem[j] = self.IMM_LOC
self.encode32(mem, j+1, loc.getint())
j += 5
@@ -293,12 +308,15 @@
i += 1
mem[j] = chr(0xFF)
- memaddr = rffi.cast(lltype.Signed, mem)
n = self.cpu.get_fail_descr_number(descr)
self.encode32(mem, j+1, n)
- self.mc.LDR_ri(r.lr.value, r.pc.value, imm=WORD)
- self.mc.B(self._exit_code_addr)
+ self.mc.LDR_ri(r.ip.value, r.pc.value, imm=WORD)
+ if save_exc:
+ path = self._leave_jitted_jook_save_exc
+ else:
+ path = self._leave_jitted_jook
+ self.mc.B(path)
self.mc.write32(memaddr)
return memaddr
@@ -330,7 +348,6 @@
elif loc.type == FLOAT:
addr = self.fail_boxes_float.get_addr_for_num(i)
else:
- raise ValueError
self.mc.gen_load_int(r.ip.value, addr)
if not loc.type == FLOAT:
self.mc.LDR_ri(reg.value, r.ip.value)
@@ -341,7 +358,7 @@
looptoken._arm_arglocs = arglocs
return arglocs
- def gen_direct_bootstrap_code(self, arglocs, loop_head, regalloc):
+ def gen_direct_bootstrap_code(self, arglocs, loop_head, looptoken):
self.gen_func_prolog()
if len(arglocs) > 4:
reg_args = 4
@@ -366,23 +383,30 @@
assert 0, 'invalid location'
sp_patch_location = self._prepare_sp_patch_position()
self.mc.B_offs(loop_head)
- self._patch_sp_offset(sp_patch_location, regalloc)
+ self._patch_sp_offset(sp_patch_location, looptoken._arm_frame_depth)
+ def _dump(self, ops, type='loop'):
+ debug_start('jit-backend-ops')
+ debug_print(type)
+ for op in ops:
+ debug_print(op.repr())
+ debug_stop('jit-backend-ops')
# cpu interface
def assemble_loop(self, inputargs, operations, looptoken, log):
+ self._dump(operations)
+ self.setup()
+ longevity = compute_vars_longevity(inputargs, operations)
+ regalloc = ARMRegisterManager(longevity, assembler=self, frame_manager=ARMFrameManager())
+
clt = CompiledLoopToken(self.cpu, looptoken.number)
looptoken.compiled_loop_token = clt
- self.setup(looptoken)
- longevity = compute_vars_longevity(inputargs, operations)
- regalloc = Regalloc(longevity, assembler=self, frame_manager=ARMFrameManager())
-
-
self.align()
self.gen_func_prolog()
+ sp_patch_location = self._prepare_sp_patch_position()
arglocs = self.gen_bootstrap_code(inputargs, regalloc, looptoken)
- sp_patch_location = self._prepare_sp_patch_position()
-
+ #for x in range(5):
+ # self.mc.NOP()
loop_head = self.mc.currpos()
looptoken._arm_loop_code = loop_head
@@ -390,12 +414,13 @@
self._walk_operations(operations, regalloc)
- self._patch_sp_offset(sp_patch_location, regalloc)
+ looptoken._arm_frame_depth = regalloc.frame_manager.frame_depth
+ self._patch_sp_offset(sp_patch_location, looptoken._arm_frame_depth)
self.align()
direct_bootstrap_code = self.mc.currpos()
- self.gen_direct_bootstrap_code(arglocs, loop_head, regalloc)
+ self.gen_direct_bootstrap_code(arglocs, loop_head, looptoken)
loop_start = self.materialize_loop(looptoken)
looptoken._arm_bootstrap_code = loop_start
@@ -409,7 +434,8 @@
def assemble_bridge(self, faildescr, inputargs, operations,
original_loop_token, log):
- self.setup(original_loop_token)
+ self._dump(operations, 'bridge')
+ self.setup()
assert isinstance(faildescr, AbstractFailDescr)
code = faildescr._failure_recovery_code
enc = rffi.cast(rffi.CCHARP, code)
@@ -417,14 +443,15 @@
regalloc = Regalloc(longevity, assembler=self,
frame_manager=ARMFrameManager())
+ sp_patch_location = self._prepare_sp_patch_position()
frame_depth = faildescr._arm_frame_depth
locs = self.decode_inputargs(enc, inputargs, regalloc)
regalloc.update_bindings(locs, frame_depth, inputargs)
- sp_patch_location = self._prepare_sp_patch_position()
self._walk_operations(operations, regalloc)
- self._patch_sp_offset(sp_patch_location, regalloc)
+ #original_loop_token._arm_frame_depth = regalloc.frame_manager.frame_depth
+ self._patch_sp_offset(sp_patch_location, regalloc.frame_manager.frame_depth)
bridge_start = self.materialize_loop(original_loop_token)
self.update_descrs_for_bridges(bridge_start)
@@ -437,9 +464,9 @@
self.teardown()
def materialize_loop(self, looptoken):
- self.datablockwrapper.done() # finish using cpu.asmmemmgr
- self.datablockwrapper = None
allblocks = self.get_asmmemmgr_blocks(looptoken)
+ for block in self.blocks:
+ allblocks.append(block)
return self.mc.materialize(self.cpu.asmmemmgr, allblocks,
self.cpu.gc_ll_descr.gcrootmap)
@@ -468,13 +495,13 @@
self.mc.MOV_rr(r.r0.value, r.r0.value)
return l
- def _patch_sp_offset(self, pos, regalloc):
+ def _patch_sp_offset(self, pos, frame_depth):
cb = OverwritingBuilder(self.mc, pos, OverwritingBuilder.size_of_gen_load_int)
# Note: the frame_depth is one less than the value stored in the frame
# manager
- if regalloc.frame_manager.frame_depth == 1:
+ if frame_depth == 1:
return
- n = (regalloc.frame_manager.frame_depth-1)*WORD
+ n = (frame_depth-1)*WORD
self._adjust_sp(n, cb, base_reg=r.fp)
def _adjust_sp(self, n, cb=None, fcond=c.AL, base_reg=r.sp):
@@ -499,26 +526,26 @@
def _walk_operations(self, operations, regalloc):
fcond=c.AL
- i = 0
- while i < len(operations):
- regalloc.position = i
+ while regalloc.position < len(operations) - 1:
+ regalloc.next_instruction()
+ i = regalloc.position
op = operations[i]
opnum = op.getopnum()
if op.has_no_side_effect() and op.result not in regalloc.longevity:
- i += 1
regalloc.possibly_free_vars_for_op(op)
- continue
elif self.can_merge_with_next_guard(op, i, operations):
+ regalloc.next_instruction()
arglocs = regalloc.operations_with_guard[opnum](regalloc, op,
operations[i+1], fcond)
fcond = self.operations_with_guard[opnum](self, op,
operations[i+1], arglocs, regalloc, fcond)
- i += 1
- regalloc.position = i
else:
arglocs = regalloc.operations[opnum](regalloc, op, fcond)
fcond = self.operations[opnum](self, op, arglocs, regalloc, fcond)
- i += 1
+ if op.result:
+ regalloc.possibly_free_var(op.result)
+ regalloc.possibly_free_vars_for_op(op)
+ regalloc._check_invariants()
def can_merge_with_next_guard(self, op, i, operations):
if op.getopnum() == rop.CALL_MAY_FORCE or op.getopnum() == rop.CALL_ASSEMBLER:
@@ -565,26 +592,53 @@
if value.is_imm():
self.mc.gen_load_int(loc.value, value.getint())
elif value.is_imm_float():
+ #XXX this is wrong
self.mc.gen_load_int(r.ip.value, value.getint())
self.mc.VLDR(loc.value, r.ip.value)
- def regalloc_mov(self, prev_loc, loc):
+ # XXX needs float support
+ def regalloc_mov(self, prev_loc, loc, cond=c.AL):
if prev_loc.is_imm():
+ if loc.is_reg():
+ new_loc = loc
+ else:
+ assert loc is not r.ip
+ new_loc = r.ip
if _check_imm_arg(ConstInt(prev_loc.getint())):
- self.mc.MOV_ri(loc.value, prev_loc.getint())
+ self.mc.MOV_ri(new_loc.value, prev_loc.getint(), cond=cond)
else:
- self.mc.gen_load_int(loc.value, prev_loc.getint())
- elif loc.is_stack():
- self.mc.STR_ri(prev_loc.value, r.fp.value, loc.position*-WORD)
- elif prev_loc.is_stack():
- self.mc.LDR_ri(loc.value, r.fp.value, prev_loc.position*-WORD)
+ self.mc.gen_load_int(new_loc.value, prev_loc.getint(), cond=cond)
+ prev_loc = new_loc
+ if not loc.is_stack():
+ return
+
+ if loc.is_stack() or prev_loc.is_stack():
+ temp = r.lr
+ if loc.is_stack() and prev_loc.is_reg():
+ offset = ConstInt(loc.position*-WORD)
+ if not _check_imm_arg(offset):
+ self.mc.gen_load_int(temp.value, offset.value)
+ self.mc.STR_rr(prev_loc.value, r.fp.value, temp.value, cond=cond)
+ else:
+ self.mc.STR_ri(prev_loc.value, r.fp.value, offset.value, cond=cond)
+ elif loc.is_reg() and prev_loc.is_stack():
+ offset = ConstInt(prev_loc.position*-WORD)
+ if not _check_imm_arg(offset):
+ self.mc.gen_load_int(temp.value, offset.value)
+ self.mc.LDR_rr(loc.value, r.fp.value, temp.value, cond=cond)
+ else:
+ self.mc.LDR_ri(loc.value, r.fp.value, offset.value, cond=cond)
+ else:
+ assert 0, 'unsupported case'
+ elif loc.is_reg() and prev_loc.is_reg():
+ self.mc.MOV_rr(loc.value, prev_loc.value, cond=cond)
else:
- self.mc.MOV_rr(loc.value, prev_loc.value)
+ assert 0, 'unsupported case'
mov_loc_loc = regalloc_mov
def regalloc_push(self, loc):
if loc.is_stack():
- self.mc.LDR_ri(r.ip.value, r.fp.value, loc.position*-WORD)
+ self.regalloc_mov(loc, r.ip)
self.mc.PUSH([r.ip.value])
elif loc.is_reg():
self.mc.PUSH([loc.value])
@@ -594,7 +648,7 @@
def regalloc_pop(self, loc):
if loc.is_stack():
self.mc.POP([r.ip.value])
- self.mc.STR_ri(r.ip.value, r.fp.value, loc.position*-WORD)
+ self.regalloc_mov(r.ip, loc)
elif loc.is_reg():
self.mc.POP([loc.value])
else:
diff --git a/pypy/module/binascii/app_binascii.py b/pypy/module/binascii/app_binascii.py
deleted file mode 100644
--- a/pypy/module/binascii/app_binascii.py
+++ /dev/null
@@ -1,6 +0,0 @@
-
-class Error(Exception):
- pass
-
-class Incomplete(Exception):
- pass
diff --git a/pypy/jit/backend/arm/helper/assembler.py b/pypy/jit/backend/arm/helper/assembler.py
--- a/pypy/jit/backend/arm/helper/assembler.py
+++ b/pypy/jit/backend/arm/helper/assembler.py
@@ -13,7 +13,7 @@
return fcond
return f
-def gen_emit_op_ri(opname, imm_size=0xFF, commutative=True, allow_zero=True):
+def gen_emit_op_ri(opname):
ri_op = getattr(AbstractARMv7Builder, '%s_ri' % opname)
rr_op = getattr(AbstractARMv7Builder, '%s_rr' % opname)
def f(self, op, arglocs, regalloc, fcond):
@@ -30,9 +30,15 @@
helper = getattr(AbstractARMv7Builder, opname)
def f(self, op, arglocs, regalloc, fcond):
assert fcond is not None
- self.mc.PUSH([reg.value for reg in r.caller_resp][1:])
+ if op.result:
+ self.mc.PUSH([reg.value for reg in r.caller_resp][1:])
+ else:
+ self.mc.PUSH([reg.value for reg in r.caller_resp])
helper(self.mc, fcond)
- self.mc.POP([reg.value for reg in r.caller_resp][1:])
+ if op.result:
+ self.mc.POP([reg.value for reg in r.caller_resp][1:])
+ else:
+ self.mc.POP([reg.value for reg in r.caller_resp])
return fcond
return f
diff --git a/pypy/module/readline/interp_readline.py b/pypy/module/readline/interp_readline.py
deleted file mode 100644
--- a/pypy/module/readline/interp_readline.py
+++ /dev/null
@@ -1,23 +0,0 @@
-# this is a sketch of how one might one day be able to define a pretty simple
-# ctypes-using module, suitable for feeding to the ext-compiler
-
-from pypy.interpreter.baseobjspace import ObjSpace
-
-from pypy.module.readline import c_readline
-from pypy.rpython.lltypesystem import rffi
-
-#------------------------------------------------------------
-# exported API (see interpleveldefs in __init__.py)
-#
-def readline(space, prompt):
- return space.wrap(rffi.charp2str(c_readline.c_readline(prompt)))
-readline.unwrap_spec = [ObjSpace, str]
-
-def setcompleter(space, w_callback):
- """Set or remove the completer function.
- The function is called as function(text, state),
- for state in 0, 1, 2, ..., until it returns a non-string.
- It should return the next possible completion starting with 'text'.
- """
- # XXX set internal completion function
-
diff --git a/pypy/module/zipimport/app_zipimport.py b/pypy/module/zipimport/app_zipimport.py
deleted file mode 100644
--- a/pypy/module/zipimport/app_zipimport.py
+++ /dev/null
@@ -1,4 +0,0 @@
-
-class ZipImportError(ImportError):
- pass
-
More information about the Pypy-commit
mailing list