Differential D3143 Diff 14286 ps/trunk/libraries/source/spidermonkey/include-win32-debug/js/TracingAPI.h
Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/libraries/source/spidermonkey/include-win32-debug/js/TracingAPI.h
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- | ||||
* vim: set ts=8 sts=4 et sw=4 tw=99: | * vim: set ts=8 sts=2 et sw=2 tw=80: | ||||
* This Source Code Form is subject to the terms of the Mozilla Public | * 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 | * 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/. */ | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||||
#ifndef js_TracingAPI_h | #ifndef js_TracingAPI_h | ||||
#define js_TracingAPI_h | #define js_TracingAPI_h | ||||
#include "js/AllocPolicy.h" | #include "js/AllocPolicy.h" | ||||
▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Lines | public: | ||||
} | } | ||||
bool isWeakMarkingTracer() const { | bool isWeakMarkingTracer() const { | ||||
return tag_ == TracerKindTag::WeakMarking; | return tag_ == TracerKindTag::WeakMarking; | ||||
} | } | ||||
bool isTenuringTracer() const { return tag_ == TracerKindTag::Tenuring; } | bool isTenuringTracer() const { return tag_ == TracerKindTag::Tenuring; } | ||||
bool isCallbackTracer() const { return tag_ == TracerKindTag::Callback; } | bool isCallbackTracer() const { return tag_ == TracerKindTag::Callback; } | ||||
inline JS::CallbackTracer* asCallbackTracer(); | inline JS::CallbackTracer* asCallbackTracer(); | ||||
bool traceWeakEdges() const { return traceWeakEdges_; } | bool traceWeakEdges() const { return traceWeakEdges_; } | ||||
bool canSkipJsids() const { return canSkipJsids_; } | |||||
#ifdef DEBUG | #ifdef DEBUG | ||||
bool checkEdges() { return checkEdges_; } | bool checkEdges() { return checkEdges_; } | ||||
#endif | #endif | ||||
// Get the current GC number. Only call this method if |isMarkingTracer()| | // Get the current GC number. Only call this method if |isMarkingTracer()| | ||||
// is true. | // is true. | ||||
uint32_t gcNumberForMarking() const; | uint32_t gcNumberForMarking() const; | ||||
protected: | protected: | ||||
JSTracer(JSRuntime* rt, TracerKindTag tag, | JSTracer(JSRuntime* rt, TracerKindTag tag, | ||||
WeakMapTraceKind weakTraceKind = TraceWeakMapValues) | WeakMapTraceKind weakTraceKind = TraceWeakMapValues) | ||||
: runtime_(rt), | : runtime_(rt), | ||||
weakMapAction_(weakTraceKind) | weakMapAction_(weakTraceKind) | ||||
#ifdef DEBUG | #ifdef DEBUG | ||||
, | , | ||||
checkEdges_(true) | checkEdges_(true) | ||||
#endif | #endif | ||||
, | , | ||||
tag_(tag), | tag_(tag), | ||||
traceWeakEdges_(true) { | traceWeakEdges_(true), | ||||
canSkipJsids_(false) { | |||||
} | } | ||||
#ifdef DEBUG | #ifdef DEBUG | ||||
// Set whether to check edges are valid in debug builds. | // Set whether to check edges are valid in debug builds. | ||||
void setCheckEdges(bool check) { checkEdges_ = check; } | void setCheckEdges(bool check) { checkEdges_ = check; } | ||||
#endif | #endif | ||||
private: | private: | ||||
JSRuntime* runtime_; | JSRuntime* runtime_; | ||||
WeakMapTraceKind weakMapAction_; | WeakMapTraceKind weakMapAction_; | ||||
#ifdef DEBUG | #ifdef DEBUG | ||||
bool checkEdges_; | bool checkEdges_; | ||||
#endif | #endif | ||||
protected: | protected: | ||||
TracerKindTag tag_; | TracerKindTag tag_; | ||||
bool traceWeakEdges_; | bool traceWeakEdges_; | ||||
bool canSkipJsids_; | |||||
}; | }; | ||||
namespace JS { | namespace JS { | ||||
class AutoTracingName; | class AutoTracingName; | ||||
class AutoTracingIndex; | class AutoTracingIndex; | ||||
class AutoTracingCallback; | class AutoTracingCallback; | ||||
Show All 13 Lines | public: | ||||
// dispatches to the fully-generic onChild implementation, so for cases that | // dispatches to the fully-generic onChild implementation, so for cases that | ||||
// do not care about boxing overhead and do not need the actual edges, | // do not care about boxing overhead and do not need the actual edges, | ||||
// just override the generic onChild. | // just override the generic onChild. | ||||
virtual void onObjectEdge(JSObject** objp) { onChild(JS::GCCellPtr(*objp)); } | virtual void onObjectEdge(JSObject** objp) { onChild(JS::GCCellPtr(*objp)); } | ||||
virtual void onStringEdge(JSString** strp) { onChild(JS::GCCellPtr(*strp)); } | virtual void onStringEdge(JSString** strp) { onChild(JS::GCCellPtr(*strp)); } | ||||
virtual void onSymbolEdge(JS::Symbol** symp) { | virtual void onSymbolEdge(JS::Symbol** symp) { | ||||
onChild(JS::GCCellPtr(*symp)); | onChild(JS::GCCellPtr(*symp)); | ||||
} | } | ||||
virtual void onBigIntEdge(JS::BigInt** bip) { onChild(JS::GCCellPtr(*bip)); } | |||||
virtual void onScriptEdge(JSScript** scriptp) { | virtual void onScriptEdge(JSScript** scriptp) { | ||||
onChild(JS::GCCellPtr(*scriptp)); | onChild(JS::GCCellPtr(*scriptp)); | ||||
} | } | ||||
virtual void onShapeEdge(js::Shape** shapep) { | virtual void onShapeEdge(js::Shape** shapep) { | ||||
onChild(JS::GCCellPtr(*shapep, JS::TraceKind::Shape)); | onChild(JS::GCCellPtr(*shapep, JS::TraceKind::Shape)); | ||||
} | } | ||||
virtual void onObjectGroupEdge(js::ObjectGroup** groupp) { | virtual void onObjectGroupEdge(js::ObjectGroup** groupp) { | ||||
onChild(JS::GCCellPtr(*groupp, JS::TraceKind::ObjectGroup)); | onChild(JS::GCCellPtr(*groupp, JS::TraceKind::ObjectGroup)); | ||||
▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | #endif | ||||
// In C++, overriding a method hides all methods in the base class with | // In C++, overriding a method hides all methods in the base class with | ||||
// that name, not just methods with that signature. Thus, the typed edge | // that name, not just methods with that signature. Thus, the typed edge | ||||
// methods have to have distinct names to allow us to override them | // methods have to have distinct names to allow us to override them | ||||
// individually, which is freqently useful if, for example, we only want to | // individually, which is freqently useful if, for example, we only want to | ||||
// process only one type of edge. | // process only one type of edge. | ||||
void dispatchToOnEdge(JSObject** objp) { onObjectEdge(objp); } | void dispatchToOnEdge(JSObject** objp) { onObjectEdge(objp); } | ||||
void dispatchToOnEdge(JSString** strp) { onStringEdge(strp); } | void dispatchToOnEdge(JSString** strp) { onStringEdge(strp); } | ||||
void dispatchToOnEdge(JS::Symbol** symp) { onSymbolEdge(symp); } | void dispatchToOnEdge(JS::Symbol** symp) { onSymbolEdge(symp); } | ||||
void dispatchToOnEdge(JS::BigInt** bip) { onBigIntEdge(bip); } | |||||
void dispatchToOnEdge(JSScript** scriptp) { onScriptEdge(scriptp); } | void dispatchToOnEdge(JSScript** scriptp) { onScriptEdge(scriptp); } | ||||
void dispatchToOnEdge(js::Shape** shapep) { onShapeEdge(shapep); } | void dispatchToOnEdge(js::Shape** shapep) { onShapeEdge(shapep); } | ||||
void dispatchToOnEdge(js::ObjectGroup** groupp) { onObjectGroupEdge(groupp); } | void dispatchToOnEdge(js::ObjectGroup** groupp) { onObjectGroupEdge(groupp); } | ||||
void dispatchToOnEdge(js::BaseShape** basep) { onBaseShapeEdge(basep); } | void dispatchToOnEdge(js::BaseShape** basep) { onBaseShapeEdge(basep); } | ||||
void dispatchToOnEdge(js::jit::JitCode** codep) { onJitCodeEdge(codep); } | void dispatchToOnEdge(js::jit::JitCode** codep) { onJitCodeEdge(codep); } | ||||
void dispatchToOnEdge(js::LazyScript** lazyp) { onLazyScriptEdge(lazyp); } | void dispatchToOnEdge(js::LazyScript** lazyp) { onLazyScriptEdge(lazyp); } | ||||
void dispatchToOnEdge(js::Scope** scopep) { onScopeEdge(scopep); } | void dispatchToOnEdge(js::Scope** scopep) { onScopeEdge(scopep); } | ||||
void dispatchToOnEdge(js::RegExpShared** sharedp) { | void dispatchToOnEdge(js::RegExpShared** sharedp) { | ||||
onRegExpSharedEdge(sharedp); | onRegExpSharedEdge(sharedp); | ||||
} | } | ||||
protected: | protected: | ||||
void setTraceWeakEdges(bool value) { traceWeakEdges_ = value; } | void setTraceWeakEdges(bool value) { traceWeakEdges_ = value; } | ||||
// If this is set to false, then the tracer will skip some jsids | |||||
// to improve performance. This is needed for the cycle collector. | |||||
void setCanSkipJsids(bool value) { canSkipJsids_ = value; } | |||||
private: | private: | ||||
friend class AutoTracingName; | friend class AutoTracingName; | ||||
const char* contextName_; | const char* contextName_; | ||||
friend class AutoTracingIndex; | friend class AutoTracingIndex; | ||||
size_t contextIndex_; | size_t contextIndex_; | ||||
friend class AutoTracingDetails; | friend class AutoTracingDetails; | ||||
▲ Show 20 Lines • Show All 96 Lines • ▼ Show 20 Lines | |||||
// re-inserted with the correct hash. | // re-inserted with the correct hash. | ||||
// | // | ||||
// Note that while |edgep| must never be null, it is fine for |*edgep| to be | // Note that while |edgep| must never be null, it is fine for |*edgep| to be | ||||
// nullptr. | // nullptr. | ||||
template <typename T> | template <typename T> | ||||
inline void TraceEdge(JSTracer* trc, JS::Heap<T>* thingp, const char* name) { | inline void TraceEdge(JSTracer* trc, JS::Heap<T>* thingp, const char* name) { | ||||
MOZ_ASSERT(thingp); | MOZ_ASSERT(thingp); | ||||
if (*thingp) js::gc::TraceExternalEdge(trc, thingp->unsafeGet(), name); | if (*thingp) { | ||||
js::gc::TraceExternalEdge(trc, thingp->unsafeGet(), name); | |||||
} | |||||
} | } | ||||
template <typename T> | template <typename T> | ||||
inline void TraceEdge(JSTracer* trc, JS::TenuredHeap<T>* thingp, | inline void TraceEdge(JSTracer* trc, JS::TenuredHeap<T>* thingp, | ||||
const char* name) { | const char* name) { | ||||
MOZ_ASSERT(thingp); | MOZ_ASSERT(thingp); | ||||
if (T ptr = thingp->unbarrieredGetPtr()) { | if (T ptr = thingp->unbarrieredGetPtr()) { | ||||
js::gc::TraceExternalEdge(trc, &ptr, name); | js::gc::TraceExternalEdge(trc, &ptr, name); | ||||
thingp->setPtr(ptr); | thingp->unbarrieredSetPtr(ptr); | ||||
} | } | ||||
} | } | ||||
// Edges that are always traced as part of root marking do not require | // Edges that are always traced as part of root marking do not require | ||||
// incremental barriers. This function allows for marking non-barriered | // incremental barriers. This function allows for marking non-barriered | ||||
// pointers, but asserts that this happens during root marking. | // pointers, but asserts that this happens during root marking. | ||||
// | // | ||||
// Note that while |edgep| must never be null, it is fine for |*edgep| to be | // Note that while |edgep| must never be null, it is fine for |*edgep| to be | ||||
// nullptr. | // nullptr. | ||||
template <typename T> | template <typename T> | ||||
extern JS_PUBLIC_API void UnsafeTraceRoot(JSTracer* trc, T* edgep, | extern JS_PUBLIC_API void UnsafeTraceRoot(JSTracer* trc, T* edgep, | ||||
const char* name); | const char* name); | ||||
extern JS_PUBLIC_API void TraceChildren(JSTracer* trc, GCCellPtr thing); | extern JS_PUBLIC_API void TraceChildren(JSTracer* trc, GCCellPtr thing); | ||||
using ZoneSet = | using ZoneSet = | ||||
js::HashSet<Zone*, js::DefaultHasher<Zone*>, js::SystemAllocPolicy>; | js::HashSet<Zone*, js::DefaultHasher<Zone*>, js::SystemAllocPolicy>; | ||||
using CompartmentSet = | using CompartmentSet = | ||||
js::HashSet<JSCompartment*, js::DefaultHasher<JSCompartment*>, | js::HashSet<JS::Compartment*, js::DefaultHasher<JS::Compartment*>, | ||||
js::SystemAllocPolicy>; | js::SystemAllocPolicy>; | ||||
/** | /** | ||||
* Trace every value within |compartments| that is wrapped by a | * Trace every value within |compartments| that is wrapped by a | ||||
* cross-compartment wrapper from a compartment that is not an element of | * cross-compartment wrapper from a compartment that is not an element of | ||||
* |compartments|. | * |compartments|. | ||||
*/ | */ | ||||
extern JS_PUBLIC_API void TraceIncomingCCWs( | extern JS_PUBLIC_API void TraceIncomingCCWs( | ||||
Show All 36 Lines |
Wildfire Games · Phabricator