[pypy-svn] r74551 - in pypy/branch/blackhole-improvement/pypy/jit: backend/llgraph codewriter metainterp
arigo at codespeak.net
arigo at codespeak.net
Tue May 18 22:20:43 CEST 2010
Author: arigo
Date: Tue May 18 22:20:41 2010
New Revision: 74551
Modified:
pypy/branch/blackhole-improvement/pypy/jit/backend/llgraph/runner.py
pypy/branch/blackhole-improvement/pypy/jit/codewriter/jtransform.py
pypy/branch/blackhole-improvement/pypy/jit/codewriter/support.py
pypy/branch/blackhole-improvement/pypy/jit/metainterp/history.py
pypy/branch/blackhole-improvement/pypy/jit/metainterp/pyjitpl.py
Log:
Tweaks.
Modified: pypy/branch/blackhole-improvement/pypy/jit/backend/llgraph/runner.py
==============================================================================
--- pypy/branch/blackhole-improvement/pypy/jit/backend/llgraph/runner.py (original)
+++ pypy/branch/blackhole-improvement/pypy/jit/backend/llgraph/runner.py Tue May 18 22:20:41 2010
@@ -156,8 +156,6 @@
llimpl.compile_add_int_const(c, x.value)
elif isinstance(x, self.ts.ConstRef):
llimpl.compile_add_ref_const(c, x.value, self.ts.BASETYPE)
- elif isinstance(x, history.ConstAddr):
- llimpl.compile_add_int_const(c, x.getint())
elif isinstance(x, history.ConstFloat):
llimpl.compile_add_float_const(c, x.value)
else:
Modified: pypy/branch/blackhole-improvement/pypy/jit/codewriter/jtransform.py
==============================================================================
--- pypy/branch/blackhole-improvement/pypy/jit/codewriter/jtransform.py (original)
+++ pypy/branch/blackhole-improvement/pypy/jit/codewriter/jtransform.py Tue May 18 22:20:41 2010
@@ -303,6 +303,8 @@
extra, extrakey)
return self.rewrite_op_direct_call(op1)
+ # XXX some of the following functions should not become residual calls
+ # but be really compiled
rewrite_op_int_floordiv_ovf_zer = _do_builtin_call
rewrite_op_int_floordiv_ovf = _do_builtin_call
rewrite_op_int_floordiv_zer = _do_builtin_call
@@ -310,6 +312,7 @@
rewrite_op_int_mod_ovf = _do_builtin_call
rewrite_op_int_mod_zer = _do_builtin_call
rewrite_op_int_lshift_ovf = _do_builtin_call
+ rewrite_op_int_abs = _do_builtin_call
rewrite_op_gc_identityhash = _do_builtin_call
# ----------
Modified: pypy/branch/blackhole-improvement/pypy/jit/codewriter/support.py
==============================================================================
--- pypy/branch/blackhole-improvement/pypy/jit/codewriter/support.py (original)
+++ pypy/branch/blackhole-improvement/pypy/jit/codewriter/support.py Tue May 18 22:20:41 2010
@@ -164,6 +164,9 @@
def _ll_2_int_lshift_ovf(x, y):
return llop.int_lshift_ovf(lltype.Signed, x, y)
+def _ll_1_int_abs(x):
+ return abs(x)
+
class LLtypeHelpers:
Modified: pypy/branch/blackhole-improvement/pypy/jit/metainterp/history.py
==============================================================================
--- pypy/branch/blackhole-improvement/pypy/jit/metainterp/history.py (original)
+++ pypy/branch/blackhole-improvement/pypy/jit/metainterp/history.py Tue May 18 22:20:41 2010
@@ -255,7 +255,7 @@
return llmemory.cast_int_to_adr(self.value)
def _get_hash_(self):
- return self.value
+ return integer_hash(self.value)
def set_future_value(self, cpu, j):
cpu.set_future_value_int(j, self.value)
@@ -492,7 +492,7 @@
return llmemory.cast_int_to_adr(self.value)
def _get_hash_(self):
- return self.value
+ return integer_hash(self.value)
def set_future_value(self, cpu, j):
cpu.set_future_value_int(j, self.value)
@@ -655,6 +655,13 @@
except lltype.DelayedPointer:
return -2 # xxx risk of changing hash...
+def integer_hash(i):
+ if not we_are_translated() and isinstance(i, llmemory.AddressAsInt):
+ # Warning: such a hash changes at the time of translation
+ adr = llmemory.cast_int_to_adr(i)
+ return lltype.cast_ptr_to_int(adr.ptr)
+ return i
+
# ____________________________________________________________
# The TreeLoop class contains a loop or a generalized loop, i.e. a tree
Modified: pypy/branch/blackhole-improvement/pypy/jit/metainterp/pyjitpl.py
==============================================================================
--- pypy/branch/blackhole-improvement/pypy/jit/metainterp/pyjitpl.py (original)
+++ pypy/branch/blackhole-improvement/pypy/jit/metainterp/pyjitpl.py Tue May 18 22:20:41 2010
@@ -159,6 +159,7 @@
'float_add', 'float_sub', 'float_mul', 'float_truediv',
'float_lt', 'float_le', 'float_eq',
'float_ne', 'float_gt', 'float_ge',
+ 'ptr_eq', 'ptr_ne',
]:
exec py.code.Source('''
@arguments("box", "box")
@@ -175,9 +176,10 @@
return resbox
''' % (_opimpl, _opimpl.upper())).compile()
- for _opimpl in ['int_is_true', 'int_neg', 'int_invert', 'bool_not',
+ for _opimpl in ['int_is_true', 'int_is_zero', 'int_neg', 'int_invert',
'cast_ptr_to_int', 'cast_float_to_int',
'cast_int_to_float', 'float_neg', 'float_abs',
+ 'ptr_iszero', 'ptr_nonzero',
]:
exec py.code.Source('''
@arguments("box")
@@ -452,48 +454,6 @@
def opimpl_overflow_error(self):
return self.metainterp.raise_overflow_error()
- @FixME #arguments("orgpc", "box")
- def opimpl_int_abs(self, pc, box):
- nonneg = self.metainterp.execute_and_record(
- rop.INT_GE, None, box, ConstInt(0))
- nonneg = self.implement_guard_value(pc, nonneg)
- if nonneg.getint():
- self.make_result_box(box)
- else:
- self.execute(rop.INT_NEG, box)
-
- @FixME #arguments("orgpc", "box")
- def opimpl_oononnull(self, pc, box):
- value = box.nonnull()
- if value:
- opnum = rop.GUARD_NONNULL
- res = ConstInt(1)
- else:
- opnum = rop.GUARD_ISNULL
- res = ConstInt(0)
- self.generate_guard(pc, opnum, box, [])
- self.make_result_box(res)
-
- @FixME #arguments("orgpc", "box")
- def opimpl_ooisnull(self, pc, box):
- value = box.nonnull()
- if value:
- opnum = rop.GUARD_NONNULL
- res = ConstInt(0)
- else:
- opnum = rop.GUARD_ISNULL
- res = ConstInt(1)
- self.generate_guard(pc, opnum, box, [])
- self.make_result_box(res)
-
- @FixME #arguments("box", "box")
- def opimpl_ptr_eq(self, box1, box2):
- self.execute(rop.OOIS, box1, box2)
-
- @FixME #arguments("box", "box")
- def opimpl_ptr_ne(self, box1, box2):
- self.execute(rop.OOISNOT, box1, box2)
-
@arguments("box", "descr")
def _opimpl_getfield_gc_any(self, box, fielddescr):
return self.execute_with_descr(rop.GETFIELD_GC, fielddescr, box)
More information about the Pypy-commit
mailing list