Author: Richard Plangger <[email protected]>
Branch: new-jit-log
Changeset: r83482:132688540925
Date: 2016-04-01 09:53 +0200
http://bitbucket.org/pypy/pypy/changeset/132688540925/
Log: merged default, translation issue
diff --git a/pypy/doc/__pypy__-module.rst b/pypy/doc/__pypy__-module.rst
--- a/pypy/doc/__pypy__-module.rst
+++ b/pypy/doc/__pypy__-module.rst
@@ -18,6 +18,7 @@
- ``bytebuffer(length)``: return a new read-write buffer of the given length.
It works like a simplified array of characters (actually, depending on the
configuration the ``array`` module internally uses this).
+ - ``attach_gdb()``: start a GDB at the interpreter-level (or a PDB before
translation).
Transparent Proxy Functionality
@@ -37,4 +38,3 @@
--------------------------------------------------------
- ``isfake(obj)``: returns True if ``obj`` is faked.
- - ``interp_pdb()``: start a pdb at interpreter-level.
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
@@ -534,7 +534,7 @@
looptoken._ll_function_addr = rawstart
if logger:
log = logger.log_trace(MARK_TRACE_ASM, None, self.mc)
- log.write(inputargs, operations, None, ops_offset,
unique_id=unique_id)
+ log.write(inputargs, operations, None, ops_offset=ops_offset,
unique_id=unique_id)
self.fixup_target_tokens(rawstart)
self.teardown()
# oprofile support
@@ -647,15 +647,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.
@@ -793,10 +806,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
@@ -817,6 +826,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 rop.is_jit_debug(op):
+ if rop.is_jit_debug(op.getopnum()):
return
for arg in op.getarglist():
diff --git a/rpython/jit/metainterp/compile.py
b/rpython/jit/metainterp/compile.py
--- a/rpython/jit/metainterp/compile.py
+++ b/rpython/jit/metainterp/compile.py
@@ -478,7 +478,7 @@
def do_compile_loop(jd_id, unique_id, metainterp_sd, inputargs, operations,
looptoken, log=True, name='', memo=None):
_log = metainterp_sd.jitlog.log_trace(MARK_TRACE_OPT, metainterp_sd, None)
- _log.write(inputargs, operations, name=name, unique_id=unique_id)
+ _log.write(inputargs, operations, None, name=name, unique_id=unique_id)
# TODO remove old
metainterp_sd.logger_ops.log_loop(inputargs, operations, -2,
'compiling', None, name, memo)
@@ -491,7 +491,7 @@
def do_compile_bridge(metainterp_sd, faildescr, inputargs, operations,
original_loop_token, log=True, memo=None):
_log = metainterp_sd.jitlog.log_trace(MARK_TRACE_OPT, metainterp_sd, None)
- _log.write(inputargs, operations, faildescr=faildescr)
+ _log.write(inputargs, operations, faildescr)
# TODO remove old
metainterp_sd.logger_ops.log_bridge(inputargs, operations, "compiling",
memo=memo)
diff --git a/rpython/jit/metainterp/jitlog.py b/rpython/jit/metainterp/jitlog.py
--- a/rpython/jit/metainterp/jitlog.py
+++ b/rpython/jit/metainterp/jitlog.py
@@ -55,7 +55,7 @@
def log_trace(self, tag, metainterp_sd, mc, memo=None):
if self.cintf.jitlog_filter(tag):
- return
+ return EMPTY_TRACE_LOG
assert isinstance(tag, int)
if memo is None:
memo = {}
@@ -94,8 +94,13 @@
chr((val >> 48) & 0xff),
chr((val >> 56)& 0xff)])
+class BaseLogTrace(object):
+ def write(self, args, ops, faildescr=None, ops_offset={}, name=None,
unique_id=0):
+ return None
-class LogTrace(object):
+EMPTY_TRACE_LOG = BaseLogTrace()
+
+class LogTrace(BaseLogTrace):
def __init__(self, tag, memo, metainterp_sd, mc, logger):
self.memo = memo
self.metainterp_sd = metainterp_sd
@@ -107,15 +112,15 @@
self.logger = logger
def write(self, args, ops, faildescr=None, ops_offset={},
- name=None, unique_id=None):
+ name=None, unique_id=0):
log = self.logger
- if not name:
+ if name is None:
name = ''
# write the initial tag
if faildescr is None:
string = self.logger.encode_str('loop') + \
- self.logger.encode_le_addr(unique_id or 0) + \
+ self.logger.encode_le_addr(unique_id) + \
self.logger.encode_str(name or '')
log.write_marked(self.tag, string)
else:
diff --git a/rpython/jit/metainterp/test/test_virtualref.py
b/rpython/jit/metainterp/test/test_virtualref.py
--- a/rpython/jit/metainterp/test/test_virtualref.py
+++ b/rpython/jit/metainterp/test/test_virtualref.py
@@ -578,7 +578,6 @@
n -= 1
return res
#
- py.test.raises(InvalidVirtualRef, "fn(10)")
py.test.raises(UnknownException, "self.meta_interp(fn, [10])")
def test_call_virtualref_already_forced(self):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit