[pypy-svn] r76859 - in pypy/trunk/pypy: jit/backend/llsupport rpython/memory
arigo at codespeak.net
arigo at codespeak.net
Fri Sep 3 18:31:09 CEST 2010
Author: arigo
Date: Fri Sep 3 18:31:07 2010
New Revision: 76859
Modified:
pypy/trunk/pypy/jit/backend/llsupport/gc.py
pypy/trunk/pypy/rpython/memory/gctypelayout.py
Log:
Bug fixes:
* reintroduce check_typeid() in gctypelayout.py to help
the code in jit/backend/llsupport/gc.py.
* fix an order dependency by rewriting is_weakref().
Modified: pypy/trunk/pypy/jit/backend/llsupport/gc.py
==============================================================================
--- pypy/trunk/pypy/jit/backend/llsupport/gc.py (original)
+++ pypy/trunk/pypy/jit/backend/llsupport/gc.py Fri Sep 3 18:31:07 2010
@@ -328,7 +328,7 @@
DEBUG = False # forced to True by x86/test/test_zrpy_gc.py
def __init__(self, gcdescr, translator, rtyper, llop1=llop):
- from pypy.rpython.memory.gctypelayout import _check_typeid
+ from pypy.rpython.memory.gctypelayout import check_typeid
from pypy.rpython.memory.gcheader import GCHeaderBuilder
from pypy.rpython.memory.gctransform import framework
GcLLDescription.__init__(self, gcdescr, translator, rtyper)
@@ -375,7 +375,7 @@
def malloc_basic(size, tid):
type_id = llop.extract_ushort(llgroup.HALFWORD, tid)
has_finalizer = bool(tid & (1<<llgroup.HALFSHIFT))
- _check_typeid(type_id)
+ check_typeid(type_id)
try:
res = llop1.do_malloc_fixedsize_clear(llmemory.GCREF,
type_id, size, True,
@@ -395,7 +395,7 @@
#
def malloc_array(itemsize, tid, num_elem):
type_id = llop.extract_ushort(llgroup.HALFWORD, tid)
- _check_typeid(type_id)
+ check_typeid(type_id)
try:
return llop1.do_malloc_varsize_clear(
llmemory.GCREF,
@@ -482,7 +482,7 @@
def init_size_descr(self, S, descr):
type_id = self.layoutbuilder.get_type_id(S)
- assert not self.layoutbuilder.is_weakref(type_id)
+ assert not self.layoutbuilder.is_weakref_type(S)
has_finalizer = bool(self.layoutbuilder.has_finalizer(S))
flags = int(has_finalizer) << llgroup.HALFSHIFT
descr.tid = llop.combine_ushort(lltype.Signed, type_id, flags)
Modified: pypy/trunk/pypy/rpython/memory/gctypelayout.py
==============================================================================
--- pypy/trunk/pypy/rpython/memory/gctypelayout.py (original)
+++ pypy/trunk/pypy/rpython/memory/gctypelayout.py Fri Sep 3 18:31:07 2010
@@ -133,6 +133,11 @@
(T_KEY_VALUE | T_IS_VARSIZE),
"invalid varsize type_id")
+def check_typeid(typeid):
+ # xxx does not perform a full check of validity, just checks for nonzero
+ ll_assert(llop.is_group_member_nonzero(lltype.Bool, typeid),
+ "invalid type_id")
+
def encode_type_shape(builder, info, TYPE, index):
"""Encode the shape of the TYPE into the TYPE_INFO structure 'info'."""
@@ -173,7 +178,7 @@
infobits |= T_HAS_GCPTR_IN_VARSIZE
varinfo.varofstoptrs = builder.offsets2table(offsets, ARRAY.OF)
varinfo.varitemsize = llmemory.sizeof(ARRAY.OF)
- if TYPE == WEAKREF:
+ if builder.is_weakref_type(TYPE):
infobits |= T_IS_WEAKREF
info.infobits = infobits | T_KEY_VALUE
@@ -271,8 +276,8 @@
_check_valid_type_info_varsize(res)
return res
- def is_weakref(self, type_id):
- return self.get_info(type_id).infobits & T_IS_WEAKREF
+ def is_weakref_type(self, TYPE):
+ return TYPE == WEAKREF
def encode_type_shapes_now(self):
if not self.can_encode_type_shape:
More information about the Pypy-commit
mailing list