[pypy-commit] pypy reflex-support: merge default into branch
wlav
noreply at buildbot.pypy.org
Sat Mar 3 08:46:03 CET 2012
Author: Wim Lavrijsen <WLavrijsen at lbl.gov>
Branch: reflex-support
Changeset: r53137:3759abe3a35d
Date: 2012-03-02 23:00 -0800
http://bitbucket.org/pypy/pypy/changeset/3759abe3a35d/
Log: merge default into branch
diff --git a/pypy/interpreter/test/test_typedef.py b/pypy/interpreter/test/test_typedef.py
--- a/pypy/interpreter/test/test_typedef.py
+++ b/pypy/interpreter/test/test_typedef.py
@@ -304,6 +304,42 @@
assert_method(w_o1, "c", True)
assert_method(w_o2, "c", False)
+ def test_total_ordering(self):
+ class W_SomeType(Wrappable):
+ def __init__(self, space, x):
+ self.space = space
+ self.x = x
+
+ def descr__lt(self, w_other):
+ assert isinstance(w_other, W_SomeType)
+ return self.space.wrap(self.x < w_other.x)
+
+ def descr__eq(self, w_other):
+ assert isinstance(w_other, W_SomeType)
+ return self.space.wrap(self.x == w_other.x)
+
+ W_SomeType.typedef = typedef.TypeDef(
+ 'some_type',
+ __total_ordering__ = 'auto',
+ __lt__ = interp2app(W_SomeType.descr__lt),
+ __eq__ = interp2app(W_SomeType.descr__eq),
+ )
+ space = self.space
+ w_b = space.wrap(W_SomeType(space, 2))
+ w_c = space.wrap(W_SomeType(space, 2))
+ w_a = space.wrap(W_SomeType(space, 1))
+ # explicitly defined
+ assert space.is_true(space.lt(w_a, w_b))
+ assert not space.is_true(space.eq(w_a, w_b))
+ assert space.is_true(space.eq(w_b, w_c))
+ # automatically defined
+ assert space.is_true(space.le(w_a, w_b))
+ assert space.is_true(space.le(w_b, w_c))
+ assert space.is_true(space.gt(w_b, w_a))
+ assert space.is_true(space.ge(w_b, w_a))
+ assert space.is_true(space.ge(w_b, w_c))
+ assert space.is_true(space.ne(w_a, w_b))
+ assert not space.is_true(space.ne(w_b, w_c))
class AppTestTypeDef:
diff --git a/pypy/interpreter/typedef.py b/pypy/interpreter/typedef.py
--- a/pypy/interpreter/typedef.py
+++ b/pypy/interpreter/typedef.py
@@ -12,7 +12,7 @@
from pypy.rlib.jit import promote
class TypeDef:
- def __init__(self, __name, __base=None, **rawdict):
+ def __init__(self, __name, __base=None, __total_ordering__=None, **rawdict):
"NOT_RPYTHON: initialization-time only"
self.name = __name
if __base is None:
@@ -34,6 +34,9 @@
# xxx used by faking
self.fakedcpytype = None
self.add_entries(**rawdict)
+ assert __total_ordering__ in (None, 'auto'), "Unknown value for __total_ordering"
+ if __total_ordering__ == 'auto':
+ self.auto_total_ordering()
def add_entries(self, **rawdict):
# xxx fix the names of the methods to match what app-level expects
@@ -41,7 +44,15 @@
if isinstance(value, (interp2app, GetSetProperty)):
value.name = key
self.rawdict.update(rawdict)
-
+
+ def auto_total_ordering(self):
+ assert '__lt__' in self.rawdict, "__total_ordering='auto' requires __lt__"
+ assert '__eq__' in self.rawdict, "__total_ordering='auto' requires __eq__"
+ self.add_entries(__le__ = auto__le__,
+ __gt__ = auto__gt__,
+ __ge__ = auto__ge__,
+ __ne__ = auto__ne__)
+
def _freeze_(self):
# hint for the annotator: track individual constant instances of TypeDef
return True
@@ -50,6 +61,26 @@
return "<%s name=%r>" % (self.__class__.__name__, self.name)
+# generic special cmp methods defined on top of __lt__ and __eq__, used by
+# automatic total ordering
+
+ at interp2app
+def auto__le__(space, w_self, w_other):
+ return space.not_(space.lt(w_other, w_self))
+
+ at interp2app
+def auto__gt__(space, w_self, w_other):
+ return space.lt(w_other, w_self)
+
+ at interp2app
+def auto__ge__(space, w_self, w_other):
+ return space.not_(space.lt(w_self, w_other))
+
+ at interp2app
+def auto__ne__(space, w_self, w_other):
+ return space.not_(space.eq(w_self, w_other))
+
+
# ____________________________________________________________
# Hash support
diff --git a/pypy/jit/backend/llsupport/gc.py b/pypy/jit/backend/llsupport/gc.py
--- a/pypy/jit/backend/llsupport/gc.py
+++ b/pypy/jit/backend/llsupport/gc.py
@@ -208,6 +208,7 @@
This is the class supporting --gcrootfinder=asmgcc.
"""
is_shadow_stack = False
+ is_64_bit = (WORD == 8)
LOC_REG = 0
LOC_ESP_PLUS = 1
@@ -336,17 +337,17 @@
self._gcmap_deadentries += 1
item += asmgcroot.arrayitemsize
- def get_basic_shape(self, is_64_bit=False):
+ def get_basic_shape(self):
# XXX: Should this code even really know about stack frame layout of
# the JIT?
- if is_64_bit:
- return [chr(self.LOC_EBP_PLUS | 8),
- chr(self.LOC_EBP_MINUS | 8),
- chr(self.LOC_EBP_MINUS | 16),
- chr(self.LOC_EBP_MINUS | 24),
- chr(self.LOC_EBP_MINUS | 32),
- chr(self.LOC_EBP_MINUS | 40),
- chr(self.LOC_EBP_PLUS | 0),
+ if self.is_64_bit:
+ return [chr(self.LOC_EBP_PLUS | 4), # return addr: at 8(%rbp)
+ chr(self.LOC_EBP_MINUS | 4), # saved %rbx: at -8(%rbp)
+ chr(self.LOC_EBP_MINUS | 8), # saved %r12: at -16(%rbp)
+ chr(self.LOC_EBP_MINUS | 12), # saved %r13: at -24(%rbp)
+ chr(self.LOC_EBP_MINUS | 16), # saved %r14: at -32(%rbp)
+ chr(self.LOC_EBP_MINUS | 20), # saved %r15: at -40(%rbp)
+ chr(self.LOC_EBP_PLUS | 0), # saved %rbp: at (%rbp)
chr(0)]
else:
return [chr(self.LOC_EBP_PLUS | 4), # return addr: at 4(%ebp)
@@ -366,7 +367,11 @@
shape.append(chr(number | flag))
def add_frame_offset(self, shape, offset):
- assert (offset & 3) == 0
+ if self.is_64_bit:
+ assert (offset & 7) == 0
+ offset >>= 1
+ else:
+ assert (offset & 3) == 0
if offset >= 0:
num = self.LOC_EBP_PLUS | offset
else:
@@ -518,7 +523,7 @@
def initialize(self):
pass
- def get_basic_shape(self, is_64_bit=False):
+ def get_basic_shape(self):
return []
def add_frame_offset(self, shape, offset):
diff --git a/pypy/jit/backend/llsupport/test/test_gc.py b/pypy/jit/backend/llsupport/test/test_gc.py
--- a/pypy/jit/backend/llsupport/test/test_gc.py
+++ b/pypy/jit/backend/llsupport/test/test_gc.py
@@ -57,6 +57,7 @@
def frame_pos(n):
return -4*(4+n)
gcrootmap = GcRootMap_asmgcc()
+ gcrootmap.is_64_bit = False
num1 = frame_pos(-5)
num1a = num1|2
num2 = frame_pos(55)
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
@@ -266,6 +266,38 @@
res = self.cpu.get_latest_value_int(0)
assert res == 20
+ def test_compile_big_bridge_out_of_small_loop(self):
+ i0 = BoxInt()
+ faildescr1 = BasicFailDescr(1)
+ looptoken = JitCellToken()
+ operations = [
+ ResOperation(rop.GUARD_FALSE, [i0], None, descr=faildescr1),
+ ResOperation(rop.FINISH, [], None, descr=BasicFailDescr(2)),
+ ]
+ inputargs = [i0]
+ operations[0].setfailargs([i0])
+ self.cpu.compile_loop(inputargs, operations, looptoken)
+
+ i1list = [BoxInt() for i in range(1000)]
+ bridge = []
+ iprev = i0
+ for i1 in i1list:
+ bridge.append(ResOperation(rop.INT_ADD, [iprev, ConstInt(1)], i1))
+ iprev = i1
+ bridge.append(ResOperation(rop.GUARD_FALSE, [i0], None,
+ descr=BasicFailDescr(3)))
+ bridge.append(ResOperation(rop.FINISH, [], None,
+ descr=BasicFailDescr(4)))
+ bridge[-2].setfailargs(i1list)
+
+ self.cpu.compile_bridge(faildescr1, [i0], bridge, looptoken)
+
+ fail = self.cpu.execute_token(looptoken, 1)
+ assert fail.identifier == 3
+ for i in range(1000):
+ res = self.cpu.get_latest_value_int(i)
+ assert res == 2 + i
+
def test_get_latest_value_count(self):
i0 = BoxInt()
i1 = BoxInt()
diff --git a/pypy/jit/backend/x86/regalloc.py b/pypy/jit/backend/x86/regalloc.py
--- a/pypy/jit/backend/x86/regalloc.py
+++ b/pypy/jit/backend/x86/regalloc.py
@@ -1393,7 +1393,7 @@
self.force_spill_var(op.getarg(0))
def get_mark_gc_roots(self, gcrootmap, use_copy_area=False):
- shape = gcrootmap.get_basic_shape(IS_X86_64)
+ shape = gcrootmap.get_basic_shape()
for v, val in self.fm.bindings.items():
if (isinstance(v, BoxPtr) and self.rm.stays_alive(v)):
assert isinstance(val, StackLoc)
diff --git a/pypy/jit/metainterp/blackhole.py b/pypy/jit/metainterp/blackhole.py
--- a/pypy/jit/metainterp/blackhole.py
+++ b/pypy/jit/metainterp/blackhole.py
@@ -1379,7 +1379,8 @@
elif opnum == rop.GUARD_NO_OVERFLOW:
# Produced by int_xxx_ovf(). The pc is just after the opcode.
# We get here because it did not used to overflow, but now it does.
- return get_llexception(self.cpu, OverflowError())
+ if not dont_change_position:
+ return get_llexception(self.cpu, OverflowError())
#
elif opnum == rop.GUARD_OVERFLOW:
# Produced by int_xxx_ovf(). The pc is just after the opcode.
diff --git a/pypy/jit/metainterp/optimizeopt/__init__.py b/pypy/jit/metainterp/optimizeopt/__init__.py
--- a/pypy/jit/metainterp/optimizeopt/__init__.py
+++ b/pypy/jit/metainterp/optimizeopt/__init__.py
@@ -9,7 +9,7 @@
from pypy.jit.metainterp.optimizeopt.simplify import OptSimplify
from pypy.jit.metainterp.optimizeopt.pure import OptPure
from pypy.jit.metainterp.optimizeopt.earlyforce import OptEarlyForce
-from pypy.rlib.jit import PARAMETERS
+from pypy.rlib.jit import PARAMETERS, ENABLE_ALL_OPTS
from pypy.rlib.unroll import unrolling_iterable
from pypy.rlib.debug import debug_start, debug_stop, debug_print
@@ -30,6 +30,9 @@
ALL_OPTS_LIST = [name for name, _ in ALL_OPTS]
ALL_OPTS_NAMES = ':'.join([name for name, _ in ALL_OPTS])
+assert ENABLE_ALL_OPTS == ALL_OPTS_NAMES, (
+ 'please fix rlib/jit.py to say ENABLE_ALL_OPTS = %r' % (ALL_OPTS_NAMES,))
+
def build_opt_chain(metainterp_sd, enable_opts):
config = metainterp_sd.config
optimizations = []
diff --git a/pypy/jit/metainterp/optimizeopt/unroll.py b/pypy/jit/metainterp/optimizeopt/unroll.py
--- a/pypy/jit/metainterp/optimizeopt/unroll.py
+++ b/pypy/jit/metainterp/optimizeopt/unroll.py
@@ -9,7 +9,6 @@
from pypy.jit.metainterp.inliner import Inliner
from pypy.jit.metainterp.resoperation import rop, ResOperation
from pypy.jit.metainterp.resume import Snapshot
-from pypy.rlib.debug import debug_print
import sys, os
# FIXME: Introduce some VirtualOptimizer super class instead
@@ -121,9 +120,9 @@
limit = self.optimizer.metainterp_sd.warmrunnerdesc.memory_manager.retrace_limit
if cell_token.retraced_count < limit:
cell_token.retraced_count += 1
- debug_print('Retracing (%d/%d)' % (cell_token.retraced_count, limit))
+ #debug_print('Retracing (%d/%d)' % (cell_token.retraced_count, limit))
else:
- debug_print("Retrace count reached, jumping to preamble")
+ #debug_print("Retrace count reached, jumping to preamble")
assert cell_token.target_tokens[0].virtual_state is None
jumpop.setdescr(cell_token.target_tokens[0])
self.optimizer.send_extra_operation(jumpop)
@@ -273,9 +272,9 @@
not newvalue.is_constant():
op = ResOperation(rop.SAME_AS, [op.result], newresult)
self.optimizer._newoperations.append(op)
- if self.optimizer.loop.logops:
- debug_print(' Falling back to add extra: ' +
- self.optimizer.loop.logops.repr_of_resop(op))
+ #if self.optimizer.loop.logops:
+ # debug_print(' Falling back to add extra: ' +
+ # self.optimizer.loop.logops.repr_of_resop(op))
self.optimizer.flush()
self.optimizer.emitting_dissabled = False
@@ -341,8 +340,8 @@
if i == len(newoperations):
while j < len(jumpargs):
a = jumpargs[j]
- if self.optimizer.loop.logops:
- debug_print('J: ' + self.optimizer.loop.logops.repr_of_arg(a))
+ #if self.optimizer.loop.logops:
+ # debug_print('J: ' + self.optimizer.loop.logops.repr_of_arg(a))
self.import_box(a, inputargs, short_jumpargs, jumpargs)
j += 1
else:
@@ -353,11 +352,11 @@
if op.is_guard():
args = args + op.getfailargs()
- if self.optimizer.loop.logops:
- debug_print('OP: ' + self.optimizer.loop.logops.repr_of_resop(op))
+ #if self.optimizer.loop.logops:
+ # debug_print('OP: ' + self.optimizer.loop.logops.repr_of_resop(op))
for a in args:
- if self.optimizer.loop.logops:
- debug_print('A: ' + self.optimizer.loop.logops.repr_of_arg(a))
+ #if self.optimizer.loop.logops:
+ # debug_print('A: ' + self.optimizer.loop.logops.repr_of_arg(a))
self.import_box(a, inputargs, short_jumpargs, jumpargs)
i += 1
newoperations = self.optimizer.get_newoperations()
@@ -370,18 +369,18 @@
# that is compatible with the virtual state at the start of the loop
modifier = VirtualStateAdder(self.optimizer)
final_virtual_state = modifier.get_virtual_state(original_jumpargs)
- debug_start('jit-log-virtualstate')
- virtual_state.debug_print('Closed loop with ')
+ #debug_start('jit-log-virtualstate')
+ #virtual_state.debug_print('Closed loop with ')
bad = {}
if not virtual_state.generalization_of(final_virtual_state, bad):
# We ended up with a virtual state that is not compatible
# and we are thus unable to jump to the start of the loop
- final_virtual_state.debug_print("Bad virtual state at end of loop, ",
- bad)
- debug_stop('jit-log-virtualstate')
+ #final_virtual_state.debug_print("Bad virtual state at end of loop, ",
+ # bad)
+ #debug_stop('jit-log-virtualstate')
raise InvalidLoop
- debug_stop('jit-log-virtualstate')
+ #debug_stop('jit-log-virtualstate')
maxguards = self.optimizer.metainterp_sd.warmrunnerdesc.memory_manager.max_retrace_guards
if self.optimizer.emitted_guards > maxguards:
@@ -444,9 +443,9 @@
self.ensure_short_op_emitted(self.short_boxes.producer(a), optimizer,
seen)
- if self.optimizer.loop.logops:
- debug_print(' Emitting short op: ' +
- self.optimizer.loop.logops.repr_of_resop(op))
+ #if self.optimizer.loop.logops:
+ # debug_print(' Emitting short op: ' +
+ # self.optimizer.loop.logops.repr_of_resop(op))
optimizer.send_extra_operation(op)
seen[op.result] = True
@@ -527,8 +526,8 @@
args = jumpop.getarglist()
modifier = VirtualStateAdder(self.optimizer)
virtual_state = modifier.get_virtual_state(args)
- debug_start('jit-log-virtualstate')
- virtual_state.debug_print("Looking for ")
+ #debug_start('jit-log-virtualstate')
+ #virtual_state.debug_print("Looking for ")
for target in cell_token.target_tokens:
if not target.virtual_state:
@@ -537,10 +536,10 @@
extra_guards = []
bad = {}
- debugmsg = 'Did not match '
+ #debugmsg = 'Did not match '
if target.virtual_state.generalization_of(virtual_state, bad):
ok = True
- debugmsg = 'Matched '
+ #debugmsg = 'Matched '
else:
try:
cpu = self.optimizer.cpu
@@ -549,13 +548,13 @@
extra_guards)
ok = True
- debugmsg = 'Guarded to match '
+ #debugmsg = 'Guarded to match '
except InvalidLoop:
pass
- target.virtual_state.debug_print(debugmsg, bad)
+ #target.virtual_state.debug_print(debugmsg, bad)
if ok:
- debug_stop('jit-log-virtualstate')
+ #debug_stop('jit-log-virtualstate')
values = [self.getvalue(arg)
for arg in jumpop.getarglist()]
@@ -576,13 +575,13 @@
newop = inliner.inline_op(shop)
self.optimizer.send_extra_operation(newop)
except InvalidLoop:
- debug_print("Inlining failed unexpectedly",
- "jumping to preamble instead")
+ #debug_print("Inlining failed unexpectedly",
+ # "jumping to preamble instead")
assert cell_token.target_tokens[0].virtual_state is None
jumpop.setdescr(cell_token.target_tokens[0])
self.optimizer.send_extra_operation(jumpop)
return True
- debug_stop('jit-log-virtualstate')
+ #debug_stop('jit-log-virtualstate')
return False
class ValueImporter(object):
diff --git a/pypy/jit/metainterp/optimizeopt/virtualstate.py b/pypy/jit/metainterp/optimizeopt/virtualstate.py
--- a/pypy/jit/metainterp/optimizeopt/virtualstate.py
+++ b/pypy/jit/metainterp/optimizeopt/virtualstate.py
@@ -681,13 +681,14 @@
self.synthetic[op] = True
def debug_print(self, logops):
- debug_start('jit-short-boxes')
- for box, op in self.short_boxes.items():
- if op:
- debug_print(logops.repr_of_arg(box) + ': ' + logops.repr_of_resop(op))
- else:
- debug_print(logops.repr_of_arg(box) + ': None')
- debug_stop('jit-short-boxes')
+ if 0:
+ debug_start('jit-short-boxes')
+ for box, op in self.short_boxes.items():
+ if op:
+ debug_print(logops.repr_of_arg(box) + ': ' + logops.repr_of_resop(op))
+ else:
+ debug_print(logops.repr_of_arg(box) + ': None')
+ debug_stop('jit-short-boxes')
def operations(self):
if not we_are_translated(): # For tests
diff --git a/pypy/jit/metainterp/pyjitpl.py b/pypy/jit/metainterp/pyjitpl.py
--- a/pypy/jit/metainterp/pyjitpl.py
+++ b/pypy/jit/metainterp/pyjitpl.py
@@ -2064,11 +2064,12 @@
pass # XXX we want to do something special in resume descr,
# but not now
elif opnum == rop.GUARD_NO_OVERFLOW: # an overflow now detected
- self.execute_raised(OverflowError(), constant=True)
- try:
- self.finishframe_exception()
- except ChangeFrame:
- pass
+ if not dont_change_position:
+ self.execute_raised(OverflowError(), constant=True)
+ try:
+ self.finishframe_exception()
+ except ChangeFrame:
+ pass
elif opnum == rop.GUARD_OVERFLOW: # no longer overflowing
self.clear_exception()
else:
diff --git a/pypy/jit/metainterp/test/test_ajit.py b/pypy/jit/metainterp/test/test_ajit.py
--- a/pypy/jit/metainterp/test/test_ajit.py
+++ b/pypy/jit/metainterp/test/test_ajit.py
@@ -288,10 +288,10 @@
if y&4 == 0:
x1, x2 = x2, x1
return res
+ res = self.meta_interp(f, [6, sys.maxint, 32, 48])
+ assert res == f(6, sys.maxint, 32, 48)
res = self.meta_interp(f, [sys.maxint, 6, 32, 48])
assert res == f(sys.maxint, 6, 32, 48)
- res = self.meta_interp(f, [6, sys.maxint, 32, 48])
- assert res == f(6, sys.maxint, 32, 48)
def test_loop_invariant_intbox(self):
diff --git a/pypy/jit/metainterp/test/test_compile.py b/pypy/jit/metainterp/test/test_compile.py
--- a/pypy/jit/metainterp/test/test_compile.py
+++ b/pypy/jit/metainterp/test/test_compile.py
@@ -14,7 +14,7 @@
ts = typesystem.llhelper
def __init__(self):
self.seen = []
- def compile_loop(self, inputargs, operations, token, name=''):
+ def compile_loop(self, inputargs, operations, token, log=True, name=''):
self.seen.append((inputargs, operations, token))
class FakeLogger(object):
diff --git a/pypy/jit/metainterp/warmspot.py b/pypy/jit/metainterp/warmspot.py
--- a/pypy/jit/metainterp/warmspot.py
+++ b/pypy/jit/metainterp/warmspot.py
@@ -100,7 +100,7 @@
if not kwds.get('translate_support_code', False):
warmrunnerdesc.metainterp_sd.profiler.finish()
warmrunnerdesc.metainterp_sd.cpu.finish_once()
- print '~~~ return value:', res
+ print '~~~ return value:', repr(res)
while repeat > 1:
print '~' * 79
res1 = interp.eval_graph(graph, args)
diff --git a/pypy/module/_md5/test/test_md5.py b/pypy/module/_md5/test/test_md5.py
--- a/pypy/module/_md5/test/test_md5.py
+++ b/pypy/module/_md5/test/test_md5.py
@@ -28,7 +28,7 @@
assert self.md5.digest_size == 16
#assert self.md5.digestsize == 16 -- not on CPython
assert self.md5.md5().digest_size == 16
- if sys.version >= (2, 5):
+ if sys.version_info >= (2, 5):
assert self.md5.blocksize == 1
assert self.md5.md5().digestsize == 16
diff --git a/pypy/module/array/interp_array.py b/pypy/module/array/interp_array.py
--- a/pypy/module/array/interp_array.py
+++ b/pypy/module/array/interp_array.py
@@ -11,6 +11,7 @@
from pypy.objspace.std.register_all import register_all
from pypy.rlib.rarithmetic import ovfcheck
from pypy.rlib.unroll import unrolling_iterable
+from pypy.rlib.objectmodel import specialize
from pypy.rpython.lltypesystem import lltype, rffi
@@ -162,13 +163,15 @@
def make_array(mytype):
+ W_ArrayBase = globals()['W_ArrayBase']
+
class W_Array(W_ArrayBase):
itemsize = mytype.bytes
typecode = mytype.typecode
@staticmethod
def register(typeorder):
- typeorder[W_Array] = []
+ typeorder[W_Array] = [(W_ArrayBase, None)]
def __init__(self, space):
self.space = space
@@ -586,13 +589,29 @@
raise OperationError(space.w_ValueError, space.wrap(msg))
# Compare methods
- def cmp__Array_ANY(space, self, other):
- if isinstance(other, W_ArrayBase):
- w_lst1 = array_tolist__Array(space, self)
- w_lst2 = space.call_method(other, 'tolist')
- return space.cmp(w_lst1, w_lst2)
- else:
- return space.w_NotImplemented
+ @specialize.arg(3)
+ def _cmp_impl(space, self, other, space_fn):
+ w_lst1 = array_tolist__Array(space, self)
+ w_lst2 = space.call_method(other, 'tolist')
+ return space_fn(w_lst1, w_lst2)
+
+ def eq__Array_ArrayBase(space, self, other):
+ return _cmp_impl(space, self, other, space.eq)
+
+ def ne__Array_ArrayBase(space, self, other):
+ return _cmp_impl(space, self, other, space.ne)
+
+ def lt__Array_ArrayBase(space, self, other):
+ return _cmp_impl(space, self, other, space.lt)
+
+ def le__Array_ArrayBase(space, self, other):
+ return _cmp_impl(space, self, other, space.le)
+
+ def gt__Array_ArrayBase(space, self, other):
+ return _cmp_impl(space, self, other, space.gt)
+
+ def ge__Array_ArrayBase(space, self, other):
+ return _cmp_impl(space, self, other, space.ge)
# Misc methods
diff --git a/pypy/module/array/test/test_array.py b/pypy/module/array/test/test_array.py
--- a/pypy/module/array/test/test_array.py
+++ b/pypy/module/array/test/test_array.py
@@ -536,12 +536,6 @@
assert (a >= c) is False
assert (c >= a) is True
- assert cmp(a, a) == 0
- assert cmp(a, b) == 0
- assert cmp(a, c) < 0
- assert cmp(b, a) == 0
- assert cmp(c, a) > 0
-
def test_reduce(self):
import pickle
a = self.array('i', [1, 2, 3])
@@ -851,8 +845,11 @@
cls.maxint = sys.maxint
class AppTestArray(BaseArrayTests):
+ OPTIONS = {}
+
def setup_class(cls):
- cls.space = gettestobjspace(usemodules=('array', 'struct', '_rawffi'))
+ cls.space = gettestobjspace(usemodules=('array', 'struct', '_rawffi'),
+ **cls.OPTIONS)
cls.w_array = cls.space.appexec([], """():
import array
return array.array
@@ -874,3 +871,7 @@
a = self.array('b', range(4))
a[::-1] = a
assert a == self.array('b', [3, 2, 1, 0])
+
+
+class AppTestArrayBuiltinShortcut(AppTestArray):
+ OPTIONS = {'objspace.std.builtinshortcut': True}
diff --git a/pypy/rlib/jit.py b/pypy/rlib/jit.py
--- a/pypy/rlib/jit.py
+++ b/pypy/rlib/jit.py
@@ -392,6 +392,9 @@
class JitHintError(Exception):
"""Inconsistency in the JIT hints."""
+ENABLE_ALL_OPTS = (
+ 'intbounds:rewrite:virtualize:string:earlyforce:pure:heap:ffi:unroll')
+
PARAMETER_DOCS = {
'threshold': 'number of times a loop has to run for it to become hot',
'function_threshold': 'number of times a function must run for it to become traced from start',
@@ -402,7 +405,8 @@
'retrace_limit': 'how many times we can try retracing before giving up',
'max_retrace_guards': 'number of extra guards a retrace can cause',
'max_unroll_loops': 'number of extra unrollings a loop can cause',
- 'enable_opts': 'optimizations to enable or all, INTERNAL USE ONLY'
+ 'enable_opts': 'INTERNAL USE ONLY: optimizations to enable, or all = %s' %
+ ENABLE_ALL_OPTS,
}
PARAMETERS = {'threshold': 1039, # just above 1024, prime
diff --git a/pypy/rpython/memory/gctransform/asmgcroot.py b/pypy/rpython/memory/gctransform/asmgcroot.py
--- a/pypy/rpython/memory/gctransform/asmgcroot.py
+++ b/pypy/rpython/memory/gctransform/asmgcroot.py
@@ -442,6 +442,8 @@
ll_assert(location >= 0, "negative location")
kind = location & LOC_MASK
offset = location & ~ LOC_MASK
+ if IS_64_BITS:
+ offset <<= 1
if kind == LOC_REG: # register
if location == LOC_NOWHERE:
return llmemory.NULL
diff --git a/pypy/translator/c/gcc/instruction.py b/pypy/translator/c/gcc/instruction.py
--- a/pypy/translator/c/gcc/instruction.py
+++ b/pypy/translator/c/gcc/instruction.py
@@ -13,13 +13,17 @@
ARGUMENT_REGISTERS_64 = ('%rdi', '%rsi', '%rdx', '%rcx', '%r8', '%r9')
-def frameloc_esp(offset):
+def frameloc_esp(offset, wordsize):
assert offset >= 0
- assert offset % 4 == 0
+ assert offset % wordsize == 0
+ if wordsize == 8: # in this case, there are 3 null bits, but we
+ offset >>= 1 # only need 2 of them
return LOC_ESP_PLUS | offset
-def frameloc_ebp(offset):
- assert offset % 4 == 0
+def frameloc_ebp(offset, wordsize):
+ assert offset % wordsize == 0
+ if wordsize == 8: # in this case, there are 3 null bits, but we
+ offset >>= 1 # only need 2 of them
if offset >= 0:
return LOC_EBP_PLUS | offset
else:
@@ -57,12 +61,12 @@
# try to use esp-relative addressing
ofs_from_esp = framesize + self.ofs_from_frame_end
if ofs_from_esp % 2 == 0:
- return frameloc_esp(ofs_from_esp)
+ return frameloc_esp(ofs_from_esp, wordsize)
# we can get an odd value if the framesize is marked as bogus
# by visit_andl()
assert uses_frame_pointer
ofs_from_ebp = self.ofs_from_frame_end + wordsize
- return frameloc_ebp(ofs_from_ebp)
+ return frameloc_ebp(ofs_from_ebp, wordsize)
class Insn(object):
diff --git a/pypy/translator/c/gcc/trackgcroot.py b/pypy/translator/c/gcc/trackgcroot.py
--- a/pypy/translator/c/gcc/trackgcroot.py
+++ b/pypy/translator/c/gcc/trackgcroot.py
@@ -78,9 +78,9 @@
if self.is_stack_bottom:
retaddr = LOC_NOWHERE # end marker for asmgcroot.py
elif self.uses_frame_pointer:
- retaddr = frameloc_ebp(self.WORD)
+ retaddr = frameloc_ebp(self.WORD, self.WORD)
else:
- retaddr = frameloc_esp(insn.framesize)
+ retaddr = frameloc_esp(insn.framesize, self.WORD)
shape = [retaddr]
# the first gcroots are always the ones corresponding to
# the callee-saved registers
@@ -894,6 +894,8 @@
return '%' + cls.CALLEE_SAVE_REGISTERS[reg].replace("%", "")
else:
offset = loc & ~ LOC_MASK
+ if cls.WORD == 8:
+ offset <<= 1
if kind == LOC_EBP_PLUS:
result = '(%' + cls.EBP.replace("%", "") + ')'
elif kind == LOC_EBP_MINUS:
diff --git a/pypy/translator/goal/app_main.py b/pypy/translator/goal/app_main.py
--- a/pypy/translator/goal/app_main.py
+++ b/pypy/translator/goal/app_main.py
@@ -130,30 +130,46 @@
sys.executable,)
print __doc__.rstrip()
if 'pypyjit' in sys.builtin_module_names:
- _print_jit_help()
+ print " --jit OPTIONS advanced JIT options: try 'off' or 'help'"
print
raise SystemExit
def _print_jit_help():
- import pypyjit
+ try:
+ import pypyjit
+ except ImportError:
+ print >> sys.stderr, "No jit support in %s" % (sys.executable,)
+ return
items = pypyjit.defaults.items()
items.sort()
+ print 'Advanced JIT options: a comma-separated list of OPTION=VALUE:'
for key, value in items:
- prefix = ' --jit %s=N %s' % (key, ' '*(18-len(key)))
+ print
+ print ' %s=N' % (key,)
doc = '%s (default %s)' % (pypyjit.PARAMETER_DOCS[key], value)
- while len(doc) > 51:
- i = doc[:51].rfind(' ')
- print prefix + doc[:i]
+ while len(doc) > 72:
+ i = doc[:74].rfind(' ')
+ if i < 0:
+ i = doc.find(' ')
+ if i < 0:
+ i = len(doc)
+ print ' ' + doc[:i]
doc = doc[i+1:]
- prefix = ' '*len(prefix)
- print prefix + doc
- print ' --jit off turn off the JIT'
+ print ' ' + doc
+ print
+ print ' off'
+ print ' turn off the JIT'
+ print ' help'
+ print ' print this page'
def print_version(*args):
print >> sys.stderr, "Python", sys.version
raise SystemExit
def set_jit_option(options, jitparam, *args):
+ if jitparam == 'help':
+ _print_jit_help()
+ raise SystemExit
if 'pypyjit' not in sys.builtin_module_names:
print >> sys.stderr, ("Warning: No jit support in %s" %
(sys.executable,))
More information about the pypy-commit
mailing list