Author: Armin Rigo <ar...@tunes.org> Branch: py3.6 Changeset: r97241:27e4db43a117 Date: 2019-08-22 12:04 +0200 http://bitbucket.org/pypy/pypy/changeset/27e4db43a117/
Log: hg merge default diff --git a/pypy/module/gc/referents.py b/pypy/module/gc/referents.py --- a/pypy/module/gc/referents.py +++ b/pypy/module/gc/referents.py @@ -14,6 +14,8 @@ def try_cast_gcref_to_w_root(gcref): + if rgc.get_gcflag_dummy(gcref): + return None w_obj = rgc.try_cast_gcref_to_instance(W_Root, gcref) # Ignore the instances of W_Root that are not really valid as Python # objects. There is e.g. WeakrefLifeline in module/_weakref that 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 @@ -23,6 +23,7 @@ can_usually_pin_objects = False object_minimal_size = 0 gcflag_extra = 0 # or a dedicated GC flag that the GC initializes to 0 + gcflag_dummy = 0 # dedicated GC flag set only on rmodel.ll_dummy_value _totalroots_rpy = 0 # for inspector.py def __init__(self, config, chunk_size=DEFAULT_CHUNK_SIZE, 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 @@ -162,7 +162,11 @@ # It does not need an additional copy in trace out GCFLAG_SHADOW_INITIALIZED = first_gcflag << 11 -_GCFLAG_FIRST_UNUSED = first_gcflag << 12 # the first unused bit +# another flag set only on specific objects: the ll_dummy_value from +# rpython.rtyper.rmodel +GCFLAG_DUMMY = first_gcflag << 12 + +_GCFLAG_FIRST_UNUSED = first_gcflag << 13 # the first unused bit # States for the incremental GC @@ -203,6 +207,7 @@ can_usually_pin_objects = True malloc_zero_filled = False gcflag_extra = GCFLAG_EXTRA + gcflag_dummy = GCFLAG_DUMMY # All objects start with a HDR, i.e. with a field 'tid' which contains # a word. This word is divided in two halves: the lower half contains 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 @@ -122,7 +122,11 @@ # note that GCFLAG_CARDS_SET is the most significant bit of a byte: # this is required for the JIT (x86) -_GCFLAG_FIRST_UNUSED = first_gcflag << 8 # the first unused bit +# another flag set only on specific objects: the ll_dummy_value from +# rpython.rtyper.rmodel +GCFLAG_DUMMY = first_gcflag << 8 + +_GCFLAG_FIRST_UNUSED = first_gcflag << 9 # the first unused bit FORWARDSTUB = lltype.GcStruct('forwarding_stub', @@ -140,6 +144,7 @@ prebuilt_gc_objects_are_static_roots = False malloc_zero_filled = True # xxx experiment with False gcflag_extra = GCFLAG_EXTRA + gcflag_dummy = GCFLAG_DUMMY # All objects start with a HDR, i.e. with a field 'tid' which contains # a word. This word is divided in two halves: the lower half contains 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 @@ -1675,6 +1675,15 @@ self.translator = translator super(TransformerLayoutBuilder, self).__init__(GCClass, lltype2vtable) + def is_dummy_struct(self, obj): + # overrides the base method + TYPE = lltype.typeOf(obj) + try: + dummy = self.translator.rtyper.cache_dummy_values[TYPE] + except KeyError: + return False + return dummy._obj == obj + def has_destructor(self, TYPE): rtti = get_rtti(TYPE) return rtti is not None and getattr(rtti._obj, 'destructor_funcptr', diff --git a/rpython/memory/gctypelayout.py b/rpython/memory/gctypelayout.py --- a/rpython/memory/gctypelayout.py +++ b/rpython/memory/gctypelayout.py @@ -466,7 +466,10 @@ typeid = self.get_type_id(TYPE) hdr = gc.gcheaderbuilder.new_header(value) adr = llmemory.cast_ptr_to_adr(hdr) - gc.init_gc_object_immortal(adr, typeid) + if gc.gcflag_dummy and self.is_dummy_struct(value): + gc.init_gc_object_immortal(adr, typeid, flags=gc.gcflag_dummy) + else: + gc.init_gc_object_immortal(adr, typeid) self.all_prebuilt_gc.append(value) # The following collects the addresses of all the fields that have @@ -484,6 +487,10 @@ for a in gc_pointers_inside(value, adr, mutable_only=True): appendto.append(a) + def is_dummy_struct(self, obj): + return False # overridden in TransformerLayoutBuilder + + # ____________________________________________________________ # # Helpers to discover GC pointers inside structures diff --git a/rpython/memory/gcwrapper.py b/rpython/memory/gcwrapper.py --- a/rpython/memory/gcwrapper.py +++ b/rpython/memory/gcwrapper.py @@ -188,6 +188,9 @@ hdr.tid &= ~self.gc.gcflag_extra else: hdr.tid |= self.gc.gcflag_extra + elif subopnum == 4: # get_gcflag_dummy + # returns always False if gc.gcflag_dummy == 0 + return (hdr.tid & self.gc.gcflag_dummy) != 0 return (hdr.tid & self.gc.gcflag_extra) != 0 def thread_run(self): diff --git a/rpython/rlib/rgc.py b/rpython/rlib/rgc.py --- a/rpython/rlib/rgc.py +++ b/rpython/rlib/rgc.py @@ -835,6 +835,11 @@ _gcflag_extras.add(gcref) toggle_gcflag_extra._subopnum = 3 +@not_rpython +def get_gcflag_dummy(gcref): + return False +get_gcflag_dummy._subopnum = 4 + def assert_no_more_gcflags(): if not we_are_translated(): assert not _gcflag_extras @@ -1079,7 +1084,8 @@ return hop.genop('gc_typeids_list', [], resulttype = hop.r_result) class Entry(ExtRegistryEntry): - _about_ = (has_gcflag_extra, get_gcflag_extra, toggle_gcflag_extra) + _about_ = (has_gcflag_extra, get_gcflag_extra, toggle_gcflag_extra, + get_gcflag_dummy) def compute_result_annotation(self, s_arg=None): from rpython.annotator.model import s_Bool return s_Bool diff --git a/rpython/translator/c/funcgen.py b/rpython/translator/c/funcgen.py --- a/rpython/translator/c/funcgen.py +++ b/rpython/translator/c/funcgen.py @@ -562,7 +562,7 @@ return '%s = %d;' % (self.expr(op.result), ARRAY.length) else: - return self.generic_get(op, '%s->length;' % self.expr(op.args[0])) + return self.generic_get(op, '%s->length' % self.expr(op.args[0])) def OP_GETARRAYITEM(self, op): ARRAY = self.lltypemap(op.args[0]).TO diff --git a/rpython/translator/c/gc.py b/rpython/translator/c/gc.py --- a/rpython/translator/c/gc.py +++ b/rpython/translator/c/gc.py @@ -388,10 +388,14 @@ raise Exception("the FramewokGCTransformer should handle this") def OP_GC_GCFLAG_EXTRA(self, funcgen, op): - gcflag_extra = self.db.gctransformer.gcdata.gc.gcflag_extra + subopnum = op.args[0].value + if subopnum != 4: + gcflag_extra = self.db.gctransformer.gcdata.gc.gcflag_extra + else: + gcflag_extra = self.db.gctransformer.gcdata.gc.gcflag_dummy + # if gcflag_extra == 0: return BasicGcPolicy.OP_GC_GCFLAG_EXTRA(self, funcgen, op) - subopnum = op.args[0].value if subopnum == 1: return '%s = 1; /* has_gcflag_extra */' % ( funcgen.expr(op.result),) @@ -407,6 +411,8 @@ parts.insert(0, '%s ^= %dL;' % (hdrfield, gcflag_extra)) parts.append('/* toggle_gcflag_extra */') + elif subopnum == 4: # get_gcflag_dummy + parts.append('/* get_gcflag_dummy */') else: raise AssertionError(subopnum) return ' '.join(parts) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit