[pypy-svn] r74880 - in pypy/branch/blackhole-improvement/pypy: annotation jit/backend/llsupport jit/backend/test jit/backend/x86 jit/metainterp rpython rpython/lltypesystem translator/c/src
arigo at codespeak.net
arigo at codespeak.net
Fri May 28 23:57:07 CEST 2010
Author: arigo
Date: Fri May 28 23:57:05 2010
New Revision: 74880
Modified:
pypy/branch/blackhole-improvement/pypy/annotation/builtin.py
pypy/branch/blackhole-improvement/pypy/jit/backend/llsupport/gc.py
pypy/branch/blackhole-improvement/pypy/jit/backend/test/runner_test.py
pypy/branch/blackhole-improvement/pypy/jit/backend/x86/ri386.py
pypy/branch/blackhole-improvement/pypy/jit/backend/x86/runner.py
pypy/branch/blackhole-improvement/pypy/jit/metainterp/logger.py
pypy/branch/blackhole-improvement/pypy/rpython/lltypesystem/llmemory.py
pypy/branch/blackhole-improvement/pypy/rpython/lltypesystem/lloperation.py
pypy/branch/blackhole-improvement/pypy/rpython/lltypesystem/opimpl.py
pypy/branch/blackhole-improvement/pypy/rpython/lltypesystem/rffi.py
pypy/branch/blackhole-improvement/pypy/rpython/raddress.py
pypy/branch/blackhole-improvement/pypy/rpython/rbuiltin.py
pypy/branch/blackhole-improvement/pypy/translator/c/src/int.h
Log:
General progress.
(Quite boring checkin messages, I know, but it's hard
to describe it more precisely than: I spent some time
tracking obscure bugs and fixing them)
Modified: pypy/branch/blackhole-improvement/pypy/annotation/builtin.py
==============================================================================
--- pypy/branch/blackhole-improvement/pypy/annotation/builtin.py (original)
+++ pypy/branch/blackhole-improvement/pypy/annotation/builtin.py Fri May 28 23:57:05 2010
@@ -346,9 +346,6 @@
def llmemory_cast_int_to_adr(s):
return SomeAddress()
-def llmemory_get_inthash_from_int(s):
- return SomeInteger() # xxx
-
##def rarith_ovfcheck(s_obj):
## if isinstance(s_obj, SomeInteger) and s_obj.unsigned:
@@ -390,7 +387,6 @@
BUILTIN_ANALYZERS[pypy.rpython.lltypesystem.llmemory.cast_adr_to_ptr] = llmemory_cast_adr_to_ptr
BUILTIN_ANALYZERS[pypy.rpython.lltypesystem.llmemory.cast_adr_to_int] = llmemory_cast_adr_to_int
BUILTIN_ANALYZERS[pypy.rpython.lltypesystem.llmemory.cast_int_to_adr] = llmemory_cast_int_to_adr
-BUILTIN_ANALYZERS[pypy.rpython.lltypesystem.llmemory.get_inthash_from_int] = llmemory_get_inthash_from_int
BUILTIN_ANALYZERS[getattr(OSError.__init__, 'im_func', OSError.__init__)] = (
OSError_init)
Modified: pypy/branch/blackhole-improvement/pypy/jit/backend/llsupport/gc.py
==============================================================================
--- pypy/branch/blackhole-improvement/pypy/jit/backend/llsupport/gc.py (original)
+++ pypy/branch/blackhole-improvement/pypy/jit/backend/llsupport/gc.py Fri May 28 23:57:05 2010
@@ -171,7 +171,7 @@
# the object moves)
addr = llmemory.cast_ptr_to_adr(gcref)
hash = llmemory.cast_adr_to_int(addr)
- hash = llmemory.get_inthash_from_int(hash)
+ hash = rffi.get_real_int(hash)
hash -= hash >> self.HASHTABLE_BITS
hash &= self.HASHTABLE_SIZE - 1
addr_ref = self.hashtable[hash]
Modified: pypy/branch/blackhole-improvement/pypy/jit/backend/test/runner_test.py
==============================================================================
--- pypy/branch/blackhole-improvement/pypy/jit/backend/test/runner_test.py (original)
+++ pypy/branch/blackhole-improvement/pypy/jit/backend/test/runner_test.py Fri May 28 23:57:05 2010
@@ -1663,8 +1663,8 @@
x = cpu.bh_newstr(5)
y = cpu.bh_cast_ptr_to_int(x)
z = cpu.bh_cast_ptr_to_int(x)
- y = llmemory.get_inthash_from_int(y)
- z = llmemory.get_inthash_from_int(z)
+ y = rffi.get_real_int(y)
+ z = rffi.get_real_int(z)
assert type(y) == type(z) == int and y == z
def test_sorting_of_fields(self):
Modified: pypy/branch/blackhole-improvement/pypy/jit/backend/x86/ri386.py
==============================================================================
--- pypy/branch/blackhole-improvement/pypy/jit/backend/x86/ri386.py (original)
+++ pypy/branch/blackhole-improvement/pypy/jit/backend/x86/ri386.py Fri May 28 23:57:05 2010
@@ -1,7 +1,7 @@
from pypy.rlib.rarithmetic import intmask
from pypy.rlib.objectmodel import ComputedIntSymbolic, we_are_translated
from pypy.rlib.debug import make_sure_not_resized
-from pypy.rpython.lltypesystem import llmemory
+from pypy.rpython.lltypesystem.rffi import get_real_int
class OPERAND(object):
_attrs_ = []
@@ -211,7 +211,7 @@
class REL32(OPERAND):
width = 4
def __init__(self, absolute_target):
- self.absolute_target = absolute_target
+ self.absolute_target = get_real_int(absolute_target)
def assembler(self):
return '%d' % (self.absolute_target,)
@@ -290,7 +290,7 @@
def imm(value):
if isinstance(value, ComputedIntSymbolic):
value = value.compute_fn()
- value = llmemory.get_inthash_from_int(value)
+ value = get_real_int(value)
if single_byte(value):
return imm8(value)
else:
Modified: pypy/branch/blackhole-improvement/pypy/jit/backend/x86/runner.py
==============================================================================
--- pypy/branch/blackhole-improvement/pypy/jit/backend/x86/runner.py (original)
+++ pypy/branch/blackhole-improvement/pypy/jit/backend/x86/runner.py Fri May 28 23:57:05 2010
@@ -2,6 +2,7 @@
import ctypes
import py
from pypy.rpython.lltypesystem import lltype, llmemory, rffi
+from pypy.rpython.lltypesystem.lloperation import llop
from pypy.rpython.llinterp import LLInterpreter
from pypy.rlib.objectmodel import we_are_translated
from pypy.jit.metainterp import history, compile
Modified: pypy/branch/blackhole-improvement/pypy/jit/metainterp/logger.py
==============================================================================
--- pypy/branch/blackhole-improvement/pypy/jit/metainterp/logger.py (original)
+++ pypy/branch/blackhole-improvement/pypy/jit/metainterp/logger.py Fri May 28 23:57:05 2010
@@ -2,7 +2,7 @@
from pypy.rlib.debug import have_debug_prints
from pypy.rlib.debug import debug_start, debug_stop, debug_print
from pypy.rlib.objectmodel import we_are_translated
-from pypy.rpython.lltypesystem import llmemory
+from pypy.rpython.lltypesystem import llmemory, rffi
from pypy.jit.metainterp.resoperation import rop
from pypy.jit.metainterp.history import Const, ConstInt, Box, \
BoxInt, ConstFloat, BoxFloat, AbstractFailDescr
@@ -108,7 +108,7 @@
def int_could_be_an_address(x):
if we_are_translated():
- x = llmemory.get_inthash_from_int(x)
+ x = rffi.get_real_int(x)
return not (-32768 <= x <= 32767)
else:
return isinstance(x, llmemory.AddressAsInt)
Modified: pypy/branch/blackhole-improvement/pypy/rpython/lltypesystem/llmemory.py
==============================================================================
--- pypy/branch/blackhole-improvement/pypy/rpython/lltypesystem/llmemory.py (original)
+++ pypy/branch/blackhole-improvement/pypy/rpython/lltypesystem/llmemory.py Fri May 28 23:57:05 2010
@@ -635,14 +635,6 @@
ptr = lltype.cast_int_to_ptr(_NONGCREF, int)
return cast_ptr_to_adr(ptr)
-def get_inthash_from_int(int):
- """Just returns 'int' after translation. Before translation, it convert
- an AddressAsInt into a real integer, to use e.g. as a hash. Do not store
- the real integer (or the dict using this as a hash) across translation."""
- if isinstance(int, AddressAsInt):
- int = lltype.cast_ptr_to_int(int.adr.ptr)
- return int
-
# ____________________________________________________________
# Weakrefs.
#
Modified: pypy/branch/blackhole-improvement/pypy/rpython/lltypesystem/lloperation.py
==============================================================================
--- pypy/branch/blackhole-improvement/pypy/rpython/lltypesystem/lloperation.py (original)
+++ pypy/branch/blackhole-improvement/pypy/rpython/lltypesystem/lloperation.py Fri May 28 23:57:05 2010
@@ -411,7 +411,6 @@
'cast_adr_to_ptr': LLOp(canfold=True),
'cast_adr_to_int': LLOp(sideeffects=False),
'cast_int_to_adr': LLOp(canfold=True),
- 'get_inthash_from_int': LLOp(canfold=True),
'get_group_member': LLOp(canfold=True),
'get_next_group_member':LLOp(canfold=True),
Modified: pypy/branch/blackhole-improvement/pypy/rpython/lltypesystem/opimpl.py
==============================================================================
--- pypy/branch/blackhole-improvement/pypy/rpython/lltypesystem/opimpl.py (original)
+++ pypy/branch/blackhole-improvement/pypy/rpython/lltypesystem/opimpl.py Fri May 28 23:57:05 2010
@@ -340,9 +340,6 @@
def op_cast_int_to_adr(int):
return llmemory.cast_int_to_adr(int)
-def op_get_inthash_from_int(int):
- return llmemory.get_inthash_from_int(int)
-
##def op_cast_int_to_adr(x):
## assert type(x) is int
## return llmemory.cast_int_to_adr(x)
Modified: pypy/branch/blackhole-improvement/pypy/rpython/lltypesystem/rffi.py
==============================================================================
--- pypy/branch/blackhole-improvement/pypy/rpython/lltypesystem/rffi.py (original)
+++ pypy/branch/blackhole-improvement/pypy/rpython/lltypesystem/rffi.py Fri May 28 23:57:05 2010
@@ -905,3 +905,11 @@
"""
return cast(lltype.Signed, getattr(pdst, fieldname))
getintfield._annspecialcase_ = 'specialize:ll_and_arg(1)'
+
+def get_real_int(i):
+ """No-op after translation. Before translation, it convert an
+ AddressAsInt into a real integer, to use e.g. as a hash. Do not store
+ the real integer (or the dict using this as a hash) across translation."""
+ # although it's not really a cast, this force_cast forces
+ # the AddressAsInt to be evaluated with ctypes
+ return cast(lltype.Signed, i)
Modified: pypy/branch/blackhole-improvement/pypy/rpython/raddress.py
==============================================================================
--- pypy/branch/blackhole-improvement/pypy/rpython/raddress.py (original)
+++ pypy/branch/blackhole-improvement/pypy/rpython/raddress.py Fri May 28 23:57:05 2010
@@ -2,7 +2,7 @@
from pypy.tool.pairtype import pairtype
from pypy.annotation import model as annmodel
from pypy.rpython.lltypesystem.llmemory import NULL, Address, \
- cast_adr_to_int, get_inthash_from_int, fakeaddress
+ cast_adr_to_int, fakeaddress
from pypy.rpython.rmodel import Repr, IntegerRepr
from pypy.rpython.rptr import PtrRepr
from pypy.rpython.lltypesystem import lltype
@@ -57,9 +57,9 @@
get_ll_fasthash_function = get_ll_hash_function
def ll_addrhash(addr1):
- result = cast_adr_to_int(addr1)
# we don't want to have an AddressAsInt instance in this case
- return get_inthash_from_int(result)
+ from pypy.rpython.lltypesystem import rffi
+ return rffi.get_real_int(cast_adr_to_int(addr1))
address_repr = AddressRepr()
Modified: pypy/branch/blackhole-improvement/pypy/rpython/rbuiltin.py
==============================================================================
--- pypy/branch/blackhole-improvement/pypy/rpython/rbuiltin.py (original)
+++ pypy/branch/blackhole-improvement/pypy/rpython/rbuiltin.py Fri May 28 23:57:05 2010
@@ -615,15 +615,9 @@
return hop.genop('cast_int_to_adr', [v_input],
resulttype = llmemory.Address)
-def rtype_get_inthash_from_int(hop):
- v_input, = hop.inputargs(lltype.Signed)
- hop.exception_cannot_occur()
- return hop.genop('get_inthash_from_int', [v_input],
- resulttype = lltype.Signed)
-
BUILTIN_TYPER[llmemory.cast_ptr_to_adr] = rtype_cast_ptr_to_adr
BUILTIN_TYPER[llmemory.cast_adr_to_ptr] = rtype_cast_adr_to_ptr
BUILTIN_TYPER[llmemory.cast_adr_to_int] = rtype_cast_adr_to_int
BUILTIN_TYPER[llmemory.cast_int_to_adr] = rtype_cast_int_to_adr
-BUILTIN_TYPER[llmemory.get_inthash_from_int] = rtype_get_inthash_from_int
+
Modified: pypy/branch/blackhole-improvement/pypy/translator/c/src/int.h
==============================================================================
--- pypy/branch/blackhole-improvement/pypy/translator/c/src/int.h (original)
+++ pypy/branch/blackhole-improvement/pypy/translator/c/src/int.h Fri May 28 23:57:05 2010
@@ -297,5 +297,3 @@
#define OP_ULLONG_AND OP_LLONG_AND
#define OP_ULLONG_OR OP_LLONG_OR
#define OP_ULLONG_XOR OP_LLONG_XOR
-
-#define OP_GET_INTHASH_FROM_INT(x, r) r = x;
More information about the Pypy-commit
mailing list