[pypy-svn] pypy jit-longlong-2: More fixes. metainterp/test passes again.
arigo
commits-noreply at bitbucket.org
Sat Feb 12 17:40:37 CET 2011
Author: Armin Rigo <arigo at tunes.org>
Branch: jit-longlong-2
Changeset: r41851:5be8666b0f60
Date: 2011-02-12 14:59 +0100
http://bitbucket.org/pypy/pypy/changeset/5be8666b0f60/
Log: More fixes. metainterp/test passes again.
diff --git a/pypy/jit/metainterp/compile.py b/pypy/jit/metainterp/compile.py
--- a/pypy/jit/metainterp/compile.py
+++ b/pypy/jit/metainterp/compile.py
@@ -15,7 +15,7 @@
from pypy.jit.metainterp.typesystem import llhelper, oohelper
from pypy.jit.metainterp.optimizeutil import InvalidLoop
from pypy.jit.metainterp.resume import NUMBERING
-from pypy.jit.codewriter import heaptracker
+from pypy.jit.codewriter import heaptracker, longlong
def giveup():
from pypy.jit.metainterp.pyjitpl import SwitchToBlackhole
@@ -528,7 +528,7 @@
class ResumeGuardCountersFloat(AbstractResumeGuardCounters):
def __init__(self):
self.counters = [0] * 5
- self.values = [0.0] * 5
+ self.values = [longlong.ZEROF] * 5
see_float = func_with_new_name(_see, 'see_float')
diff --git a/pypy/jit/backend/x86/test/test_runner.py b/pypy/jit/backend/x86/test/test_runner.py
--- a/pypy/jit/backend/x86/test/test_runner.py
+++ b/pypy/jit/backend/x86/test/test_runner.py
@@ -390,18 +390,6 @@
res = self.cpu.get_latest_value_int(0)
assert res == 20
- def test_call_with_const_floats(self):
- def func(f1, f2):
- return f1 + f2
-
- FUNC = self.FuncType([lltype.Float, lltype.Float], lltype.Float)
- FPTR = self.Ptr(FUNC)
- calldescr = self.cpu.calldescrof(FUNC, FUNC.ARGS, FUNC.RESULT)
- func_ptr = llhelper(FPTR, func)
- funcbox = self.get_funcbox(self.cpu, func_ptr)
- res = self.execute_operation(rop.CALL, [funcbox, ConstFloat(1.5), ConstFloat(2.5)], 'float', descr=calldescr)
- assert res.value == 4.0
-
class TestDebuggingAssembler(object):
def setup_method(self, meth):
diff --git a/pypy/jit/backend/llgraph/llimpl.py b/pypy/jit/backend/llgraph/llimpl.py
--- a/pypy/jit/backend/llgraph/llimpl.py
+++ b/pypy/jit/backend/llgraph/llimpl.py
@@ -25,7 +25,6 @@
from pypy.rlib.objectmodel import ComputedIntSymbolic, we_are_translated
from pypy.rlib.rarithmetic import ovfcheck
from pypy.rlib.rarithmetic import r_longlong, r_ulonglong, r_uint
-from pypy.rlib.longlong2float import longlong2float, float2longlong
import py
from pypy.tool.ansi_print import ansi_log
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
@@ -12,7 +12,7 @@
from pypy.rlib import rgc
from pypy.jit.backend.llsupport import symbolic
from pypy.jit.backend.x86.jump import remap_frame_layout
-from pypy.jit.codewriter import heaptracker
+from pypy.jit.codewriter import heaptracker, longlong
from pypy.jit.codewriter.effectinfo import EffectInfo
from pypy.jit.metainterp.resoperation import rop
from pypy.jit.backend.llsupport.descr import BaseFieldDescr, BaseArrayDescr
@@ -71,15 +71,16 @@
def convert_to_imm(self, c):
adr = self.assembler.datablockwrapper.malloc_aligned(8, 8)
- xxxxxxxxx
- rffi.cast(rffi.CArrayPtr(rffi.DOUBLE), adr)[0] = c.getfloat()
+ x = c.getfloatstorage()
+ rffi.cast(rffi.CArrayPtr(longlong.FLOATSTORAGE), adr)[0] = x
return ConstFloatLoc(adr)
def convert_to_imm_16bytes_align(self, c):
adr = self.assembler.datablockwrapper.malloc_aligned(16, 16)
- xxxxxxxxx
- rffi.cast(rffi.CArrayPtr(rffi.DOUBLE), adr)[0] = c.getfloat()
- rffi.cast(rffi.CArrayPtr(rffi.DOUBLE), adr)[1] = 0.0
+ x = c.getfloatstorage()
+ y = longlong.ZEROF
+ rffi.cast(rffi.CArrayPtr(longlong.FLOATSTORAGE), adr)[0] = x
+ rffi.cast(rffi.CArrayPtr(longlong.FLOATSTORAGE), adr)[1] = y
return ConstFloatLoc(adr)
def after_call(self, v):
@@ -223,8 +224,7 @@
selected_reg=None, need_lower_byte=False):
if var.type == FLOAT:
if isinstance(var, ConstFloat):
- xxxxxxxxxxxxxx
- return FloatImmedLoc(var.getfloat())
+ return FloatImmedLoc(var.getfloatstorage())
return self.xrm.make_sure_var_in_reg(var, forbidden_vars,
selected_reg, need_lower_byte)
else:
@@ -683,11 +683,10 @@
def _maybe_consider_llong_lt(self, op):
# XXX just a special case for now
- from pypy.rlib.longlong2float import longlong2float
box = op.getarg(2)
if not isinstance(box, ConstFloat):
return False
- if not (box.value == longlong2float(r_longlong(0))):
+ if not box.aslonglong():
return False
# "x < 0"
box = op.getarg(1)
diff --git a/pypy/jit/backend/model.py b/pypy/jit/backend/model.py
--- a/pypy/jit/backend/model.py
+++ b/pypy/jit/backend/model.py
@@ -1,5 +1,4 @@
from pypy.rlib.debug import debug_start, debug_print, debug_stop
-from pypy.rlib.longlong2float import longlong2float, float2longlong
from pypy.jit.metainterp import history, compile
diff --git a/pypy/jit/metainterp/test/test_warmstate.py b/pypy/jit/metainterp/test/test_warmstate.py
--- a/pypy/jit/metainterp/test/test_warmstate.py
+++ b/pypy/jit/metainterp/test/test_warmstate.py
@@ -7,6 +7,13 @@
from pypy.jit.metainterp.warmstate import WarmEnterState, JitCell
from pypy.jit.metainterp.history import BoxInt, BoxFloat, BoxPtr
from pypy.jit.metainterp.history import ConstInt, ConstFloat, ConstPtr
+from pypy.jit.codewriter import longlong
+
+def boxfloat(x):
+ return BoxFloat(longlong.getfloatstorage(x))
+
+def constfloat(x):
+ return ConstFloat(longlong.getfloatstorage(x))
def test_unwrap():
@@ -16,7 +23,7 @@
assert unwrap(lltype.Void, BoxInt(42)) is None
assert unwrap(lltype.Signed, BoxInt(42)) == 42
assert unwrap(lltype.Char, BoxInt(42)) == chr(42)
- assert unwrap(lltype.Float, BoxFloat(42.5)) == 42.5
+ assert unwrap(lltype.Float, boxfloat(42.5)) == 42.5
assert unwrap(lltype.Ptr(S), BoxPtr(po)) == p
def test_wrap():
@@ -26,10 +33,10 @@
p = lltype.malloc(lltype.GcStruct('S'))
po = lltype.cast_opaque_ptr(llmemory.GCREF, p)
assert _is(wrap(None, 42), BoxInt(42))
- assert _is(wrap(None, 42.5), BoxFloat(42.5))
+ assert _is(wrap(None, 42.5), boxfloat(42.5))
assert _is(wrap(None, p), BoxPtr(po))
assert _is(wrap(None, 42, in_const_box=True), ConstInt(42))
- assert _is(wrap(None, 42.5, in_const_box=True), ConstFloat(42.5))
+ assert _is(wrap(None, 42.5, in_const_box=True), constfloat(42.5))
assert _is(wrap(None, p, in_const_box=True), ConstPtr(po))
def test_hash_equal_whatever_lltype():
@@ -138,7 +145,7 @@
set_future_values(5, 42.5)
assert future_values == {
0: ("int", 5),
- 1: ("float", 42.5),
+ 1: ("float", longlong.getfloatstorage(42.5)),
}
assert set_future_values is state.make_set_future_values()
@@ -147,7 +154,7 @@
_green_args_spec = [lltype.Signed, lltype.Float]
state = WarmEnterState(None, FakeJitDriverSD())
unwrap_greenkey = state.make_unwrap_greenkey()
- greenargs = unwrap_greenkey([ConstInt(42), ConstFloat(42.5)])
+ greenargs = unwrap_greenkey([ConstInt(42), constfloat(42.5)])
assert greenargs == (42, 42.5)
assert type(greenargs[0]) is int
@@ -161,7 +168,7 @@
pass
looptoken = FakeLoopToken()
state.attach_unoptimized_bridge_from_interp([ConstInt(5),
- ConstFloat(2.25)],
+ constfloat(2.25)],
looptoken)
cell1 = get_jitcell(True, 5, 2.25)
assert cell1.counter < 0
@@ -183,7 +190,7 @@
return FakeCell()
state.jit_getter = jit_getter
state.make_jitdriver_callbacks()
- res = state.get_location_str([ConstInt(5), ConstFloat(42.5)])
+ res = state.get_location_str([ConstInt(5), constfloat(42.5)])
assert res == '(no jitdriver.get_printable_location!)'
def test_make_jitdriver_callbacks_3():
@@ -205,7 +212,7 @@
_get_jitcell_at_ptr = None
state = WarmEnterState(FakeWarmRunnerDesc(), FakeJitDriverSD())
state.make_jitdriver_callbacks()
- res = state.get_location_str([ConstInt(5), ConstFloat(42.5)])
+ res = state.get_location_str([ConstInt(5), constfloat(42.5)])
assert res == "hi there"
def test_make_jitdriver_callbacks_4():
diff --git a/pypy/jit/metainterp/executor.py b/pypy/jit/metainterp/executor.py
--- a/pypy/jit/metainterp/executor.py
+++ b/pypy/jit/metainterp/executor.py
@@ -30,7 +30,7 @@
else: args_i = None
if count_r: args_r = [NULL] * count_r
else: args_r = None
- if count_f: args_f = [0.0] * count_f
+ if count_f: args_f = [longlong.ZEROF] * count_f
else: args_f = None
# fill in the lists
count_i = count_r = count_f = 0
@@ -68,7 +68,7 @@
result = cpu.bh_call_f(func, descr, args_i, args_r, args_f)
except Exception, e:
metainterp.execute_raised(e)
- result = 0.0
+ result = longlong.ZEROF
return BoxFloat(result)
if rettype == VOID:
try:
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
@@ -551,6 +551,20 @@
descr=calldescr)
assert res.value == ord('a')
+ def test_call_with_const_floats(self):
+ def func(f1, f2):
+ return f1 + f2
+
+ FUNC = self.FuncType([lltype.Float, lltype.Float], lltype.Float)
+ FPTR = self.Ptr(FUNC)
+ calldescr = self.cpu.calldescrof(FUNC, FUNC.ARGS, FUNC.RESULT)
+ func_ptr = llhelper(FPTR, func)
+ funcbox = self.get_funcbox(self.cpu, func_ptr)
+ res = self.execute_operation(rop.CALL, [funcbox, constfloat(1.5),
+ constfloat(2.5)], 'float',
+ descr=calldescr)
+ assert res.getfloat() == 4.0
+
def test_field_basic(self):
t_box, T_box = self.alloc_instance(self.T)
@@ -2026,10 +2040,10 @@
x = self.cpu.get_latest_value_float(0)
assert longlong.getrealfloat(x) == 1.2 + 3.2
called.append(failindex)
- return longlong.getfloatstorage(13.5)
+ return 13.5
FUNCPTR = lltype.Ptr(lltype.FuncType([lltype.Signed, llmemory.GCREF],
- longlong.FLOATSTORAGE))
+ lltype.Float))
class FakeJitDriverSD:
index_of_virtualizable = -1
_assembler_helper_ptr = llhelper(FUNCPTR, assembler_helper)
@@ -2116,7 +2130,7 @@
x = self.cpu.get_latest_value_float(0)
assert longlong.getrealfloat(x) == 1.25 + 3.25
called.append(failindex)
- return longlong.getfloatstorage(13.5)
+ return 13.5
FUNCPTR = lltype.Ptr(lltype.FuncType([lltype.Signed, llmemory.GCREF],
lltype.Float))
@@ -2391,7 +2405,6 @@
py.test.skip("longlong test")
from pypy.translator.tool.cbuild import ExternalCompilationInfo
from pypy.rlib.rarithmetic import r_longlong
- from pypy.rlib.longlong2float import longlong2float, float2longlong
eci = ExternalCompilationInfo(
separate_module_sources=["""
long long fn_test_result_of_call(long long x)
@@ -2419,7 +2432,6 @@
py.test.skip("test of longlong result")
from pypy.translator.tool.cbuild import ExternalCompilationInfo
from pypy.rlib.rarithmetic import r_longlong
- from pypy.rlib.longlong2float import longlong2float, float2longlong
eci = ExternalCompilationInfo(
separate_module_sources=["""
long long fn_test_result_of_call(long long x)
diff --git a/pypy/jit/codewriter/longlong.py b/pypy/jit/codewriter/longlong.py
--- a/pypy/jit/codewriter/longlong.py
+++ b/pypy/jit/codewriter/longlong.py
@@ -43,3 +43,5 @@
TYPE == lltype.UnsignedLongLong)
# -------------------------------------
+
+ZEROF = getfloatstorage(0.0)
diff --git a/pypy/jit/backend/llsupport/descr.py b/pypy/jit/backend/llsupport/descr.py
--- a/pypy/jit/backend/llsupport/descr.py
+++ b/pypy/jit/backend/llsupport/descr.py
@@ -325,7 +325,7 @@
self.call_stub = d['call_stub']
def verify_types(self, args_i, args_r, args_f, return_type):
- assert self._return_type == return_type
+ assert self._return_type in return_type
assert self.arg_classes.count('i') == len(args_i or ())
assert self.arg_classes.count('r') == len(args_r or ())
assert (self.arg_classes.count('f') +
diff --git a/pypy/jit/backend/x86/regloc.py b/pypy/jit/backend/x86/regloc.py
--- a/pypy/jit/backend/x86/regloc.py
+++ b/pypy/jit/backend/x86/regloc.py
@@ -6,6 +6,7 @@
from pypy.rlib.objectmodel import specialize, instantiate
from pypy.rlib.rarithmetic import intmask
from pypy.jit.metainterp.history import FLOAT
+from pypy.jit.codewriter import longlong
#
# This module adds support for "locations", which can be either in a Const,
@@ -212,9 +213,8 @@
_immutable_ = True
width = 8
- def __init__(self, floatvalue):
- from pypy.rlib.longlong2float import float2longlong
- self.aslonglong = float2longlong(floatvalue)
+ def __init__(self, floatstorage):
+ self.aslonglong = floatstorage
def low_part(self):
return intmask(self.aslonglong)
@@ -229,15 +229,14 @@
return ImmedLoc(self.high_part())
def __repr__(self):
- from pypy.rlib.longlong2float import longlong2float
- floatvalue = longlong2float(self.aslonglong)
+ floatvalue = longlong.getrealfloat(self.aslonglong)
return '<FloatImmedLoc(%s)>' % (floatvalue,)
def location_code(self):
raise NotImplementedError
if IS_X86_64:
- def FloatImmedLoc(floatvalue):
+ def FloatImmedLoc(floatstorage):
from pypy.rlib.longlong2float import float2longlong
value = intmask(float2longlong(floatvalue))
return ImmedLoc(value)
diff --git a/pypy/jit/metainterp/history.py b/pypy/jit/metainterp/history.py
--- a/pypy/jit/metainterp/history.py
+++ b/pypy/jit/metainterp/history.py
@@ -309,11 +309,11 @@
class ConstFloat(Const):
type = FLOAT
- value = longlong.getfloatstorage(0.0)
+ value = longlong.ZEROF
_attrs_ = ('value',)
def __init__(self, valuestorage):
- assert isinstance(valuestorage, longlong.r_float_storage)
+ assert lltype.typeOf(valuestorage) is longlong.FLOATSTORAGE
self.value = valuestorage
def clonebox(self):
@@ -336,7 +336,7 @@
return False
def nonnull(self):
- return self.value != 0
+ return self.value != longlong.ZEROF
def _getrepr_(self):
return self.getfloat()
@@ -344,7 +344,7 @@
def repr_rpython(self):
return repr_rpython(self, 'cf')
-CONST_FZERO = ConstFloat(longlong.getfloatstorage(0.0))
+CONST_FZERO = ConstFloat(longlong.ZEROF)
class ConstPtr(Const):
type = REF
@@ -554,12 +554,12 @@
type = FLOAT
_attrs_ = ('value',)
- def __init__(self, valuestorage=longlong.getfloatstorage(0.0)):
- assert isinstance(valuestorage, longlong.r_float_storage)
+ def __init__(self, valuestorage=longlong.ZEROF):
+ assert lltype.typeOf(valuestorage) is longlong.FLOATSTORAGE
self.value = valuestorage
def forget_value(self):
- self.value = longlong.getfloatstorage(0.0)
+ self.value = longlong.ZEROF
def clonebox(self):
return BoxFloat(self.value)
@@ -577,7 +577,7 @@
cpu.set_future_value_float(j, self.value)
def nonnull(self):
- return self.value != 0
+ return self.value != longlong.ZEROF
def _getrepr_(self):
return self.getfloat()
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
@@ -252,7 +252,7 @@
if we_are_translated():
default_i = 0
default_r = NULL
- default_f = longlong.getfloatstorage(0.0)
+ default_f = longlong.ZEROF
else:
default_i = MissingValue()
default_r = MissingValue()
diff --git a/pypy/jit/backend/llsupport/llmodel.py b/pypy/jit/backend/llsupport/llmodel.py
--- a/pypy/jit/backend/llsupport/llmodel.py
+++ b/pypy/jit/backend/llsupport/llmodel.py
@@ -511,7 +511,7 @@
def bh_call_f(self, func, calldescr, args_i, args_r, args_f):
assert isinstance(calldescr, FloatCallDescr) # or LongLongCallDescr
if not we_are_translated():
- calldescr.verify_types(args_i, args_r, args_f, history.FLOAT)
+ calldescr.verify_types(args_i, args_r, args_f, history.FLOAT + 'L')
return calldescr.call_stub(func, args_i, args_r, args_f)
def bh_call_v(self, func, calldescr, args_i, args_r, args_f):
More information about the Pypy-commit
mailing list