Author: Maciej Fijalkowski <[email protected]>
Branch: elidable-canfold-exception
Changeset: r70046:83468ba5580d
Date: 2014-03-18 09:48 +0200
http://bitbucket.org/pypy/pypy/changeset/83468ba5580d/
Log: Start a branch to constant-fold some errors in @elidable. Begin with
changing all @elidable to @elidable()
diff --git a/pypy/interpreter/signature.py b/pypy/interpreter/signature.py
--- a/pypy/interpreter/signature.py
+++ b/pypy/interpreter/signature.py
@@ -10,7 +10,7 @@
self.varargname = varargname
self.kwargname = kwargname
- @jit.elidable
+ @jit.elidable()
def find_argname(self, name):
try:
return self.argnames.index(name)
@@ -69,4 +69,4 @@
return self.varargname
if i == 2:
return self.kwargname
- raise IndexError
\ No newline at end of file
+ raise IndexError
diff --git a/pypy/module/_cffi_backend/ctypestruct.py
b/pypy/module/_cffi_backend/ctypestruct.py
--- a/pypy/module/_cffi_backend/ctypestruct.py
+++ b/pypy/module/_cffi_backend/ctypestruct.py
@@ -135,7 +135,7 @@
msg = "list or tuple or dict"
raise self._convert_error(msg, w_ob)
- @jit.elidable
+ @jit.elidable()
def _getcfield_const(self, attr):
return self.fields_dict[attr]
diff --git a/pypy/module/_codecs/interp_codecs.py
b/pypy/module/_codecs/interp_codecs.py
--- a/pypy/module/_codecs/interp_codecs.py
+++ b/pypy/module/_codecs/interp_codecs.py
@@ -100,7 +100,7 @@
def get_codec_from_cache(self, key):
return self._get_codec_with_version(key, self.version)
- @jit.elidable
+ @jit.elidable()
def _get_codec_with_version(self, key, version):
return self.codec_search_cache.get(key, None)
diff --git a/pypy/module/_lsprof/interp_lsprof.py
b/pypy/module/_lsprof/interp_lsprof.py
--- a/pypy/module/_lsprof/interp_lsprof.py
+++ b/pypy/module/_lsprof/interp_lsprof.py
@@ -150,7 +150,7 @@
factor * float(self.ll_it), w_sublist)
return space.wrap(w_se)
- @jit.elidable
+ @jit.elidable()
def _get_or_make_subentry(self, entry, make=True):
try:
return self.calls[entry]
@@ -302,7 +302,7 @@
c_setup_profiling()
space.getexecutioncontext().setllprofile(lsprof_call, space.wrap(self))
- @jit.elidable
+ @jit.elidable()
def _get_or_make_entry(self, f_code, make=True):
try:
return self.data[f_code]
@@ -313,7 +313,7 @@
return entry
raise
- @jit.elidable
+ @jit.elidable()
def _get_or_make_builtin_entry(self, key, make=True):
try:
return self.builtin_data[key]
diff --git a/pypy/module/_rawffi/alt/interp_ffitype.py
b/pypy/module/_rawffi/alt/interp_ffitype.py
--- a/pypy/module/_rawffi/alt/interp_ffitype.py
+++ b/pypy/module/_rawffi/alt/interp_ffitype.py
@@ -17,7 +17,7 @@
self.w_pointer_to = w_pointer_to
self.set_ffitype(ffitype)
- @jit.elidable
+ @jit.elidable()
def get_ffitype(self):
if not self._ffitype:
raise ValueError("Operation not permitted on an incomplete type")
diff --git a/pypy/module/cppyy/capi/loadable_capi.py
b/pypy/module/cppyy/capi/loadable_capi.py
--- a/pypy/module/cppyy/capi/loadable_capi.py
+++ b/pypy/module/cppyy/capi/loadable_capi.py
@@ -342,10 +342,10 @@
return _cdata_to_ptr(space, call_capi(space, 'allocate_function_args',
[_Arg(l=size)]))
def c_deallocate_function_args(space, cargs):
call_capi(space, 'deallocate_function_args', [_Arg(vp=cargs)])
[email protected]
[email protected]()
def c_function_arg_sizeof(space):
return _cdata_to_size_t(space, call_capi(space, 'function_arg_sizeof', []))
[email protected]
[email protected]()
def c_function_arg_typeoffset(space):
return _cdata_to_size_t(space, call_capi(space, 'function_arg_typeoffset',
[]))
diff --git a/pypy/module/imp/importing.py b/pypy/module/imp/importing.py
--- a/pypy/module/imp/importing.py
+++ b/pypy/module/imp/importing.py
@@ -121,7 +121,7 @@
def check_sys_modules_w(space, modulename):
return space.finditem_str(space.sys.get('modules'), modulename)
[email protected]
[email protected]()
def _get_dot_position(str, n):
# return the index in str of the '.' such that there are n '.'-separated
# strings after it
diff --git a/pypy/objspace/std/mapdict.py b/pypy/objspace/std/mapdict.py
--- a/pypy/objspace/std/mapdict.py
+++ b/pypy/objspace/std/mapdict.py
@@ -43,7 +43,7 @@
else:
return obj._mapdict_read_storage(attr.storageindex)
- @jit.elidable
+ @jit.elidable()
def _pure_mapdict_read_storage(self, obj, storageindex):
return obj._mapdict_read_storage(storageindex)
@@ -68,7 +68,7 @@
else:
return self._find_map_attr_indirection(selector)
- @jit.elidable
+ @jit.elidable()
def _find_map_attr_jit_pure(self, name, index):
return self._find_map_attr_indirection((name, index))
@@ -128,14 +128,14 @@
def set_terminator(self, obj, terminator):
raise NotImplementedError("abstract base class")
- @jit.elidable
+ @jit.elidable()
def size_estimate(self):
return self._size_estimate >> NUM_DIGITS
def search(self, attrtype):
return None
- @jit.elidable
+ @jit.elidable()
def _get_new_attr(self, name, index):
selector = name, index
cache = self.cache_attrs
diff --git a/pypy/objspace/std/stringmethods.py
b/pypy/objspace/std/stringmethods.py
--- a/pypy/objspace/std/stringmethods.py
+++ b/pypy/objspace/std/stringmethods.py
@@ -585,7 +585,7 @@
return self
return self._new(self.title(selfval))
- @jit.elidable
+ @jit.elidable()
def title(self, value):
builder = self._builder(len(value))
previous_is_cased = False
diff --git a/pypy/objspace/std/typeobject.py b/pypy/objspace/std/typeobject.py
--- a/pypy/objspace/std/typeobject.py
+++ b/pypy/objspace/std/typeobject.py
@@ -259,7 +259,7 @@
return w_value
return w_value
- @elidable
+ @elidable()
def _pure_getdictvalue_no_unwrapping(w_self, space, version_tag, attr):
return w_self._getdictvalue_no_unwrapping(space, attr)
@@ -371,7 +371,7 @@
w_class, w_value = w_self._pure_lookup_where_with_method_cache(name,
version_tag)
return w_class, unwrap_cell(space, w_value)
- @elidable
+ @elidable()
def _pure_lookup_where_with_method_cache(w_self, name, version_tag):
space = w_self.space
cache = space.fromcache(MethodCache)
diff --git a/rpython/jit/backend/llsupport/test/zrpy_gc_test.py
b/rpython/jit/backend/llsupport/test/zrpy_gc_test.py
--- a/rpython/jit/backend/llsupport/test/zrpy_gc_test.py
+++ b/rpython/jit/backend/llsupport/test/zrpy_gc_test.py
@@ -634,7 +634,7 @@
self.run('compile_framework_external_exception_handling')
def define_compile_framework_bug1(self):
- @elidable
+ @elidable()
def nonmoving():
x = X(1)
for i in range(7):
diff --git a/rpython/jit/codewriter/support.py
b/rpython/jit/codewriter/support.py
--- a/rpython/jit/codewriter/support.py
+++ b/rpython/jit/codewriter/support.py
@@ -216,12 +216,12 @@
_ll_3_list_resize_hint_really = rlist_ll._ll_list_resize_hint_really
-@elidable
+@elidable()
def _ll_1_gc_identityhash(x):
return lltype.identityhash(x)
-# the following function should not be "@elidable": I can think of
+# the following function should not be "@elidable()": I can think of
# a corner case in which id(const) is constant-folded, and then 'const'
# disappears and is collected too early (possibly causing another object
# with the same id() to appear).
diff --git a/rpython/jit/codewriter/test/test_effectinfo.py
b/rpython/jit/codewriter/test/test_effectinfo.py
--- a/rpython/jit/codewriter/test/test_effectinfo.py
+++ b/rpython/jit/codewriter/test/test_effectinfo.py
@@ -122,7 +122,7 @@
class B(A):
x = 2
- @jit.elidable
+ @jit.elidable()
def g(cls):
return cls()
diff --git a/rpython/jit/codewriter/test/test_policy.py
b/rpython/jit/codewriter/test/test_policy.py
--- a/rpython/jit/codewriter/test/test_policy.py
+++ b/rpython/jit/codewriter/test/test_policy.py
@@ -52,7 +52,7 @@
assert not policy.look_inside_graph(graph)
def test_elidable():
- @jit.elidable
+ @jit.elidable()
def g(x):
return x + 2
graph = support.getgraph(g, [5])
diff --git a/rpython/jit/metainterp/test/test_ajit.py
b/rpython/jit/metainterp/test/test_ajit.py
--- a/rpython/jit/metainterp/test/test_ajit.py
+++ b/rpython/jit/metainterp/test/test_ajit.py
@@ -413,7 +413,7 @@
call=0, call_pure=0)
def test_residual_call_elidable_1(self):
- @elidable
+ @elidable()
def externfn(x, y):
return x * y
def f(n):
@@ -426,7 +426,7 @@
def test_residual_call_elidable_2(self):
myjitdriver = JitDriver(greens = [], reds = ['n'])
- @elidable
+ @elidable()
def externfn(x):
return x - 1
def f(n):
@@ -443,7 +443,7 @@
def test_constfold_call_elidable(self):
myjitdriver = JitDriver(greens = ['m'], reds = ['n'])
- @elidable
+ @elidable()
def externfn(x):
return x - 3
def f(n, m):
@@ -459,7 +459,7 @@
def test_constfold_call_elidable_2(self):
myjitdriver = JitDriver(greens = ['m'], reds = ['n'])
- @elidable
+ @elidable()
def externfn(x):
return x - 3
class V:
@@ -484,7 +484,7 @@
self.x = x
v1 = V(1)
v2 = V(2)
- @elidable
+ @elidable()
def externfn(x):
if x:
return v1
@@ -504,7 +504,7 @@
def test_elidable_raising(self):
myjitdriver = JitDriver(greens = ['m'], reds = ['n'])
- @elidable
+ @elidable()
def externfn(x):
if x <= 0:
raise ValueError
@@ -530,7 +530,7 @@
def test_elidable_raising_2(self):
myjitdriver = JitDriver(greens = ['m'], reds = ['n'])
- @elidable
+ @elidable()
def externfn(x):
if x <= 0:
raise ValueError
diff --git a/rpython/jit/metainterp/test/test_call.py
b/rpython/jit/metainterp/test/test_call.py
--- a/rpython/jit/metainterp/test/test_call.py
+++ b/rpython/jit/metainterp/test/test_call.py
@@ -28,7 +28,7 @@
def test_call_elidable_none(self):
d = {}
- @jit.elidable
+ @jit.elidable()
def f(a):
return d.get(a, None)
diff --git a/rpython/jit/metainterp/test/test_jitprof.py
b/rpython/jit/metainterp/test/test_jitprof.py
--- a/rpython/jit/metainterp/test/test_jitprof.py
+++ b/rpython/jit/metainterp/test/test_jitprof.py
@@ -77,7 +77,7 @@
assert profiler.calls == 1
def test_blackhole_pure(self):
- @elidable
+ @elidable()
def g(n):
return n+1
diff --git a/rpython/jit/metainterp/test/test_send.py
b/rpython/jit/metainterp/test/test_send.py
--- a/rpython/jit/metainterp/test/test_send.py
+++ b/rpython/jit/metainterp/test/test_send.py
@@ -596,7 +596,7 @@
def test_constfold_pure_oosend(self):
myjitdriver = JitDriver(greens=[], reds = ['i', 'obj'])
class A:
- @elidable
+ @elidable()
def foo(self):
return 42
def fn(n, i):
diff --git a/rpython/jit/metainterp/test/test_tracingopts.py
b/rpython/jit/metainterp/test/test_tracingopts.py
--- a/rpython/jit/metainterp/test/test_tracingopts.py
+++ b/rpython/jit/metainterp/test/test_tracingopts.py
@@ -411,7 +411,7 @@
a1.y = 6
a2 = A()
a2.y = 13
- @jit.elidable
+ @jit.elidable()
def f(b):
return b + 1
def fn(n):
diff --git a/rpython/jit/tl/tlc.py b/rpython/jit/tl/tlc.py
--- a/rpython/jit/tl/tlc.py
+++ b/rpython/jit/tl/tlc.py
@@ -72,7 +72,7 @@
classes = [] # [(descr, cls), ...]
- @elidable
+ @elidable()
def get(key):
for descr, cls in Class.classes:
if key.attributes == descr.attributes and\
diff --git a/rpython/rlib/jit.py b/rpython/rlib/jit.py
--- a/rpython/rlib/jit.py
+++ b/rpython/rlib/jit.py
@@ -1,4 +1,5 @@
import sys
+import types
import py
@@ -11,7 +12,7 @@
DEBUG_ELIDABLE_FUNCTIONS = False
-def elidable(func):
+def elidable(canfolderror=None):
""" Decorate a function as "trace-elidable". Usually this means simply that
the function is constant-foldable, i.e. is pure and has no side-effects.
@@ -31,22 +32,31 @@
Most importantly it doesn't mean that an elidable function has no
observable
side effect, but those side effects are idempotent (ie caching).
If a particular call to this function ends up raising an exception, then it
- is handled like a normal function call (this decorator is ignored).
+ is handled like a normal function call (this decorator is ignored), unless
+ canfolderror is specified (which is an exception class or a tuple).
+ In this case, if it raises specific exception listed there, it's also
+ constant folded away.
"""
- if DEBUG_ELIDABLE_FUNCTIONS:
- cache = {}
- oldfunc = func
- def func(*args):
- result = oldfunc(*args) # if it raises, no caching
- try:
- oldresult = cache.setdefault(args, result)
- except TypeError:
- pass # unhashable args
- else:
- assert oldresult == result
- return result
- func._elidable_function_ = True
- return func
+ if isinstance(canfolderror, types.FunctionType):
+ raise Exception("@elidable was changed to a full "
+ "decorator, use @elidable()")
+ def decorator(func):
+ if DEBUG_ELIDABLE_FUNCTIONS:
+ cache = {}
+ oldfunc = func
+ def func(*args):
+ result = oldfunc(*args) # if it raises, no caching
+ try:
+ oldresult = cache.setdefault(args, result)
+ except TypeError:
+ pass # unhashable args
+ else:
+ assert oldresult == result
+ return result
+ func._elidable_function_ = True
+ if canfolderror is not None:
+ func._elidable_exceptions_ = canfolderror
+ return func
def purefunction(*args, **kwargs):
import warnings
diff --git a/rpython/rlib/jit_libffi.py b/rpython/rlib/jit_libffi.py
--- a/rpython/rlib/jit_libffi.py
+++ b/rpython/rlib/jit_libffi.py
@@ -245,7 +245,7 @@
del cls._import
@staticmethod
- @jit.elidable
+ @jit.elidable()
def getkind(ffi_type):
"""Returns 'v' for void, 'f' for float, 'i' for signed integer,
'u' for unsigned integer, 'S' for singlefloat, 'L' for long long
@@ -281,7 +281,7 @@
return '?'
@staticmethod
- @jit.elidable
+ @jit.elidable()
def is_struct(ffi_type):
return rffi.getintfield(ffi_type, 'c_type') == FFI_TYPE_STRUCT
diff --git a/rpython/rlib/libffi.py b/rpython/rlib/libffi.py
--- a/rpython/rlib/libffi.py
+++ b/rpython/rlib/libffi.py
@@ -45,7 +45,7 @@
del cls._import
@staticmethod
- @jit.elidable
+ @jit.elidable()
def getkind(ffi_type):
"""Returns 'v' for void, 'f' for float, 'i' for signed integer,
and 'u' for unsigned integer.
@@ -79,7 +79,7 @@
raise KeyError
@staticmethod
- @jit.elidable
+ @jit.elidable()
def is_struct(ffi_type):
return intmask(ffi_type.c_type) == FFI_TYPE_STRUCT
diff --git a/rpython/rlib/rbigint.py b/rpython/rlib/rbigint.py
--- a/rpython/rlib/rbigint.py
+++ b/rpython/rlib/rbigint.py
@@ -169,7 +169,7 @@
numdigits._always_inline_ = True
@staticmethod
- @jit.elidable
+ @jit.elidable()
def fromint(intval):
# This function is marked as pure, so you must not call it and
# then modify the result.
@@ -192,7 +192,7 @@
return rbigint([_store_digit(ival & MASK)], sign, 1)
@staticmethod
- @jit.elidable
+ @jit.elidable()
def frombool(b):
# You must not call this function and then modify the result.
if b:
@@ -205,7 +205,7 @@
return rbigint(*args_from_long(l))
@staticmethod
- @jit.elidable
+ @jit.elidable()
def fromfloat(dval):
""" Create a new bigint object from a float """
# This function is not marked as pure because it can raise
@@ -216,7 +216,7 @@
return rbigint._fromfloat_finite(dval)
@staticmethod
- @jit.elidable
+ @jit.elidable()
def _fromfloat_finite(dval):
sign = 1
if dval < 0.0:
@@ -238,7 +238,7 @@
return v
@staticmethod
- @jit.elidable
+ @jit.elidable()
@specialize.argtype(0)
def fromrarith_int(i):
# This function is marked as pure, so you must not call it and
@@ -246,14 +246,14 @@
return rbigint(*args_from_rarith_int(i))
@staticmethod
- @jit.elidable
+ @jit.elidable()
def fromdecimalstr(s):
# This function is marked as elidable, so you must not call it and
# then modify the result.
return _decimalstr_to_bigint(s)
@staticmethod
- @jit.elidable
+ @jit.elidable()
def fromstr(s, base=0):
"""As string_to_int(), but ignores an optional 'l' or 'L' suffix
and returns an rbigint."""
@@ -271,7 +271,7 @@
return parse_digit_string(parser)
@staticmethod
- @jit.elidable
+ @jit.elidable()
def frombytes(s, byteorder, signed):
if byteorder not in ('big', 'little'):
raise InvalidEndiannessError()
@@ -311,7 +311,7 @@
result._normalize()
return result
- @jit.elidable
+ @jit.elidable()
def tobytes(self, nbytes, byteorder, signed):
if byteorder not in ('big', 'little'):
raise InvalidEndiannessError()
@@ -384,7 +384,7 @@
digits = ''.join([digits[i] for i in range(length-1, -1, -1)])
return digits
- @jit.elidable
+ @jit.elidable()
def toint(self):
"""
Get an integer from a bigint object.
@@ -400,7 +400,7 @@
raise OverflowError
return intmask(intmask(x) * sign)
- @jit.elidable
+ @jit.elidable()
def tolonglong(self):
return _AsLongLong(self)
@@ -408,13 +408,13 @@
def tobool(self):
return self.sign != 0
- @jit.elidable
+ @jit.elidable()
def touint(self):
if self.sign == -1:
raise ValueError("cannot convert negative integer to unsigned int")
return self._touint_helper()
- @jit.elidable
+ @jit.elidable()
def _touint_helper(self):
x = r_uint(0)
i = self.numdigits() - 1
@@ -427,32 +427,32 @@
i -= 1
return x
- @jit.elidable
+ @jit.elidable()
def toulonglong(self):
if self.sign == -1:
raise ValueError("cannot convert negative integer to unsigned int")
return _AsULonglong_ignore_sign(self)
- @jit.elidable
+ @jit.elidable()
def uintmask(self):
return _AsUInt_mask(self)
- @jit.elidable
+ @jit.elidable()
def ulonglongmask(self):
"""Return r_ulonglong(self), truncating."""
return _AsULonglong_mask(self)
- @jit.elidable
+ @jit.elidable()
def tofloat(self):
return _AsDouble(self)
- @jit.elidable
+ @jit.elidable()
def format(self, digits, prefix='', suffix=''):
# 'digits' is a string whose length is the base to use,
# and where each character is the corresponding digit.
return _format(self, digits, prefix, suffix)
- @jit.elidable
+ @jit.elidable()
def repr(self):
try:
x = self.toint()
@@ -460,7 +460,7 @@
return self.format(BASE10, suffix="L")
return str(x) + "L"
- @jit.elidable
+ @jit.elidable()
def str(self):
try:
x = self.toint()
@@ -468,7 +468,7 @@
return self.format(BASE10)
return str(x)
- @jit.elidable
+ @jit.elidable()
def eq(self, other):
if (self.sign != other.sign or
self.numdigits() != other.numdigits()):
@@ -486,7 +486,7 @@
def ne(self, other):
return not self.eq(other)
- @jit.elidable
+ @jit.elidable()
def lt(self, other):
if self.sign > other.sign:
return False
@@ -533,11 +533,11 @@
def ge(self, other):
return not self.lt(other)
- @jit.elidable
+ @jit.elidable()
def hash(self):
return _hash(self)
- @jit.elidable
+ @jit.elidable()
def add(self, other):
if self.sign == 0:
return other
@@ -550,7 +550,7 @@
result.sign *= other.sign
return result
- @jit.elidable
+ @jit.elidable()
def sub(self, other):
if other.sign == 0:
return self
@@ -563,7 +563,7 @@
result.sign *= self.sign
return result
- @jit.elidable
+ @jit.elidable()
def mul(self, b):
asize = self.numdigits()
bsize = b.numdigits()
@@ -608,12 +608,12 @@
result.sign = a.sign * b.sign
return result
- @jit.elidable
+ @jit.elidable()
def truediv(self, other):
div = _bigint_true_divide(self, other)
return div
- @jit.elidable
+ @jit.elidable()
def floordiv(self, other):
if self.sign == 1 and other.numdigits() == 1 and other.sign == 1:
digit = other.digit(0)
@@ -634,7 +634,7 @@
def div(self, other):
return self.floordiv(other)
- @jit.elidable
+ @jit.elidable()
def mod(self, other):
if self.sign == 0:
return NULLRBIGINT
@@ -671,7 +671,7 @@
mod = mod.add(other)
return mod
- @jit.elidable
+ @jit.elidable()
def divmod(v, w):
"""
The / and % operators are now defined in terms of divmod().
@@ -697,7 +697,7 @@
div = div.sub(ONERBIGINT)
return div, mod
- @jit.elidable
+ @jit.elidable()
def pow(a, b, c=None):
negativeOutput = False # if x<0 return negative output
@@ -837,17 +837,17 @@
z = z.sub(c)
return z
- @jit.elidable
+ @jit.elidable()
def neg(self):
return rbigint(self._digits, -self.sign, self.size)
- @jit.elidable
+ @jit.elidable()
def abs(self):
if self.sign != -1:
return self
return rbigint(self._digits, 1, self.size)
- @jit.elidable
+ @jit.elidable()
def invert(self): #Implement ~x as -(x + 1)
if self.sign == 0:
return ONENEGATIVERBIGINT
@@ -856,7 +856,7 @@
ret.sign = -ret.sign
return ret
- @jit.elidable
+ @jit.elidable()
def lshift(self, int_other):
if int_other < 0:
raise ValueError("negative shift count")
@@ -893,7 +893,7 @@
return z
lshift._always_inline_ = True # It's so fast that it's always benefitial.
- @jit.elidable
+ @jit.elidable()
def lqshift(self, int_other):
" A quicker one with much less checks, int_other is valid and for the
most part constant."
assert int_other > 0
@@ -913,7 +913,7 @@
return z
lqshift._always_inline_ = True # It's so fast that it's always benefitial.
- @jit.elidable
+ @jit.elidable()
def rshift(self, int_other, dont_invert=False):
if int_other < 0:
raise ValueError("negative shift count")
@@ -943,7 +943,7 @@
return z
rshift._always_inline_ = 'try' # It's so fast that it's always benefitial.
- @jit.elidable
+ @jit.elidable()
def abs_rshift_and_mask(self, bigshiftcount, mask):
assert isinstance(bigshiftcount, r_ulonglong)
assert mask >= 0
@@ -992,30 +992,30 @@
z._normalize()
return z
- @jit.elidable
+ @jit.elidable()
def and_(self, other):
return _bitwise(self, '&', other)
- @jit.elidable
+ @jit.elidable()
def xor(self, other):
return _bitwise(self, '^', other)
- @jit.elidable
+ @jit.elidable()
def or_(self, other):
return _bitwise(self, '|', other)
- @jit.elidable
+ @jit.elidable()
def oct(self):
if self.sign == 0:
return '0L'
else:
return _format(self, BASE8, '0', 'L')
- @jit.elidable
+ @jit.elidable()
def hex(self):
return _format(self, BASE16, '0x', 'L')
- @jit.elidable
+ @jit.elidable()
def log(self, base):
# base is supposed to be positive or 0.0, which means we use e
if base == 10.0:
@@ -1050,7 +1050,7 @@
_normalize._always_inline_ = True
- @jit.elidable
+ @jit.elidable()
def bit_length(self):
i = self.numdigits()
if i == 1 and self._digits[0] == NULLDIGIT:
diff --git a/rpython/rlib/rstring.py b/rpython/rlib/rstring.py
--- a/rpython/rlib/rstring.py
+++ b/rpython/rlib/rstring.py
@@ -160,7 +160,7 @@
@specialize.argtype(0)
[email protected]
[email protected]()
def replace(input, sub, by, maxsplit=-1):
if isinstance(input, str):
assert isinstance(sub, str)
@@ -236,7 +236,7 @@
return start, end
@specialize.argtype(0)
[email protected]
[email protected]()
def startswith(u_self, prefix, start=0, end=sys.maxint):
length = len(u_self)
start, end = _normalize_start_end(length, start, end)
@@ -249,7 +249,7 @@
return True
@specialize.argtype(0)
[email protected]
[email protected]()
def endswith(u_self, suffix, start=0, end=sys.maxint):
length = len(u_self)
start, end = _normalize_start_end(length, start, end)
diff --git a/rpython/rtyper/lltypesystem/ll_str.py
b/rpython/rtyper/lltypesystem/ll_str.py
--- a/rpython/rtyper/lltypesystem/ll_str.py
+++ b/rpython/rtyper/lltypesystem/ll_str.py
@@ -10,7 +10,7 @@
else:
return r_uint(i)
[email protected]
[email protected]()
def ll_int2dec(val):
from rpython.rtyper.lltypesystem.rstr import mallocstr
@@ -44,7 +44,7 @@
for i in range(16):
hex_chars[i] = "%x" % i
[email protected]
[email protected]()
def ll_int2hex(i, addPrefix):
from rpython.rtyper.lltypesystem.rstr import mallocstr
temp = malloc(CHAR_ARRAY, 20)
@@ -81,7 +81,7 @@
j += 1
return result
[email protected]
[email protected]()
def ll_int2oct(i, addPrefix):
from rpython.rtyper.lltypesystem.rstr import mallocstr
if i == 0:
diff --git a/rpython/rtyper/lltypesystem/module/ll_math.py
b/rpython/rtyper/lltypesystem/module/ll_math.py
--- a/rpython/rtyper/lltypesystem/module/ll_math.py
+++ b/rpython/rtyper/lltypesystem/module/ll_math.py
@@ -71,7 +71,7 @@
math_sin = llexternal('sin', [rffi.DOUBLE], rffi.DOUBLE,
elidable_function=True)
math_cos = llexternal('cos', [rffi.DOUBLE], rffi.DOUBLE,
elidable_function=True)
[email protected]
[email protected]()
def sqrt_nonneg(x):
return math_sqrt(x)
sqrt_nonneg.oopspec = "math.sqrt_nonneg(x)"
diff --git a/rpython/rtyper/lltypesystem/rstr.py
b/rpython/rtyper/lltypesystem/rstr.py
--- a/rpython/rtyper/lltypesystem/rstr.py
+++ b/rpython/rtyper/lltypesystem/rstr.py
@@ -199,7 +199,7 @@
self.ll = LLHelpers
self.malloc = mallocunicode
- @jit.elidable
+ @jit.elidable()
def ll_str(self, s):
# XXX crazy that this is here, but I don't want to break
# rmodel logic
@@ -214,14 +214,14 @@
result.chars[i] = cast_primitive(Char, c)
return result
- @jit.elidable
+ @jit.elidable()
def ll_unicode(self, s):
if s:
return s
else:
return self.ll.ll_constant_unicode(u'None')
- @jit.elidable
+ @jit.elidable()
def ll_encode_latin1(self, s):
length = len(s.chars)
result = mallocstr(length)
@@ -266,7 +266,7 @@
class LLHelpers(AbstractLLHelpers):
from rpython.rtyper.annlowlevel import llstr, llunicode
- @jit.elidable
+ @jit.elidable()
def ll_str_mul(s, times):
if times < 0:
times = 0
@@ -288,7 +288,7 @@
i += j
return newstr
- @jit.elidable
+ @jit.elidable()
def ll_char_mul(ch, times):
if typeOf(ch) is Char:
malloc = mallocstr
@@ -343,7 +343,7 @@
b.chars[i] = str.chars[i]
return b
- @jit.elidable
+ @jit.elidable()
def ll_strhash(s):
# unlike CPython, there is no reason to avoid to return -1
# but our malloc initializes the memory to zero, so we use zero as the
@@ -364,7 +364,7 @@
def ll_strfasthash(s):
return s.hash # assumes that the hash is already computed
- @jit.elidable
+ @jit.elidable()
def ll_strconcat(s1, s2):
len1 = s1.length()
len2 = s2.length()
@@ -384,7 +384,7 @@
return newstr
ll_strconcat.oopspec = 'stroruni.concat(s1, s2)'
- @jit.elidable
+ @jit.elidable()
def ll_strip(s, ch, left, right):
s_len = len(s.chars)
if s_len == 0:
@@ -404,7 +404,7 @@
s.copy_contents(s, result, lpos, 0, r_len)
return result
- @jit.elidable
+ @jit.elidable()
def ll_strip_default(s, left, right):
s_len = len(s.chars)
if s_len == 0:
@@ -424,7 +424,7 @@
s.copy_contents(s, result, lpos, 0, r_len)
return result
- @jit.elidable
+ @jit.elidable()
def ll_strip_multiple(s, s2, left, right):
s_len = len(s.chars)
if s_len == 0:
@@ -444,7 +444,7 @@
s.copy_contents(s, result, lpos, 0, r_len)
return result
- @jit.elidable
+ @jit.elidable()
def ll_upper(s):
s_chars = s.chars
s_len = len(s_chars)
@@ -458,7 +458,7 @@
i += 1
return result
- @jit.elidable
+ @jit.elidable()
def ll_lower(s):
s_chars = s.chars
s_len = len(s_chars)
@@ -505,7 +505,7 @@
i += 1
return result
- @jit.elidable
+ @jit.elidable()
def ll_strcmp(s1, s2):
if not s1 and not s2:
return True
@@ -528,7 +528,7 @@
i += 1
return len1 - len2
- @jit.elidable
+ @jit.elidable()
def ll_streq(s1, s2):
if s1 == s2: # also if both are NULLs
return True
@@ -548,7 +548,7 @@
return True
ll_streq.oopspec = 'stroruni.equal(s1, s2)'
- @jit.elidable
+ @jit.elidable()
def ll_startswith(s1, s2):
len1 = len(s1.chars)
len2 = len(s2.chars)
@@ -569,7 +569,7 @@
return False
return s.chars[0] == ch
- @jit.elidable
+ @jit.elidable()
def ll_endswith(s1, s2):
len1 = len(s1.chars)
len2 = len(s2.chars)
@@ -591,7 +591,7 @@
return False
return s.chars[len(s.chars) - 1] == ch
- @jit.elidable
+ @jit.elidable()
@signature(types.any(), types.any(), types.int(), types.int(),
returns=types.int())
def ll_find_char(s, ch, start, end):
i = start
@@ -603,7 +603,7 @@
i += 1
return -1
- @jit.elidable
+ @jit.elidable()
def ll_rfind_char(s, ch, start, end):
if end > len(s.chars):
end = len(s.chars)
@@ -614,7 +614,7 @@
return i
return -1
- @jit.elidable
+ @jit.elidable()
def ll_count_char(s, ch, start, end):
count = 0
i = start
@@ -676,7 +676,7 @@
res = 0
return res
- @jit.elidable
+ @jit.elidable()
def ll_search(s1, s2, start, end, mode):
count = 0
n = end - start
@@ -818,7 +818,7 @@
@jit.oopspec('stroruni.slice(s1, start, stop)')
@signature(types.any(), types.int(), types.int(), returns=types.any())
- @jit.elidable
+ @jit.elidable()
def _ll_stringslice(s1, start, stop):
lgt = stop - start
assert start >= 0
@@ -980,7 +980,7 @@
item.copy_contents(s, item, 0, 0, prev_pos)
return res
- @jit.elidable
+ @jit.elidable()
def ll_replace_chr_chr(s, c1, c2):
length = len(s.chars)
newstr = s.malloc(length)
@@ -995,7 +995,7 @@
j += 1
return newstr
- @jit.elidable
+ @jit.elidable()
def ll_contains(s, c):
chars = s.chars
strlen = len(chars)
@@ -1006,7 +1006,7 @@
i += 1
return False
- @jit.elidable
+ @jit.elidable()
def ll_int(s, base):
if not 2 <= base <= 36:
raise ValueError
diff --git a/rpython/rtyper/rfloat.py b/rpython/rtyper/rfloat.py
--- a/rpython/rtyper/rfloat.py
+++ b/rpython/rtyper/rfloat.py
@@ -136,7 +136,7 @@
hop.exception_cannot_occur()
return vlist[0]
- @jit.elidable
+ @jit.elidable()
def ll_str(self, f):
return llstr(formatd(f, 'f', 6))
diff --git a/rpython/rtyper/rint.py b/rpython/rtyper/rint.py
--- a/rpython/rtyper/rint.py
+++ b/rpython/rtyper/rint.py
@@ -366,7 +366,7 @@
hop.exception_cannot_occur()
return vlist[0]
- @jit.elidable
+ @jit.elidable()
def ll_str(self, i):
from rpython.rtyper.lltypesystem.ll_str import ll_int2dec
return ll_int2dec(i)
diff --git a/rpython/rtyper/rstr.py b/rpython/rtyper/rstr.py
--- a/rpython/rtyper/rstr.py
+++ b/rpython/rtyper/rstr.py
@@ -20,7 +20,7 @@
self.rstr_decode_utf_8 = func_with_new_name(str_decode_utf_8_impl,
'rstr_decode_utf_8_impl')
- @jit.elidable
+ @jit.elidable()
def ll_decode_utf8(self, llvalue):
from rpython.rtyper.annlowlevel import hlstr
value = hlstr(llvalue)
@@ -70,7 +70,7 @@
def rtype_method_lower(self, hop):
raise TypeError("Cannot do tolower on unicode string")
- @jit.elidable
+ @jit.elidable()
def ll_encode_utf8(self, ll_s):
from rpython.rtyper.annlowlevel import hlunicode
s = hlunicode(ll_s)
diff --git a/rpython/tool/error.py b/rpython/tool/error.py
--- a/rpython/tool/error.py
+++ b/rpython/tool/error.py
@@ -160,7 +160,7 @@
pdb_plus_show.start(tb)
[email protected]
[email protected]()
def offset2lineno(c, stopat):
tab = c.co_lnotab
line = c.co_firstlineno
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit