Author: Maciej Fijalkowski <fij...@gmail.com> Branch: gc_no_cleanup_nursery Changeset: r73289:b1e335a09328 Date: 2014-09-03 11:28 -0600 http://bitbucket.org/pypy/pypy/changeset/b1e335a09328/
Log: kill malloc_nonmovable - it turned out to be a bad idea to start with diff --git a/pypy/tool/pypyjit_child.py b/pypy/tool/pypyjit_child.py --- a/pypy/tool/pypyjit_child.py +++ b/pypy/tool/pypyjit_child.py @@ -10,10 +10,6 @@ graph = loc['graph'] interp.malloc_check = False - def returns_null(T, *args, **kwds): - return lltype.nullptr(T) - interp.heap.malloc_nonmovable = returns_null # XXX - from rpython.jit.backend.llgraph.runner import LLGraphCPU #LLtypeCPU.supports_floats = False # for now apply_jit(interp, graph, LLGraphCPU) 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 @@ -223,7 +223,7 @@ ## return None, f, None def define_compile_framework_1(cls): - # a moving GC. Supports malloc_varsize_nonmovable. Simple test, works + # a moving GC. Simple test, works # without write_barriers and root stack enumeration. def f(n, x, *args): y = X() diff --git a/rpython/jit/tl/jittest.py b/rpython/jit/tl/jittest.py --- a/rpython/jit/tl/jittest.py +++ b/rpython/jit/tl/jittest.py @@ -6,7 +6,6 @@ import os from rpython import conftest -from rpython.rtyper.lltypesystem import lltype from rpython.rtyper.llinterp import LLInterpreter from rpython.rtyper.annlowlevel import llstr from rpython.jit.metainterp import warmspot @@ -24,10 +23,6 @@ graph = driver.translator._graphof(driver.entry_point) interp = LLInterpreter(driver.translator.rtyper) - def returns_null(T, *args, **kwds): - return lltype.nullptr(T) - interp.heap.malloc_nonmovable = returns_null # XXX - get_policy = driver.extra['jitpolicy'] jitpolicy = get_policy(driver) diff --git a/rpython/memory/gc/base.py b/rpython/memory/gc/base.py --- a/rpython/memory/gc/base.py +++ b/rpython/memory/gc/base.py @@ -47,9 +47,6 @@ def _teardown(self): pass - def can_malloc_nonmovable(self): - return not self.moving_gc - def can_optimize_clean_setarrayitems(self): return True # False in case of card marking @@ -168,9 +165,6 @@ # lots of cast and reverse-cast around... return llmemory.cast_ptr_to_adr(ref) - def malloc_nonmovable(self, typeid, length=0, zero=False): - return self.malloc(typeid, length, zero) - def id(self, ptr): return lltype.cast_ptr_to_int(ptr) diff --git a/rpython/memory/gc/hybrid.py b/rpython/memory/gc/hybrid.py --- a/rpython/memory/gc/hybrid.py +++ b/rpython/memory/gc/hybrid.py @@ -167,7 +167,7 @@ llmemory.GCREF) return self.malloc_varsize_slowpath(typeid, length) - def malloc_varsize_slowpath(self, typeid, length, force_nonmovable=False): + def malloc_varsize_slowpath(self, typeid, length): # For objects that are too large, or when the nursery is exhausted. # In order to keep malloc_varsize_clear() as compact as possible, # we recompute what we need in this slow path instead of passing @@ -185,7 +185,7 @@ nonlarge_max = self.nonlarge_gcptrs_max else: nonlarge_max = self.nonlarge_max - if force_nonmovable or raw_malloc_usage(totalsize) > nonlarge_max: + if raw_malloc_usage(totalsize) > nonlarge_max: result = self.malloc_varsize_marknsweep(totalsize) flags = self.GCFLAGS_FOR_NEW_EXTERNAL_OBJECTS | GCFLAG_UNVISITED else: @@ -197,17 +197,6 @@ malloc_varsize_slowpath._dont_inline_ = True - def malloc_varsize_nonmovable(self, typeid, length): - return self.malloc_varsize_slowpath(typeid, length, True) - - def malloc_nonmovable(self, typeid, length, zero): - # helper for testing, same as GCBase.malloc - if self.is_varsize(typeid): - gcref = self.malloc_varsize_slowpath(typeid, length, True) - else: - raise NotImplementedError("Not supported") - return llmemory.cast_ptr_to_adr(gcref) - def can_move(self, addr): tid = self.header(addr).tid return not (tid & GCFLAG_EXTERNAL) @@ -554,6 +543,3 @@ "gen3: unexpected GCFLAG_UNVISITED") ll_assert((tid & GCFLAG_AGE_MASK) == GCFLAG_AGE_MAX, "gen3: wrong age field") - - def can_malloc_nonmovable(self): - return True diff --git a/rpython/memory/gc/incminimark.py b/rpython/memory/gc/incminimark.py --- a/rpython/memory/gc/incminimark.py +++ b/rpython/memory/gc/incminimark.py @@ -427,7 +427,7 @@ # the start of the nursery: we actually allocate a bit more for # the nursery than really needed, to simplify pointer arithmetic # in malloc_fixedsize_clear(). The few extra pages are never used - # anyway so it doesn't even count. + # anyway so it doesn't even counct. nursery = llarena.arena_malloc(self._nursery_memory_size(), 0) if not nursery: raise MemoryError("cannot allocate nursery") @@ -830,9 +830,6 @@ # that one will occur very soon self.nursery_free = self.nursery_top - def can_malloc_nonmovable(self): - return True - def can_optimize_clean_setarrayitems(self): if self.card_page_indices > 0: return False @@ -868,20 +865,6 @@ (obj + offset_to_length).signed[0] = smallerlength return True - - def malloc_fixedsize_nonmovable(self, typeid): - obj = self.external_malloc(typeid, 0) - return llmemory.cast_adr_to_ptr(obj, llmemory.GCREF) - - def malloc_varsize_nonmovable(self, typeid, length): - obj = self.external_malloc(typeid, length) - return llmemory.cast_adr_to_ptr(obj, llmemory.GCREF) - - def malloc_nonmovable(self, typeid, length, zero): - # helper for testing, same as GCBase.malloc - return self.external_malloc(typeid, length or 0) # None -> 0 - - # ---------- # Simple helpers diff --git a/rpython/memory/gc/minimark.py b/rpython/memory/gc/minimark.py --- a/rpython/memory/gc/minimark.py +++ b/rpython/memory/gc/minimark.py @@ -822,9 +822,6 @@ self.nursery_top = self.nursery_real_top self.nursery_free = self.nursery_real_top - def can_malloc_nonmovable(self): - return True - def can_optimize_clean_setarrayitems(self): if self.card_page_indices > 0: return False @@ -861,19 +858,6 @@ return True - def malloc_fixedsize_nonmovable(self, typeid): - obj = self.external_malloc(typeid, 0) - return llmemory.cast_adr_to_ptr(obj, llmemory.GCREF) - - def malloc_varsize_nonmovable(self, typeid, length): - obj = self.external_malloc(typeid, length) - return llmemory.cast_adr_to_ptr(obj, llmemory.GCREF) - - def malloc_nonmovable(self, typeid, length, zero): - # helper for testing, same as GCBase.malloc - return self.external_malloc(typeid, length or 0) # None -> 0 - - # ---------- # Simple helpers diff --git a/rpython/memory/gctransform/framework.py b/rpython/memory/gctransform/framework.py --- a/rpython/memory/gctransform/framework.py +++ b/rpython/memory/gctransform/framework.py @@ -388,17 +388,6 @@ annmodel.SomeInteger(nonneg=True)], s_gcref, inline = True) - if getattr(GCClass, 'malloc_varsize_nonmovable', False): - malloc_nonmovable = func_with_new_name( - GCClass.malloc_varsize_nonmovable.im_func, - "malloc_varsize_nonmovable") - self.malloc_varsize_nonmovable_ptr = getfn( - malloc_nonmovable, - [s_gc, s_typeid16, - annmodel.SomeInteger(nonneg=True)], s_gcref) - else: - self.malloc_varsize_nonmovable_ptr = None - if getattr(GCClass, 'raw_malloc_memory_pressure', False): def raw_malloc_memory_pressure_varsize(length, itemsize): totalmem = length * itemsize @@ -665,7 +654,6 @@ has_light_finalizer) if not op.opname.endswith('_varsize') and not flags.get('varsize'): - #TODO:check if it's safe to remove the zero-flag zero = flags.get('zero', False) if (self.malloc_fast_ptr is not None and not c_has_finalizer.value and @@ -684,18 +672,12 @@ info_varsize.ofstolength) c_varitemsize = rmodel.inputconst(lltype.Signed, info_varsize.varitemsize) - if flags.get('nonmovable') and self.malloc_varsize_nonmovable_ptr: - # we don't have tests for such cases, let's fail - # explicitely - malloc_ptr = self.malloc_varsize_nonmovable_ptr - args = [self.c_const_gc, c_type_id, v_length] + if self.malloc_varsize_fast_ptr is not None: + malloc_ptr = self.malloc_varsize_fast_ptr else: - if self.malloc_varsize_fast_ptr is not None: - malloc_ptr = self.malloc_varsize_fast_ptr - else: - malloc_ptr = self.malloc_varsize_ptr - args = [self.c_const_gc, c_type_id, v_length, c_size, - c_varitemsize, c_ofstolength] + malloc_ptr = self.malloc_varsize_ptr + args = [self.c_const_gc, c_type_id, v_length, c_size, + c_varitemsize, c_ofstolength] livevars = self.push_roots(hop) v_result = hop.genop("direct_call", [malloc_ptr] + args, resulttype=llmemory.GCREF) @@ -1076,20 +1058,6 @@ resultvar=hop.spaceop.result) self.pop_roots(hop, livevars) - def gct_malloc_nonmovable_varsize(self, hop): - TYPE = hop.spaceop.result.concretetype - if self.gcdata.gc.can_malloc_nonmovable(): - return self.gct_malloc_varsize(hop, {'nonmovable':True}) - c = rmodel.inputconst(TYPE, lltype.nullptr(TYPE.TO)) - return hop.cast_result(c) - - def gct_malloc_nonmovable(self, hop): - TYPE = hop.spaceop.result.concretetype - if self.gcdata.gc.can_malloc_nonmovable(): - return self.gct_malloc(hop, {'nonmovable':True}) - c = rmodel.inputconst(TYPE, lltype.nullptr(TYPE.TO)) - return hop.cast_result(c) - def _set_into_gc_array_part(self, op): if op.opname == 'setarrayitem': return op.args[1] @@ -1231,7 +1199,7 @@ v_adr = llops.genop('adr_add', [v_a, c_fixedofs], resulttype=llmemory.Address) llops.genop('raw_memclear', [v_adr, v_totalsize]) - elif isinstance(TYPE, lltype.Struct): + elif isinstance(ITEM, lltype.Struct): xxx return else: diff --git a/rpython/memory/gctransform/transform.py b/rpython/memory/gctransform/transform.py --- a/rpython/memory/gctransform/transform.py +++ b/rpython/memory/gctransform/transform.py @@ -510,12 +510,6 @@ assert meth, "%s has no support for malloc_varsize with flavor %r" % (self, flavor) return self.varsize_malloc_helper(hop, flags, meth, []) - def gct_malloc_nonmovable(self, *args, **kwds): - return self.gct_malloc(*args, **kwds) - - def gct_malloc_nonmovable_varsize(self, *args, **kwds): - return self.gct_malloc_varsize(*args, **kwds) - def gct_gc_add_memory_pressure(self, hop): if hasattr(self, 'raw_malloc_memory_pressure_ptr'): op = hop.spaceop diff --git a/rpython/memory/gcwrapper.py b/rpython/memory/gcwrapper.py --- a/rpython/memory/gcwrapper.py +++ b/rpython/memory/gcwrapper.py @@ -57,16 +57,6 @@ return lltype.malloc(TYPE, n, flavor=flavor, zero=zero, track_allocation=track_allocation) - def malloc_nonmovable(self, TYPE, n=None, zero=False): - typeid = self.get_type_id(TYPE) - if not self.gc.can_malloc_nonmovable(): - return lltype.nullptr(TYPE) - addr = self.gc.malloc_nonmovable(typeid, n, zero=zero) - result = llmemory.cast_adr_to_ptr(addr, lltype.Ptr(TYPE)) - if not self.gc.malloc_zero_filled: - gctypelayout.zero_gc_pointers(result) - return result - def add_memory_pressure(self, size): if hasattr(self.gc, 'raw_malloc_memory_pressure'): self.gc.raw_malloc_memory_pressure(size) diff --git a/rpython/memory/test/gc_test_base.py b/rpython/memory/test/gc_test_base.py --- a/rpython/memory/test/gc_test_base.py +++ b/rpython/memory/test/gc_test_base.py @@ -25,7 +25,6 @@ class GCTest(object): GC_PARAMS = {} GC_CAN_MOVE = False - GC_CAN_MALLOC_NONMOVABLE = True GC_CAN_SHRINK_ARRAY = False GC_CAN_SHRINK_BIG_ARRAY = False BUT_HOW_BIG_IS_A_BIG_STRING = 3*WORD @@ -614,34 +613,6 @@ return rgc.can_move(lltype.malloc(TP, 1)) assert self.interpret(func, []) == self.GC_CAN_MOVE - - def test_malloc_nonmovable(self): - TP = lltype.GcArray(lltype.Char) - def func(): - a = rgc.malloc_nonmovable(TP, 3) - if a: - assert not rgc.can_move(a) - return 1 - return 0 - - assert self.interpret(func, []) == int(self.GC_CAN_MALLOC_NONMOVABLE) - - def test_malloc_nonmovable_fixsize(self): - S = lltype.GcStruct('S', ('x', lltype.Float)) - TP = lltype.GcStruct('T', ('s', lltype.Ptr(S))) - def func(): - try: - a = rgc.malloc_nonmovable(TP) - rgc.collect() - if a: - assert not rgc.can_move(a) - return 1 - return 0 - except Exception: - return 2 - - assert self.interpret(func, []) == int(self.GC_CAN_MALLOC_NONMOVABLE) - def test_shrink_array(self): from rpython.rtyper.lltypesystem.rstr import STR diff --git a/rpython/memory/test/test_hybrid_gc.py b/rpython/memory/test/test_hybrid_gc.py --- a/rpython/memory/test/test_hybrid_gc.py +++ b/rpython/memory/test/test_hybrid_gc.py @@ -8,7 +8,6 @@ class TestHybridGC(test_generational_gc.TestGenerationalGC): from rpython.memory.gc.hybrid import HybridGC as GCClass - GC_CAN_MALLOC_NONMOVABLE = True GC_CAN_SHRINK_BIG_ARRAY = False def test_ref_from_rawmalloced_to_regular(self): @@ -71,6 +70,3 @@ return b.num_deleted res = self.interpret(f, [15]) assert res == 16 - - def test_malloc_nonmovable_fixsize(self): - py.test.skip("Not supported") diff --git a/rpython/memory/test/test_hybrid_gc_smallheap.py b/rpython/memory/test/test_hybrid_gc_smallheap.py --- a/rpython/memory/test/test_hybrid_gc_smallheap.py +++ b/rpython/memory/test/test_hybrid_gc_smallheap.py @@ -10,7 +10,6 @@ from rpython.memory.gc.hybrid import HybridGC as GCClass GC_CAN_MOVE = False # with this size of heap, stuff gets allocated # in 3rd gen. - GC_CAN_MALLOC_NONMOVABLE = True GC_PARAMS = {'space_size': 48*WORD, 'min_nursery_size': 12*WORD, 'nursery_size': 12*WORD, @@ -51,6 +50,3 @@ return i res = self.interpret(f, [200]) assert res == 401 - - def test_malloc_nonmovable_fixsize(self): - py.test.skip("Not supported") diff --git a/rpython/memory/test/test_transformed_gc.py b/rpython/memory/test/test_transformed_gc.py --- a/rpython/memory/test/test_transformed_gc.py +++ b/rpython/memory/test/test_transformed_gc.py @@ -44,7 +44,6 @@ class GCTest(object): gcpolicy = None GC_CAN_MOVE = False - GC_CAN_MALLOC_NONMOVABLE = True taggedpointers = False def setup_class(cls): @@ -622,45 +621,6 @@ res = run([]) assert res == self.GC_CAN_MOVE - def define_malloc_nonmovable(cls): - TP = lltype.GcArray(lltype.Char) - def func(): - #try: - a = rgc.malloc_nonmovable(TP, 3, zero=True) - rgc.collect() - if a: - assert not rgc.can_move(a) - return 1 - return 0 - #except Exception, e: - # return 2 - - return func - - def test_malloc_nonmovable(self): - run = self.runner("malloc_nonmovable") - assert int(self.GC_CAN_MALLOC_NONMOVABLE) == run([]) - - def define_malloc_nonmovable_fixsize(cls): - S = lltype.GcStruct('S', ('x', lltype.Float)) - TP = lltype.GcStruct('T', ('s', lltype.Ptr(S))) - def func(): - try: - a = rgc.malloc_nonmovable(TP) - rgc.collect() - if a: - assert not rgc.can_move(a) - return 1 - return 0 - except Exception, e: - return 2 - - return func - - def test_malloc_nonmovable_fixsize(self): - run = self.runner("malloc_nonmovable_fixsize") - assert run([]) == int(self.GC_CAN_MALLOC_NONMOVABLE) - def define_shrink_array(cls): from rpython.rtyper.lltypesystem.rstr import STR @@ -708,7 +668,6 @@ class GenericMovingGCTests(GenericGCTests): GC_CAN_MOVE = True - GC_CAN_MALLOC_NONMOVABLE = False GC_CAN_TEST_ID = False def define_many_ids(cls): class A(object): @@ -1169,7 +1128,6 @@ class TestHybridGC(TestGenerationGC): gcname = "hybrid" - GC_CAN_MALLOC_NONMOVABLE = True class gcpolicy(gc.BasicFrameworkGcPolicy): class transformerclass(shadowstack.ShadowStackFrameworkGCTransformer): @@ -1230,9 +1188,6 @@ run = self.runner("write_barrier_direct") res = run([]) assert res == 42 - - def test_malloc_nonmovable_fixsize(self): - py.test.skip("not supported") class TestMiniMarkGC(TestHybridGC): gcname = "minimark" diff --git a/rpython/rlib/rgc.py b/rpython/rlib/rgc.py --- a/rpython/rlib/rgc.py +++ b/rpython/rlib/rgc.py @@ -101,40 +101,6 @@ hop.exception_is_here() return hop.genop('gc_heap_stats', [], resulttype=hop.r_result) -def malloc_nonmovable(TP, n=None, zero=False): - """ Allocate a non-moving buffer or return nullptr. - When running directly, will pretend that gc is always - moving (might be configurable in a future) - """ - return lltype.nullptr(TP) - -class MallocNonMovingEntry(ExtRegistryEntry): - _about_ = malloc_nonmovable - - def compute_result_annotation(self, s_TP, s_n=None, s_zero=None): - # basically return the same as malloc - from rpython.annotator.builtin import BUILTIN_ANALYZERS - return BUILTIN_ANALYZERS[lltype.malloc](s_TP, s_n, s_zero=s_zero) - - def specialize_call(self, hop, i_zero=None): - # XXX assume flavor and zero to be None by now - assert hop.args_s[0].is_constant() - vlist = [hop.inputarg(lltype.Void, arg=0)] - opname = 'malloc_nonmovable' - flags = {'flavor': 'gc'} - if i_zero is not None: - flags['zero'] = hop.args_s[i_zero].const - nb_args = hop.nb_args - 1 - else: - nb_args = hop.nb_args - vlist.append(hop.inputconst(lltype.Void, flags)) - - if nb_args == 2: - vlist.append(hop.inputarg(lltype.Signed, arg=1)) - opname += '_varsize' - - hop.exception_cannot_occur() - return hop.genop(opname, vlist, resulttype = hop.r_result.lowleveltype) def copy_struct_item(source, dest, si, di): TP = lltype.typeOf(source).TO.OF diff --git a/rpython/rtyper/llinterp.py b/rpython/rtyper/llinterp.py --- a/rpython/rtyper/llinterp.py +++ b/rpython/rtyper/llinterp.py @@ -682,18 +682,6 @@ except MemoryError: self.make_llexception() - def op_malloc_nonmovable(self, TYPE, flags): - flavor = flags['flavor'] - assert flavor == 'gc' - zero = flags.get('zero', False) - return self.heap.malloc_nonmovable(TYPE, zero=zero) - - def op_malloc_nonmovable_varsize(self, TYPE, flags, size): - flavor = flags['flavor'] - assert flavor == 'gc' - zero = flags.get('zero', False) - return self.heap.malloc_nonmovable(TYPE, size, zero=zero) - def op_free(self, obj, flags): assert flags['flavor'] == 'raw' track_allocation = flags.get('track_allocation', True) diff --git a/rpython/rtyper/lltypesystem/llheap.py b/rpython/rtyper/lltypesystem/llheap.py --- a/rpython/rtyper/lltypesystem/llheap.py +++ b/rpython/rtyper/lltypesystem/llheap.py @@ -18,7 +18,6 @@ def weakref_create_getlazy(objgetter): return weakref_create(objgetter()) -malloc_nonmovable = malloc def shrink_array(p, smallersize): return False diff --git a/rpython/rtyper/lltypesystem/lloperation.py b/rpython/rtyper/lltypesystem/lloperation.py --- a/rpython/rtyper/lltypesystem/lloperation.py +++ b/rpython/rtyper/lltypesystem/lloperation.py @@ -368,8 +368,6 @@ 'malloc': LLOp(canmallocgc=True), 'malloc_varsize': LLOp(canmallocgc=True), - 'malloc_nonmovable': LLOp(canmallocgc=True), - 'malloc_nonmovable_varsize':LLOp(canmallocgc=True), 'shrink_array': LLOp(canrun=True), 'zero_gc_pointers_inside': LLOp(), 'free': LLOp(), diff --git a/rpython/rtyper/lltypesystem/rclass.py b/rpython/rtyper/lltypesystem/rclass.py --- a/rpython/rtyper/lltypesystem/rclass.py +++ b/rpython/rtyper/lltypesystem/rclass.py @@ -505,13 +505,7 @@ ctype = inputconst(Void, self.object_type) cflags = inputconst(Void, flags) vlist = [ctype, cflags] - cnonmovable = self.classdef.classdesc.read_attribute( - '_alloc_nonmovable_', Constant(False)) - if cnonmovable.value: - opname = 'malloc_nonmovable' - else: - opname = 'malloc' - vptr = llops.genop(opname, vlist, + vptr = llops.genop('malloc', vlist, resulttype = Ptr(self.object_type)) ctypeptr = inputconst(CLASSTYPE, self.rclass.getvtable()) self.setfield(vptr, '__class__', ctypeptr, llops) diff --git a/rpython/rtyper/lltypesystem/rdict.py b/rpython/rtyper/lltypesystem/rdict.py --- a/rpython/rtyper/lltypesystem/rdict.py +++ b/rpython/rtyper/lltypesystem/rdict.py @@ -2,6 +2,7 @@ from rpython.flowspace.model import Constant from rpython.rtyper.rdict import AbstractDictRepr, AbstractDictIteratorRepr from rpython.rtyper.lltypesystem import lltype +from rpython.rtyper.lltypesystem.lloperation import llop from rpython.rlib import objectmodel, jit from rpython.rlib.debug import ll_assert from rpython.rlib.rarithmetic import r_uint, intmask, LONG_BIT @@ -615,18 +616,22 @@ i = i & mask # keep 'i' as a signed number here, to consistently pass signed # arguments to the small helper methods. + llop.debug_print(lltype.Void, "looking in", i) if not entries.everused(i): if freeslot == -1: freeslot = intmask(i) return r_uint(freeslot) | HIGHEST_BIT elif entries.valid(i): + llop.debug_print(lltype.Void, "found!", hash, entries.hash(i)) checkingkey = entries[i].key if direct_compare and checkingkey == key: return i if d.keyeq is not None and entries.hash(i) == hash: # correct hash, maybe the key is e.g. a different pointer to # an equal object + llop.debug_print(lltype.Void, "hashes compare") found = d.keyeq(checkingkey, key) + llop.debug_print(lltype.Void, "found", found) if d.paranoia: if (entries != d.entries or not entries.valid(i) or entries[i].key != checkingkey): diff --git a/rpython/rtyper/test/test_rclass.py b/rpython/rtyper/test/test_rclass.py --- a/rpython/rtyper/test/test_rclass.py +++ b/rpython/rtyper/test/test_rclass.py @@ -1144,17 +1144,6 @@ assert sorted([u]) == [6] # 32-bit types assert sorted([i, r, d, l]) == [2, 3, 4, 5] # 64-bit types - def test_nonmovable(self): - for (nonmovable, opname) in [(True, 'malloc_nonmovable'), - (False, 'malloc')]: - class A(object): - _alloc_nonmovable_ = nonmovable - def f(): - return A() - t, typer, graph = self.gengraph(f, []) - assert summary(graph) == {opname: 1, - 'cast_pointer': 1, - 'setfield': 1} def test_iter(self): class Iterable(object): diff --git a/rpython/translator/c/test/test_boehm.py b/rpython/translator/c/test/test_boehm.py --- a/rpython/translator/c/test/test_boehm.py +++ b/rpython/translator/c/test/test_boehm.py @@ -336,22 +336,6 @@ c_fn = self.getcompiled(fn, []) assert not c_fn() - def test_malloc_nonmovable(self): - TP = lltype.GcArray(lltype.Char) - def func(): - try: - a = rgc.malloc_nonmovable(TP, 3) - rgc.collect() - if a: - assert not rgc.can_move(a) - return 0 - return 1 - except Exception: - return 2 - - run = self.getcompiled(func) - assert run() == 0 - def test_shrink_array(self): def f(): ptr = lltype.malloc(STR, 3) diff --git a/rpython/translator/c/test/test_newgc.py b/rpython/translator/c/test/test_newgc.py --- a/rpython/translator/c/test/test_newgc.py +++ b/rpython/translator/c/test/test_newgc.py @@ -22,7 +22,6 @@ removetypeptr = False taggedpointers = False GC_CAN_MOVE = False - GC_CAN_MALLOC_NONMOVABLE = True GC_CAN_SHRINK_ARRAY = False _isolated_func = None @@ -721,25 +720,6 @@ def test_can_move(self): assert self.run('can_move') == self.GC_CAN_MOVE - def define_malloc_nonmovable(cls): - TP = lltype.GcArray(lltype.Char) - def func(): - try: - a = rgc.malloc_nonmovable(TP, 3) - rgc.collect() - if a: - assert not rgc.can_move(a) - return 1 - return 0 - except Exception: - return 2 - - return func - - def test_malloc_nonmovable(self): - res = self.run('malloc_nonmovable') - assert res == self.GC_CAN_MALLOC_NONMOVABLE - def define_resizable_buffer(cls): from rpython.rtyper.lltypesystem.rstr import STR @@ -1219,7 +1199,6 @@ gcpolicy = "semispace" should_be_moving = True GC_CAN_MOVE = True - GC_CAN_MALLOC_NONMOVABLE = False GC_CAN_SHRINK_ARRAY = True # for snippets @@ -1420,7 +1399,6 @@ class TestHybridGC(TestGenerationalGC): gcpolicy = "hybrid" should_be_moving = True - GC_CAN_MALLOC_NONMOVABLE = True def test_gc_set_max_heap_size(self): py.test.skip("not implemented") @@ -1433,7 +1411,6 @@ class TestMiniMarkGC(TestSemiSpaceGC): gcpolicy = "minimark" should_be_moving = True - GC_CAN_MALLOC_NONMOVABLE = True GC_CAN_SHRINK_ARRAY = True def test_gc_heap_stats(self): diff --git a/rpython/translator/exceptiontransform.py b/rpython/translator/exceptiontransform.py --- a/rpython/translator/exceptiontransform.py +++ b/rpython/translator/exceptiontransform.py @@ -251,8 +251,7 @@ len(block.operations) and (block.exits[0].args[0].concretetype is lltype.Void or block.exits[0].args[0] is block.operations[-1].result) and - block.operations[-1].opname not in ('malloc', # special cases - 'malloc_nonmovable')): + block.operations[-1].opname != 'malloc'): # special cases last_operation -= 1 lastblock = block for i in range(last_operation, -1, -1): @@ -423,14 +422,6 @@ flavor = spaceop.args[1].value['flavor'] if flavor == 'gc': insert_zeroing_op = True - elif spaceop.opname == 'malloc_nonmovable': - # xxx we cannot insert zero_gc_pointers_inside after - # malloc_nonmovable, because it can return null. For now - # we simply always force the zero=True flag on - # malloc_nonmovable. - c_flags = spaceop.args[1] - c_flags.value = c_flags.value.copy() - spaceop.args[1].value['zero'] = True # NB. when inserting more special-cases here, keep in mind that # you also need to list the opnames in transform_block() # (see "special cases") _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit