Author: fijal
Branch:
Changeset: r83466:786c1c380bd8
Date: 2016-03-31 16:49 +0200
http://bitbucket.org/pypy/pypy/changeset/786c1c380bd8/
Log: merge
diff --git a/pypy/interpreter/error.py b/pypy/interpreter/error.py
--- a/pypy/interpreter/error.py
+++ b/pypy/interpreter/error.py
@@ -277,19 +277,12 @@
raise NotImplementedError
def get_traceback(self):
- """Calling this marks the PyTraceback as escaped, i.e. it becomes
- accessible and inspectable by app-level Python code.
+ """Get the PyTraceback object, for app-level Python code.
"""
return self._application_traceback
def set_traceback(self, traceback):
- """Set the current traceback. It should either be a traceback
- pointing to some already-escaped frame, or a traceback for the
- current frame. To support the latter case we do not mark the
- frame as escaped. The idea is that it will be marked as escaping
- only if the exception really propagates out of this frame, by
- executioncontext.leave() being called with got_exception=True.
- """
+ """Set the current traceback."""
self._application_traceback = traceback
diff --git a/pypy/module/__pypy__/__init__.py b/pypy/module/__pypy__/__init__.py
--- a/pypy/module/__pypy__/__init__.py
+++ b/pypy/module/__pypy__/__init__.py
@@ -90,6 +90,7 @@
'save_module_content_for_future_reload':
'interp_magic.save_module_content_for_future_reload',
'decode_long' : 'interp_magic.decode_long',
+ '_promote' : 'interp_magic._promote',
}
if sys.platform == 'win32':
interpleveldefs['get_console_cp'] = 'interp_magic.get_console_cp'
diff --git a/pypy/module/__pypy__/interp_magic.py
b/pypy/module/__pypy__/interp_magic.py
--- a/pypy/module/__pypy__/interp_magic.py
+++ b/pypy/module/__pypy__/interp_magic.py
@@ -168,3 +168,22 @@
except InvalidEndiannessError:
raise oefmt(space.w_ValueError, "invalid byteorder argument")
return space.newlong_from_rbigint(result)
+
+def _promote(space, w_obj):
+ """ Promote the first argument of the function and return it. Promote is by
+ value for ints, floats, strs, unicodes (but not subclasses thereof) and by
+ reference otherwise.
+
+ This function is experimental!"""
+ from rpython.rlib import jit
+ if space.is_w(space.type(w_obj), space.w_int):
+ jit.promote(space.int_w(w_obj))
+ elif space.is_w(space.type(w_obj), space.w_float):
+ jit.promote(space.float_w(w_obj))
+ elif space.is_w(space.type(w_obj), space.w_str):
+ jit.promote(space.str_w(w_obj))
+ elif space.is_w(space.type(w_obj), space.w_unicode):
+ jit.promote(space.unicode_w(w_obj))
+ else:
+ jit.promote(w_obj)
+ return w_obj
diff --git a/pypy/module/__pypy__/test/test_magic.py
b/pypy/module/__pypy__/test/test_magic.py
--- a/pypy/module/__pypy__/test/test_magic.py
+++ b/pypy/module/__pypy__/test/test_magic.py
@@ -47,3 +47,16 @@
assert decode_long('\x00\x80', 'little', False) == 32768
assert decode_long('\x00\x80', 'little', True) == -32768
raises(ValueError, decode_long, '', 'foo')
+
+ def test_promote(self):
+ from __pypy__ import _promote
+ assert _promote(1) == 1
+ assert _promote(1.1) == 1.1
+ assert _promote("abc") == "abc"
+ assert _promote(u"abc") == u"abc"
+ l = []
+ assert _promote(l) is l
+ class A(object):
+ pass
+ a = A()
+ assert _promote(a) is a
diff --git a/rpython/jit/backend/x86/assembler.py
b/rpython/jit/backend/x86/assembler.py
--- a/rpython/jit/backend/x86/assembler.py
+++ b/rpython/jit/backend/x86/assembler.py
@@ -645,15 +645,28 @@
pass
elif gloc is not bloc:
self.mov(gloc, bloc)
+ offset = self.mc.get_relative_pos()
self.mc.JMP_l(0)
+ self.mc.writeimm32(0)
self.mc.force_frame_size(DEFAULT_FRAME_BYTES)
- offset = self.mc.get_relative_pos() - 4
rawstart = self.materialize_loop(looptoken)
- # update the jump to the real trace
- self._patch_jump_for_descr(rawstart + offset, asminfo.rawstart)
+ # update the jump (above) to the real trace
+ self._patch_jump_to(rawstart + offset, asminfo.rawstart)
# update the guard to jump right to this custom piece of assembler
self.patch_jump_for_descr(faildescr, rawstart)
+ def _patch_jump_to(self, adr_jump_offset, adr_new_target):
+ assert adr_jump_offset != 0
+ offset = adr_new_target - (adr_jump_offset + 5)
+ mc = codebuf.MachineCodeBlockWrapper()
+ mc.force_frame_size(DEFAULT_FRAME_BYTES)
+ if rx86.fits_in_32bits(offset):
+ mc.JMP_l(offset)
+ else:
+ mc.MOV_ri(X86_64_SCRATCH_REG.value, adr_new_target)
+ mc.JMP_r(X86_64_SCRATCH_REG.value)
+ mc.copy_to_raw_memory(adr_jump_offset)
+
def write_pending_failure_recoveries(self, regalloc):
# for each pending guard, generate the code of the recovery stub
# at the end of self.mc.
@@ -791,10 +804,6 @@
def patch_jump_for_descr(self, faildescr, adr_new_target):
adr_jump_offset = faildescr.adr_jump_offset
- self._patch_jump_for_descr(adr_jump_offset, adr_new_target)
- faildescr.adr_jump_offset = 0 # means "patched"
-
- def _patch_jump_for_descr(self, adr_jump_offset, adr_new_target):
assert adr_jump_offset != 0
offset = adr_new_target - (adr_jump_offset + 4)
# If the new target fits within a rel32 of the jump, just patch
@@ -815,6 +824,7 @@
p = rffi.cast(rffi.INTP, adr_jump_offset)
adr_target = adr_jump_offset + 4 + rffi.cast(lltype.Signed, p[0])
mc.copy_to_raw_memory(adr_target)
+ faildescr.adr_jump_offset = 0 # means "patched"
def fixup_target_tokens(self, rawstart):
for targettoken in self.target_tokens_currently_compiling:
diff --git a/rpython/jit/backend/zarch/pool.py
b/rpython/jit/backend/zarch/pool.py
--- a/rpython/jit/backend/zarch/pool.py
+++ b/rpython/jit/backend/zarch/pool.py
@@ -33,7 +33,7 @@
def ensure_can_hold_constants(self, asm, op):
# allocates 8 bytes in memory for pointers, long integers or floats
- if op.is_jit_debug():
+ if rop.is_jit_debug(op):
return
for arg in op.getarglist():
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit