[pypy-svn] r79499 - in pypy/trunk/pypy: jit/metainterp rlib rpython/test
arigo at codespeak.net
arigo at codespeak.net
Thu Nov 25 10:45:24 CET 2010
Author: arigo
Date: Thu Nov 25 10:45:18 2010
New Revision: 79499
Modified:
pypy/trunk/pypy/jit/metainterp/history.py
pypy/trunk/pypy/jit/metainterp/memmgr.py
pypy/trunk/pypy/rlib/rarithmetic.py
pypy/trunk/pypy/rpython/test/test_rint.py
Log:
Fix on 64-bits: move 'r_int64' to the general rarithmetic module and use it.
The issue is that r_longlong is r_int on 64-bits, and using r_int explicitly
is not well supported by the llinterp.
Modified: pypy/trunk/pypy/jit/metainterp/history.py
==============================================================================
--- pypy/trunk/pypy/jit/metainterp/history.py (original)
+++ pypy/trunk/pypy/jit/metainterp/history.py Thu Nov 25 10:45:18 2010
@@ -4,7 +4,7 @@
from pypy.rpython.ootypesystem import ootype
from pypy.rlib.objectmodel import we_are_translated, r_dict, Symbolic
from pypy.rlib.objectmodel import compute_hash, compute_unique_id
-from pypy.rlib.rarithmetic import intmask, r_longlong
+from pypy.rlib.rarithmetic import intmask, r_int64
from pypy.tool.uid import uid
from pypy.conftest import option
@@ -731,7 +731,7 @@
# specnodes = ...
# and more data specified by the backend when the loop is compiled
number = -1
- generation = r_longlong(0)
+ generation = r_int64(0)
# one purpose of LoopToken is to keep alive the CompiledLoopToken
# returned by the backend. When the LoopToken goes away, the
# CompiledLoopToken has its __del__ called, which frees the assembler
Modified: pypy/trunk/pypy/jit/metainterp/memmgr.py
==============================================================================
--- pypy/trunk/pypy/jit/metainterp/memmgr.py (original)
+++ pypy/trunk/pypy/jit/metainterp/memmgr.py Thu Nov 25 10:45:18 2010
@@ -1,5 +1,5 @@
import math
-from pypy.rlib.rarithmetic import r_longlong
+from pypy.rlib.rarithmetic import r_int64
from pypy.rlib.debug import debug_start, debug_print, debug_stop
from pypy.rlib.objectmodel import we_are_translated
@@ -24,7 +24,7 @@
def __init__(self):
self.check_frequency = -1
- # NB. use of r_longlong to be extremely far on the safe side:
+ # NB. use of r_int64 to be extremely far on the safe side:
# this is increasing by one after each loop or bridge is
# compiled, and it must not overflow. If the backend implements
# complete freeing in cpu.free_loop_and_bridges(), then it may
@@ -32,13 +32,13 @@
# enough. But in this day and age, you'd still never have the
# patience of waiting for a slowly-increasing 64-bit number to
# overflow :-)
- self.current_generation = r_longlong(1)
- self.next_check = r_longlong(-1)
+ self.current_generation = r_int64(1)
+ self.next_check = r_int64(-1)
self.alive_loops = {}
def set_max_age(self, max_age, check_frequency=0):
if max_age <= 0:
- self.next_check = r_longlong(-1)
+ self.next_check = r_int64(-1)
else:
self.max_age = max_age
if check_frequency <= 0:
Modified: pypy/trunk/pypy/rlib/rarithmetic.py
==============================================================================
--- pypy/trunk/pypy/rlib/rarithmetic.py (original)
+++ pypy/trunk/pypy/rlib/rarithmetic.py Thu Nov 25 10:45:18 2010
@@ -389,6 +389,11 @@
r_longlong = build_int('r_longlong', True, 64)
r_ulonglong = build_int('r_ulonglong', False, 64)
+if r_longlong is not r_int:
+ r_int64 = r_longlong
+else:
+ r_int64 = int
+
# float as string -> sign, beforept, afterpt, exponent
Modified: pypy/trunk/pypy/rpython/test/test_rint.py
==============================================================================
--- pypy/trunk/pypy/rpython/test/test_rint.py (original)
+++ pypy/trunk/pypy/rpython/test/test_rint.py Thu Nov 25 10:45:18 2010
@@ -4,14 +4,9 @@
from pypy.annotation import model as annmodel
from pypy.rpython.test import snippet
from pypy.rlib.rarithmetic import r_int, r_uint, r_longlong, r_ulonglong
-from pypy.rlib.rarithmetic import ovfcheck
+from pypy.rlib.rarithmetic import ovfcheck, r_int64
from pypy.rpython.test.tool import BaseRtypingTest, LLRtypeMixin, OORtypeMixin
-if r_longlong is not r_int:
- int64 = r_longlong
-else:
- int64 = int
-
class TestSnippet(object):
@@ -110,10 +105,10 @@
def f(i):
return str(i)
- res = self.interpret(f, [int64(0)])
+ res = self.interpret(f, [r_int64(0)])
assert self.ll_to_string(res) == '0'
- res = self.interpret(f, [int64(413974738222117)])
+ res = self.interpret(f, [r_int64(413974738222117)])
assert self.ll_to_string(res) == '413974738222117'
def test_unsigned(self):
@@ -135,7 +130,7 @@
f._annspecialcase_ = "specialize:argtype(0)"
def g(n):
if n > 0:
- return f(int64(0))
+ return f(r_int64(0))
else:
return f(0)
res = self.interpret(g, [0])
@@ -147,7 +142,7 @@
def test_downcast_int(self):
def f(i):
return int(i)
- res = self.interpret(f, [int64(0)])
+ res = self.interpret(f, [r_int64(0)])
assert res == 0
def test_isinstance_vs_int_types(self):
@@ -157,7 +152,7 @@
return [None]
if isinstance(x, str):
return x
- if isinstance(x, int64):
+ if isinstance(x, r_int64):
return int(x)
return "XXX"
wrap._annspecialcase_ = 'specialize:argtype(0)'
@@ -165,7 +160,7 @@
space = FakeSpace()
def wrap(x):
return space.wrap(x)
- res = self.interpret(wrap, [int64(0)])
+ res = self.interpret(wrap, [r_int64(0)])
assert res == 0
def test_truediv(self):
@@ -178,25 +173,25 @@
def test_float_conversion(self):
def f(ii):
return float(ii)
- res = self.interpret(f, [int64(100000000)])
+ res = self.interpret(f, [r_int64(100000000)])
assert type(res) is float
assert res == 100000000.
- res = self.interpret(f, [int64(1234567890123456789)])
+ res = self.interpret(f, [r_int64(1234567890123456789)])
assert type(res) is float
assert self.float_eq(res, 1.2345678901234568e+18)
def test_float_conversion_implicit(self):
def f(ii):
return 1.0 + ii
- res = self.interpret(f, [int64(100000000)])
+ res = self.interpret(f, [r_int64(100000000)])
assert type(res) is float
assert res == 100000001.
- res = self.interpret(f, [int64(1234567890123456789)])
+ res = self.interpret(f, [r_int64(1234567890123456789)])
assert type(res) is float
assert self.float_eq(res, 1.2345678901234568e+18)
def test_rarithmetic(self):
- inttypes = [int, r_uint, int64, r_ulonglong]
+ inttypes = [int, r_uint, r_int64, r_ulonglong]
for inttype in inttypes:
c = inttype()
def f():
@@ -231,16 +226,16 @@
res = self.interpret(f, [int(-1<<(r_int.BITS-1))])
assert res == 0
- res = self.interpret(f, [int64(-1)])
+ res = self.interpret(f, [r_int64(-1)])
assert res == 1
- res = self.interpret(f, [int64(-1)<<(r_longlong.BITS-1)])
+ res = self.interpret(f, [r_int64(-1)<<(r_longlong.BITS-1)])
assert res == 0
div_mod_iteration_count = 1000
def test_div_mod(self):
import random
- for inttype in (int, int64):
+ for inttype in (int, r_int64):
def d(x, y):
return x/y
@@ -303,7 +298,7 @@
except ZeroDivisionError:
return 84
- for inttype in (int, int64):
+ for inttype in (int, r_int64):
args = [( 5, 2), (-5, 2), ( 5,-2), (-5,-2),
( 6, 2), (-6, 2), ( 6,-2), (-6,-2),
More information about the Pypy-commit
mailing list