/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// A map from JS holders to tracer objects, where the values are stored in // SegmentedVector to speed up iteration. class JSHolderMap { public: enum WhichHolders { AllHolders, HoldersRequiredForGrayMarking };
// A map from a holder pointer to a pointer to an entry in a vector.
EntryMap mJSHolderMap;
// A vector of holders not associated with a particular zone or that can // contain pointers to GC things in more than one zone.
EntryVector mAnyZoneJSHolders;
// A map from a zone to a vector of holders that only contain pointers to GC // things in that zone. // // Currently this will only contain wrapper cache wrappers since these are the // only holders to pass a zone parameter through to AddJSHolder.
EntryVectorMap mPerZoneJSHolders;
// Iterators can mutate the element vectors by removing stale elements. Allow // at most one to exist at a time. bool mHasIterator = false;
};
// An iterator over an EntryVector that skips over removed entries and removes // them from the map. class JSHolderMap::EntryVectorIter { public:
EntryVectorIter(JSHolderMap& aMap, EntryVector& aVector)
: mHolderMap(aMap), mVector(aVector), mIter(aVector.Iter()) {
Settle();
}
// If the holders have been removed from the map while the iterator is live, // then the iterator may point to a removed entry. Update the iterator to make // sure it points to a valid entry or is done. void UpdateForRemovals();
public: enum DeferredFinalizeType { // Never finalize immediately, because it would be unsafe.
FinalizeLater, // Finalize later if we can, but it is okay to do it immediately.
FinalizeIncrementally, // Finalize immediately, for shutdown or testing purposes.
FinalizeNow,
};
// Two conditions, JSOutOfMemory and JSLargeAllocationFailure, are noted in // crash reports. Here are the values that can appear in the reports: enumclass OOMState : uint32_t { // The condition has never happened. No entry appears in the crash report.
OK,
// We are currently reporting the given condition. // // Suppose a crash report contains "JSLargeAllocationFailure: // Reporting". This means we crashed while executing memory-pressure // observers, trying to shake loose some memory. The large allocation in // question did not return null: it is still on the stack. Had we not // crashed, it would have been retried.
Reporting,
// The condition has been reported since the last GC. // // If a crash report contains "JSOutOfMemory: Reported", that means a small // allocation failed, and then we crashed, probably due to buggy // error-handling code that ran after allocation returned null. // // This contrasts with "Reporting" which means that no error-handling code // had executed yet.
Reported,
// The condition has happened, but a GC cycle ended since then. // // GC is taken as a proxy for "we've been banging on the heap a good bit // now and haven't crashed; the OOM was probably handled correctly".
Recovered
};
// This needs to be an nsWrapperCache, not a JSObject, because we need to know // when our object gets moved. But we can't trace it (and hence update our // storage), because we do not want to keep it alive. nsWrapperCache handles // this for us via its "object moved" handling. void NurseryWrapperAdded(nsWrapperCache* aCache); void JSObjectsTenured(JS::GCContext* aGCContext);
// Prepare any zones for GC that have been passed to AddZoneWaitingForGC() // since the last GC or since the last call to PrepareWaitingZonesForGC(), // whichever was most recent. If there were no such zones, prepare for a // full GC. void PrepareWaitingZonesForGC();
// Get the current thread's CycleCollectedJSRuntime. Returns null if there // isn't one. static CycleCollectedJSRuntime* Get();
#ifdef NIGHTLY_BUILD // Implementation of the error interceptor. // Built on nightly only to avoid any possible performance impact on release
struct ErrorInterceptor final : public JSErrorInterceptor { virtualvoid interceptError(JSContext* cx,
JS::Handle<JS::Value> exn) override; void Shutdown(JSRuntime* rt);
// Copy of the details of the exception. // We store this rather than the exception itself to avoid dealing with // complicated garbage-collection scenarios, e.g. a JSContext being killed // while we still hold onto an exception thrown from it. struct ErrorDetails {
nsCString mFilename;
nsString mMessage;
nsString mStack;
JSExnType mType;
uint32_t mLine;
uint32_t mColumn;
};
// If we have encountered at least one developer error, // the first error we have encountered. Otherwise, or // if we have reset since the latest error, `None`.
Maybe<ErrorDetails> mThrownError;
};
ErrorInterceptor mErrorInterceptor;
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.3Bemerkung:
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.