Move flags to ReactorStmtCtx
[yangtools.git] / yang / yang-parser-reactor / src / main / java / org / opendaylight / yangtools / yang / parser / stmt / reactor / ReactorStmtCtx.java
1 /*
2  * Copyright (c) 2020 PANTHEON.tech, s.r.o. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.yangtools.yang.parser.stmt.reactor;
9
10 import static com.google.common.base.Verify.verify;
11
12 import com.google.common.base.MoreObjects;
13 import com.google.common.base.MoreObjects.ToStringHelper;
14 import com.google.common.base.VerifyException;
15 import java.util.Collection;
16 import java.util.Map;
17 import java.util.Optional;
18 import java.util.Set;
19 import org.eclipse.jdt.annotation.NonNull;
20 import org.eclipse.jdt.annotation.Nullable;
21 import org.opendaylight.yangtools.yang.common.QName;
22 import org.opendaylight.yangtools.yang.common.YangVersion;
23 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
24 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
25 import org.opendaylight.yangtools.yang.model.api.meta.IdentifierNamespace;
26 import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
27 import org.opendaylight.yangtools.yang.model.api.stmt.ConfigEffectiveStatement;
28 import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
29 import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
30 import org.opendaylight.yangtools.yang.parser.spi.meta.ModelActionBuilder;
31 import org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase;
32 import org.opendaylight.yangtools.yang.parser.spi.meta.MutableStatement;
33 import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour.Registry;
34 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.Mutable;
35 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils;
36 import org.opendaylight.yangtools.yang.parser.spi.source.SupportedFeaturesNamespace;
37 import org.opendaylight.yangtools.yang.parser.spi.source.SupportedFeaturesNamespace.SupportedFeatures;
38 import org.slf4j.Logger;
39 import org.slf4j.LoggerFactory;
40
41 /**
42  * Real "core" reactor statement implementation of {@link Mutable}, supporting basic reactor lifecycle.
43  *
44  * @param <A> Argument type
45  * @param <D> Declared Statement representation
46  * @param <E> Effective Statement representation
47  */
48 abstract class ReactorStmtCtx<A, D extends DeclaredStatement<A>, E extends EffectiveStatement<A, D>>
49         extends NamespaceStorageSupport implements Mutable<A, D, E> {
50     private static final Logger LOG = LoggerFactory.getLogger(ReactorStmtCtx.class);
51
52     /**
53      * Substatement refcount tracking. This mechanics deals with retaining substatements for the purposes of
54      * instantiating their lazy copies in InferredStatementContext. It works in concert with {@link #buildEffective()}
55      * and {@link #buildDeclared()}: declared/effective statement views hold an implicit reference and refcount-based
56      * sweep is not activated until they are done (or this statement is not {@link #isSupportedToBuildEffective}).
57      *
58      * <p>
59      * Reference count is hierarchical in that parent references also pin down their child statements and do not allow
60      * them to be swept.
61      *
62      * <p>
63      * The counter's positive values are tracking incoming references via {@link #incRef()}/{@link #decRef()} methods.
64      * Once we transition to sweeping, this value becomes negative counting upwards to {@link #REFCOUNT_NONE} based on
65      * {@link #sweepOnChildDone()}. Once we reach that, we transition to {@link #REFCOUNT_SWEPT}.
66      */
67     private int refcount = REFCOUNT_NONE;
68     /**
69      * No outstanding references, this statement is a potential candidate for sweeping, provided it has populated its
70      * declared and effective views and {@link #parentRef} is known to be absent.
71      */
72     private static final int REFCOUNT_NONE = 0;
73     /**
74      * Reference count overflow or some other recoverable logic error. Do not rely on refcounts and do not sweep
75      * anything.
76      *
77      * <p>
78      * Note on value assignment:
79      * This allow our incRef() to naturally progress to being saturated. Others jump there directly.
80      * It also makes it  it impossible to observe {@code Interger.MAX_VALUE} children, which we take advantage of for
81      * {@link #REFCOUNT_SWEEPING}.
82      */
83     private static final int REFCOUNT_DEFUNCT = Integer.MAX_VALUE;
84     /**
85      * This statement is being actively swept. This is a transient value set when we are sweeping our children, so that
86      * we prevent re-entering this statement.
87      *
88      * <p>
89      * Note on value assignment:
90      * The value is lower than any legal child refcount due to {@link #REFCOUNT_DEFUNCT} while still being higher than
91      * {@link #REFCOUNT_SWEPT}.
92      */
93     private static final int REFCOUNT_SWEEPING = -Integer.MAX_VALUE;
94     /**
95      * This statement, along with its entire subtree has been swept and we positively know all our children have reached
96      * this state. We {@link #sweepNamespaces()} upon reaching this state.
97      *
98      * <p>
99      * Note on value assignment:
100      * This is the lowest value observable, making it easier on checking others on equality.
101      */
102     private static final int REFCOUNT_SWEPT = Integer.MIN_VALUE;
103
104     private @Nullable E effectiveInstance;
105
106     // Master flag controlling whether this context can yield an effective statement
107     // FIXME: investigate the mechanics that are being supported by this, as it would be beneficial if we can get rid
108     //        of this flag -- eliminating the initial alignment shadow used by below gap-filler fields.
109     private boolean isSupportedToBuildEffective = true;
110
111     // Flag bit assignments
112     private static final int IS_SUPPORTED_BY_FEATURES    = 0x01;
113     private static final int HAVE_SUPPORTED_BY_FEATURES  = 0x02;
114     private static final int IS_IGNORE_IF_FEATURE        = 0x04;
115     private static final int HAVE_IGNORE_IF_FEATURE      = 0x08;
116     // Note: these four are related
117     private static final int IS_IGNORE_CONFIG            = 0x10;
118     private static final int HAVE_IGNORE_CONFIG          = 0x20;
119     private static final int IS_CONFIGURATION            = 0x40;
120     private static final int HAVE_CONFIGURATION          = 0x80;
121
122     // Have-and-set flag constants, also used as masks
123     private static final int SET_SUPPORTED_BY_FEATURES = HAVE_SUPPORTED_BY_FEATURES | IS_SUPPORTED_BY_FEATURES;
124     private static final int SET_CONFIGURATION = HAVE_CONFIGURATION | IS_CONFIGURATION;
125     // Note: implies SET_CONFIGURATION, allowing fewer bit operations to be performed
126     private static final int SET_IGNORE_CONFIG = HAVE_IGNORE_CONFIG | IS_IGNORE_CONFIG | SET_CONFIGURATION;
127     private static final int SET_IGNORE_IF_FEATURE = HAVE_IGNORE_IF_FEATURE | IS_IGNORE_IF_FEATURE;
128
129     // Flags for use with SubstatementContext. These are hiding in the alignment shadow created by above boolean and
130     // hence improve memory layout.
131     private byte flags;
132
133     // Flag for use with AbstractResumedStatement. This is hiding in the alignment shadow created by above boolean
134     // FIXME: move this out once we have JDK15+
135     private boolean fullyDefined;
136
137     ReactorStmtCtx() {
138         // Empty on purpose
139     }
140
141     ReactorStmtCtx(final ReactorStmtCtx<A, D, E> original) {
142         isSupportedToBuildEffective = original.isSupportedToBuildEffective;
143         fullyDefined = original.fullyDefined;
144         flags = original.flags;
145     }
146
147     //
148     //
149     // Common public interface contracts with simple mechanics. Please keep this in one logical block, so we do not end
150     // up mixing concerns and simple details with more complex logic.
151     //
152     //
153
154     @Override
155     public abstract StatementContextBase<?, ?, ?> getParentContext();
156
157     @Override
158     public abstract RootStatementContext<?, ?, ?> getRoot();
159
160     @Override
161     public abstract Collection<? extends StatementContextBase<?, ?, ?>> mutableDeclaredSubstatements();
162
163     @Override
164     public final @NonNull Registry getBehaviourRegistry() {
165         return getRoot().getBehaviourRegistryImpl();
166     }
167
168     @Override
169     public final YangVersion getRootVersion() {
170         return getRoot().getRootVersionImpl();
171     }
172
173     @Override
174     public final void setRootVersion(final YangVersion version) {
175         getRoot().setRootVersionImpl(version);
176     }
177
178     @Override
179     public final void addMutableStmtToSeal(final MutableStatement mutableStatement) {
180         getRoot().addMutableStmtToSealImpl(mutableStatement);
181     }
182
183     @Override
184     public final void addRequiredSource(final SourceIdentifier dependency) {
185         getRoot().addRequiredSourceImpl(dependency);
186     }
187
188     @Override
189     public final void setRootIdentifier(final SourceIdentifier identifier) {
190         getRoot().setRootIdentifierImpl(identifier);
191     }
192
193     @Override
194     public final boolean isEnabledSemanticVersioning() {
195         return getRoot().isEnabledSemanticVersioningImpl();
196     }
197
198     @Override
199     public final ModelActionBuilder newInferenceAction(final ModelProcessingPhase phase) {
200         return getRoot().getSourceContext().newInferenceAction(phase);
201     }
202
203     @Override
204     public final StatementDefinition publicDefinition() {
205         return definition().getPublicView();
206     }
207
208     @Override
209     public final String toString() {
210         return addToStringAttributes(MoreObjects.toStringHelper(this).omitNullValues()).toString();
211     }
212
213     protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
214         return toStringHelper.add("definition", definition()).add("rawArgument", rawArgument());
215     }
216
217     /**
218      * Return the context in which this statement was defined.
219      *
220      * @return statement definition
221      */
222     abstract @NonNull StatementDefinitionContext<A, D, E> definition();
223
224     //
225     //
226     // NamespaceStorageSupport/Mutable integration methods. Keep these together.
227     //
228     //
229
230     @Override
231     public final <K, V, T extends K, N extends IdentifierNamespace<K, V>> V getFromNamespace(
232             final Class<@NonNull N> type, final T key) {
233         return getBehaviourRegistry().getNamespaceBehaviour(type).getFrom(this, key);
234     }
235
236     @Override
237     public final <K, V, N extends IdentifierNamespace<K, V>> Map<K, V> getAllFromNamespace(final Class<N> type) {
238         return getNamespace(type);
239     }
240
241     @Override
242     public final <K, V, N extends IdentifierNamespace<K, V>> Map<K, V> getAllFromCurrentStmtCtxNamespace(
243             final Class<N> type) {
244         return getLocalNamespace(type);
245     }
246
247     @Override
248     protected final void checkLocalNamespaceAllowed(final Class<? extends IdentifierNamespace<?, ?>> type) {
249         definition().checkNamespaceAllowed(type);
250     }
251
252     @Override
253     protected <K, V, N extends IdentifierNamespace<K, V>> void onNamespaceElementAdded(final Class<N> type, final K key,
254             final V value) {
255         // definition().onNamespaceElementAdded(this, type, key, value);
256     }
257
258     //
259     //
260     // Statement build entry points -- both public and package-private.
261     //
262     //
263
264     @Override
265     public final E buildEffective() {
266         final E existing;
267         return (existing = effectiveInstance) != null ? existing : loadEffective();
268     }
269
270     private E loadEffective() {
271         // Creating an effective statement does not strictly require a declared instance -- there are statements like
272         // 'input', which are implicitly defined.
273         // Our implementation design makes an invariant assumption that buildDeclared() has been called by the time
274         // we attempt to create effective statement:
275         buildDeclared();
276
277         final E ret = effectiveInstance = createEffective();
278         // we have called createEffective(), substatements are no longer guarded by us. Let's see if we can clear up
279         // some residue.
280         if (refcount == REFCOUNT_NONE) {
281             sweepOnDecrement();
282         }
283         return ret;
284     }
285
286     abstract @NonNull E createEffective();
287
288     //
289     //
290     // Flags-based mechanics. These include public interfaces as well as all the crud we have lurking in our alignment
291     // shadow.
292     //
293     //
294
295     @Override
296     public final boolean isSupportedToBuildEffective() {
297         return isSupportedToBuildEffective;
298     }
299
300     @Override
301     public final void setIsSupportedToBuildEffective(final boolean isSupportedToBuildEffective) {
302         this.isSupportedToBuildEffective = isSupportedToBuildEffective;
303     }
304
305     @Override
306     public final boolean isSupportedByFeatures() {
307         final int fl = flags & SET_SUPPORTED_BY_FEATURES;
308         if (fl != 0) {
309             return fl == SET_SUPPORTED_BY_FEATURES;
310         }
311         if (isIgnoringIfFeatures()) {
312             flags |= SET_SUPPORTED_BY_FEATURES;
313             return true;
314         }
315
316         /*
317          * If parent is supported, we need to check if-features statements of this context.
318          */
319         if (isParentSupportedByFeatures()) {
320             // If the set of supported features has not been provided, all features are supported by default.
321             final Set<QName> supportedFeatures = getFromNamespace(SupportedFeaturesNamespace.class,
322                     SupportedFeatures.SUPPORTED_FEATURES);
323             if (supportedFeatures == null || StmtContextUtils.checkFeatureSupport(this, supportedFeatures)) {
324                 flags |= SET_SUPPORTED_BY_FEATURES;
325                 return true;
326             }
327         }
328
329         // Either parent is not supported or this statement is not supported
330         flags |= HAVE_SUPPORTED_BY_FEATURES;
331         return false;
332     }
333
334     protected abstract boolean isParentSupportedByFeatures();
335
336     /**
337      * Config statements are not all that common which means we are performing a recursive search towards the root
338      * every time {@link #isConfiguration()} is invoked. This is quite expensive because it causes a linear search
339      * for the (usually non-existent) config statement.
340      *
341      * <p>
342      * This method maintains a resolution cache, so once we have returned a result, we will keep on returning the same
343      * result without performing any lookups, solely to support {@link SubstatementContext#isConfiguration()}.
344      *
345      * <p>
346      * Note: use of this method implies that {@link #isIgnoringConfig()} is realized with
347      *       {@link #isIgnoringConfig(StatementContextBase)}.
348      */
349     final boolean isConfiguration(final StatementContextBase<?, ?, ?> parent) {
350         final int fl = flags & SET_CONFIGURATION;
351         if (fl != 0) {
352             return fl == SET_CONFIGURATION;
353         }
354         if (isIgnoringConfig(parent)) {
355             // Note: SET_CONFIGURATION has been stored in flags
356             return true;
357         }
358
359         final boolean isConfig;
360         final Optional<Boolean> optConfig = findSubstatementArgument(ConfigEffectiveStatement.class);
361         if (optConfig.isPresent()) {
362             isConfig = optConfig.orElseThrow();
363             if (isConfig) {
364                 // Validity check: if parent is config=false this cannot be a config=true
365                 InferenceException.throwIf(!parent.isConfiguration(), sourceReference(),
366                         "Parent node has config=false, this node must not be specifed as config=true");
367             }
368         } else {
369             // If "config" statement is not specified, the default is the same as the parent's "config" value.
370             isConfig = parent.isConfiguration();
371         }
372
373         // Resolved, make sure we cache this return
374         flags |= isConfig ? SET_CONFIGURATION : HAVE_CONFIGURATION;
375         return isConfig;
376     }
377
378     protected abstract boolean isIgnoringConfig();
379
380     /**
381      * This method maintains a resolution cache for ignore config, so once we have returned a result, we will
382      * keep on returning the same result without performing any lookups. Exists only to support
383      * {@link SubstatementContext#isIgnoringConfig()}.
384      *
385      * <p>
386      * Note: use of this method implies that {@link #isConfiguration()} is realized with
387      *       {@link #isConfiguration(StatementContextBase)}.
388      */
389     final boolean isIgnoringConfig(final StatementContextBase<?, ?, ?> parent) {
390         final int fl = flags & SET_IGNORE_CONFIG;
391         if (fl != 0) {
392             return fl == SET_IGNORE_CONFIG;
393         }
394         if (definition().support().isIgnoringConfig() || parent.isIgnoringConfig()) {
395             flags |= SET_IGNORE_CONFIG;
396             return true;
397         }
398
399         flags |= HAVE_IGNORE_CONFIG;
400         return false;
401     }
402
403     protected abstract boolean isIgnoringIfFeatures();
404
405     /**
406      * This method maintains a resolution cache for ignore if-feature, so once we have returned a result, we will
407      * keep on returning the same result without performing any lookups. Exists only to support
408      * {@link SubstatementContext#isIgnoringIfFeatures()}.
409      */
410     final boolean isIgnoringIfFeatures(final StatementContextBase<?, ?, ?> parent) {
411         final int fl = flags & SET_IGNORE_IF_FEATURE;
412         if (fl != 0) {
413             return fl == SET_IGNORE_IF_FEATURE;
414         }
415         if (definition().support().isIgnoringIfFeatures() || parent.isIgnoringIfFeatures()) {
416             flags |= SET_IGNORE_IF_FEATURE;
417             return true;
418         }
419
420         flags |= HAVE_IGNORE_IF_FEATURE;
421         return false;
422     }
423
424     // These two exists only due to memory optimization, should live in AbstractResumedStatement
425     final boolean fullyDefined() {
426         return fullyDefined;
427     }
428
429     final void setFullyDefined() {
430         fullyDefined = true;
431     }
432
433     //
434     //
435     // Reference counting mechanics start. Please keep these methods in one block for clarity. Note this does not
436     // contribute to state visible outside of this package.
437     //
438     //
439
440     /**
441      * Acquire a reference on this context. As long as there is at least one reference outstanding,
442      * {@link #buildEffective()} will not result in {@link #effectiveSubstatements()} being discarded.
443      *
444      * @throws VerifyException if {@link #effectiveSubstatements()} has already been discarded
445      */
446     final void incRef() {
447         final int current = refcount;
448         verify(current >= REFCOUNT_NONE, "Attempted to access reference count of %s", this);
449         if (current != REFCOUNT_DEFUNCT) {
450             // Note: can end up becoming REFCOUNT_DEFUNCT on overflow
451             refcount = current + 1;
452         } else {
453             LOG.debug("Disabled refcount increment of {}", this);
454         }
455     }
456
457     /**
458      * Release a reference on this context. This call may result in {@link #effectiveSubstatements()} becoming
459      * unavailable.
460      */
461     final void decRef() {
462         final int current = refcount;
463         if (current == REFCOUNT_DEFUNCT) {
464             // no-op
465             LOG.debug("Disabled refcount decrement of {}", this);
466             return;
467         }
468         if (current <= REFCOUNT_NONE) {
469             // Underflow, become defunct
470             LOG.warn("Statement refcount underflow, reference counting disabled for {}", this, new Throwable());
471             refcount = REFCOUNT_DEFUNCT;
472             return;
473         }
474
475         refcount = current - 1;
476         LOG.trace("Refcount {} on {}", refcount, this);
477         if (isSweepable()) {
478             // We are no longer guarded by effective instance
479             sweepOnDecrement();
480         }
481     }
482
483     /**
484      * Sweep this statement context as a result of {@link #sweepSubstatements()}, i.e. when parent is also being swept.
485      */
486     private void sweep() {
487         if (isSweepable()) {
488             LOG.trace("Releasing {}", this);
489             sweepState();
490         }
491     }
492
493     static final void sweep(final Collection<? extends ReactorStmtCtx<?, ?, ?>> substatements) {
494         for (ReactorStmtCtx<?, ?, ?> stmt : substatements) {
495             stmt.sweep();
496         }
497     }
498
499     static final int countUnswept(final Collection<? extends ReactorStmtCtx<?, ?, ?>> substatements) {
500         int result = 0;
501         for (ReactorStmtCtx<?, ?, ?> stmt : substatements) {
502             if (stmt.refcount > REFCOUNT_NONE || !stmt.noImplictRef()) {
503                 result++;
504             }
505         }
506         return result;
507     }
508
509     /**
510      * Implementation-specific sweep action. This is expected to perform a recursive {@link #sweep(Collection)} on all
511      * {@link #declaredSubstatements()} and {@link #effectiveSubstatements()} and report the result of the sweep
512      * operation.
513      *
514      * <p>
515      * {@link #effectiveSubstatements()} as well as namespaces may become inoperable as a result of this operation.
516      *
517      * @return True if the entire tree has been completely swept, false otherwise.
518      */
519     abstract int sweepSubstatements();
520
521     // Called when this statement does not have an implicit reference and have reached REFCOUNT_NONE
522     private void sweepOnDecrement() {
523         LOG.trace("Sweeping on decrement {}", this);
524         if (noParentRefcount()) {
525             // No further parent references, sweep our state.
526             sweepState();
527         }
528
529         // Propagate towards parent if there is one
530         final ReactorStmtCtx<?, ?, ?> parent = getParentContext();
531         if (parent != null) {
532             parent.sweepOnChildDecrement();
533         }
534     }
535
536     // Called from child when it has lost its final reference
537     private void sweepOnChildDecrement() {
538         if (isAwaitingChildren()) {
539             // We are a child for which our parent is waiting. Notify it and we are done.
540             sweepOnChildDone();
541             return;
542         }
543
544         // Check parent reference count
545         final int refs = refcount;
546         if (refs > REFCOUNT_NONE || refs <= REFCOUNT_SWEEPING || !noImplictRef()) {
547             // No-op
548             return;
549         }
550
551         // parent is potentially reclaimable
552         if (noParentRefcount()) {
553             LOG.trace("Cleanup {} of parent {}", refcount, this);
554             if (sweepState()) {
555                 final ReactorStmtCtx<?, ?, ?> parent = getParentContext();
556                 if (parent != null) {
557                     parent.sweepOnChildDecrement();
558                 }
559             }
560         }
561     }
562
563     private boolean noImplictRef() {
564         return effectiveInstance != null || !isSupportedToBuildEffective();
565     }
566
567     // FIXME: cache the resolution of this
568     private boolean noParentRefcount() {
569         final ReactorStmtCtx<?, ?, ?> parent = getParentContext();
570         if (parent != null) {
571             // There are three possibilities:
572             // - REFCOUNT_NONE, in which case we need to search next parent
573             // - negative (< REFCOUNT_NONE), meaning parent is in some stage of sweeping, hence it does not have
574             //   a reference to us
575             // - positive (> REFCOUNT_NONE), meaning parent has an explicit refcount which is holding us down
576             final int refs = parent.refcount;
577             return refs == REFCOUNT_NONE ? parent.noParentRefcount() : refs < REFCOUNT_NONE;
578         }
579         return true;
580     }
581
582     private boolean isAwaitingChildren() {
583         return refcount > REFCOUNT_SWEEPING && refcount < REFCOUNT_NONE;
584     }
585
586     private boolean isSweepable() {
587         return refcount == REFCOUNT_NONE && noImplictRef();
588     }
589
590     private void sweepOnChildDone() {
591         LOG.trace("Sweeping on child done {}", this);
592         final int current = refcount;
593         if (current >= REFCOUNT_NONE) {
594             // no-op, perhaps we want to handle some cases differently?
595             LOG.trace("Ignoring child sweep of {} for {}", this, current);
596             return;
597         }
598         verify(current != REFCOUNT_SWEPT, "Attempt to sweep a child of swept %s", this);
599
600         refcount = current + 1;
601         LOG.trace("Child refcount {}", refcount);
602         if (refcount == REFCOUNT_NONE) {
603             sweepDone();
604             final ReactorStmtCtx<?, ?, ?> parent = getParentContext();
605             LOG.trace("Propagating to parent {}", parent);
606             if (parent != null && parent.isAwaitingChildren()) {
607                 parent.sweepOnChildDone();
608             }
609         }
610     }
611
612     private void sweepDone() {
613         LOG.trace("Sweep done for {}", this);
614         refcount = REFCOUNT_SWEPT;
615         sweepNamespaces();
616     }
617
618     private boolean sweepState() {
619         refcount = REFCOUNT_SWEEPING;
620         final int childRefs = sweepSubstatements();
621         if (childRefs == 0) {
622             sweepDone();
623             return true;
624         }
625         if (childRefs < 0 || childRefs >= REFCOUNT_DEFUNCT) {
626             LOG.warn("Negative child refcount {} cannot be stored, reference counting disabled for {}", childRefs, this,
627                 new Throwable());
628             refcount = REFCOUNT_DEFUNCT;
629         } else {
630             LOG.trace("Still {} outstanding children of {}", childRefs, this);
631             refcount = -childRefs;
632         }
633         return false;
634     }
635 }