2013-09-03 09:01:18 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
|
|
* vim: set ts=8 sts=4 et sw=4 tw=99:
|
|
|
|
* 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/. */
|
|
|
|
|
2014-04-12 02:19:05 +04:00
|
|
|
#ifndef js_TracingAPI_h
|
|
|
|
#define js_TracingAPI_h
|
2013-09-03 09:01:18 +04:00
|
|
|
|
2014-11-07 13:56:00 +03:00
|
|
|
#include "jsalloc.h"
|
2013-09-03 09:01:18 +04:00
|
|
|
|
2014-11-07 13:56:00 +03:00
|
|
|
#include "js/HashTable.h"
|
2015-06-11 20:03:33 +03:00
|
|
|
#include "js/HeapAPI.h"
|
|
|
|
#include "js/TraceKind.h"
|
2014-11-07 13:56:00 +03:00
|
|
|
|
2014-04-12 02:19:05 +04:00
|
|
|
class JS_PUBLIC_API(JSTracer);
|
2013-09-03 09:01:18 +04:00
|
|
|
|
|
|
|
namespace JS {
|
2015-02-26 00:11:37 +03:00
|
|
|
class JS_PUBLIC_API(CallbackTracer);
|
2013-09-03 09:01:18 +04:00
|
|
|
template <typename T> class Heap;
|
|
|
|
template <typename T> class TenuredHeap;
|
|
|
|
|
2014-12-02 01:49:07 +03:00
|
|
|
// Returns a static string equivalent of |kind|.
|
2015-03-29 01:22:11 +03:00
|
|
|
JS_FRIEND_API(const char*)
|
2015-05-22 20:40:24 +03:00
|
|
|
GCTraceKindToAscii(JS::TraceKind kind);
|
|
|
|
|
|
|
|
} // namespace JS
|
2014-12-02 01:49:07 +03:00
|
|
|
|
2013-09-03 09:01:18 +04:00
|
|
|
enum WeakMapTraceKind {
|
2015-08-13 02:55:40 +03:00
|
|
|
// Do true ephemeron marking with an iterative weak marking phase.
|
|
|
|
DoNotTraceWeakMaps,
|
|
|
|
|
|
|
|
// Do true ephemeron marking with a weak key lookup marking phase. This is
|
|
|
|
// expected to be constant for the lifetime of a JSTracer; it does not
|
|
|
|
// change when switching from "plain" marking to weak marking.
|
|
|
|
ExpandWeakMaps,
|
|
|
|
|
|
|
|
// Trace through to all values, irrespective of whether the keys are live
|
|
|
|
// or not. Used for non-marking tracers.
|
|
|
|
TraceWeakMapValues,
|
|
|
|
|
|
|
|
// Trace through to all keys and values, irrespective of whether the keys
|
|
|
|
// are live or not. Used for non-marking tracers.
|
|
|
|
TraceWeakMapKeysValues
|
2013-09-03 09:01:18 +04:00
|
|
|
};
|
|
|
|
|
2014-04-12 02:19:05 +04:00
|
|
|
class JS_PUBLIC_API(JSTracer)
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// Return the runtime set on the tracer.
|
2015-03-29 01:22:11 +03:00
|
|
|
JSRuntime* runtime() const { return runtime_; }
|
2014-04-12 02:19:05 +04:00
|
|
|
|
2015-08-13 02:55:40 +03:00
|
|
|
// Return the weak map tracing behavior currently set on this tracer.
|
|
|
|
WeakMapTraceKind weakMapAction() const { return weakMapAction_; }
|
2014-04-12 02:19:05 +04:00
|
|
|
|
2015-02-26 00:11:37 +03:00
|
|
|
// An intermediate state on the road from C to C++ style dispatch.
|
2015-05-05 03:36:31 +03:00
|
|
|
enum class TracerKindTag {
|
|
|
|
Marking,
|
2015-08-13 02:55:40 +03:00
|
|
|
WeakMarking, // In weak marking phase: looking up every marked obj/script.
|
2015-05-05 03:36:31 +03:00
|
|
|
Tenuring,
|
|
|
|
Callback
|
2015-02-26 00:11:37 +03:00
|
|
|
};
|
2015-08-13 02:55:40 +03:00
|
|
|
bool isMarkingTracer() const { return tag_ == TracerKindTag::Marking || tag_ == TracerKindTag::WeakMarking; }
|
|
|
|
bool isWeakMarkingTracer() const { return tag_ == TracerKindTag::WeakMarking; }
|
2015-05-05 03:36:31 +03:00
|
|
|
bool isTenuringTracer() const { return tag_ == TracerKindTag::Tenuring; }
|
|
|
|
bool isCallbackTracer() const { return tag_ == TracerKindTag::Callback; }
|
2015-03-29 01:22:11 +03:00
|
|
|
inline JS::CallbackTracer* asCallbackTracer();
|
2015-02-26 00:11:37 +03:00
|
|
|
|
|
|
|
protected:
|
2015-03-29 01:22:11 +03:00
|
|
|
JSTracer(JSRuntime* rt, TracerKindTag tag,
|
2015-04-29 20:23:24 +03:00
|
|
|
WeakMapTraceKind weakTraceKind = TraceWeakMapValues)
|
2015-08-13 02:55:40 +03:00
|
|
|
: runtime_(rt), weakMapAction_(weakTraceKind), tag_(tag)
|
2015-04-29 20:23:24 +03:00
|
|
|
{}
|
2013-09-03 09:01:18 +04:00
|
|
|
|
2014-04-12 02:19:05 +04:00
|
|
|
private:
|
2015-03-29 01:22:11 +03:00
|
|
|
JSRuntime* runtime_;
|
2015-08-13 02:55:40 +03:00
|
|
|
WeakMapTraceKind weakMapAction_;
|
|
|
|
|
|
|
|
protected:
|
2015-04-29 20:23:24 +03:00
|
|
|
TracerKindTag tag_;
|
2014-04-12 02:19:05 +04:00
|
|
|
};
|
2013-09-03 09:01:18 +04:00
|
|
|
|
2015-02-26 00:11:37 +03:00
|
|
|
namespace JS {
|
|
|
|
|
2015-04-10 23:33:56 +03:00
|
|
|
class AutoTracingName;
|
|
|
|
class AutoTracingIndex;
|
|
|
|
class AutoTracingCallback;
|
|
|
|
|
2015-02-26 00:11:37 +03:00
|
|
|
class JS_PUBLIC_API(CallbackTracer) : public JSTracer
|
|
|
|
{
|
|
|
|
public:
|
2015-05-29 02:35:08 +03:00
|
|
|
CallbackTracer(JSRuntime* rt, WeakMapTraceKind weakTraceKind = TraceWeakMapValues)
|
|
|
|
: JSTracer(rt, JSTracer::TracerKindTag::Callback, weakTraceKind),
|
2015-05-05 03:34:38 +03:00
|
|
|
contextName_(nullptr), contextIndex_(InvalidIndex), contextFunctor_(nullptr)
|
2015-02-26 00:11:37 +03:00
|
|
|
{}
|
|
|
|
|
2015-06-11 20:03:33 +03:00
|
|
|
// Override these methods to receive notification when an edge is visited
|
|
|
|
// with the type contained in the callback. The default implementation
|
|
|
|
// dispatches to the fully-generic onChild implementation, so for cases that
|
|
|
|
// do not care about boxing overhead and do not need the actual edges,
|
|
|
|
// just override the generic onChild.
|
|
|
|
virtual void onObjectEdge(JSObject** objp) { onChild(JS::GCCellPtr(*objp)); }
|
|
|
|
virtual void onStringEdge(JSString** strp) { onChild(JS::GCCellPtr(*strp)); }
|
|
|
|
virtual void onSymbolEdge(JS::Symbol** symp) { onChild(JS::GCCellPtr(*symp)); }
|
|
|
|
virtual void onScriptEdge(JSScript** scriptp) { onChild(JS::GCCellPtr(*scriptp)); }
|
|
|
|
virtual void onShapeEdge(js::Shape** shapep) {
|
|
|
|
onChild(JS::GCCellPtr(*shapep, JS::TraceKind::Shape));
|
|
|
|
}
|
|
|
|
virtual void onObjectGroupEdge(js::ObjectGroup** groupp) {
|
|
|
|
onChild(JS::GCCellPtr(*groupp, JS::TraceKind::ObjectGroup));
|
|
|
|
}
|
|
|
|
virtual void onBaseShapeEdge(js::BaseShape** basep) {
|
|
|
|
onChild(JS::GCCellPtr(*basep, JS::TraceKind::BaseShape));
|
|
|
|
}
|
|
|
|
virtual void onJitCodeEdge(js::jit::JitCode** codep) {
|
|
|
|
onChild(JS::GCCellPtr(*codep, JS::TraceKind::JitCode));
|
|
|
|
}
|
|
|
|
virtual void onLazyScriptEdge(js::LazyScript** lazyp) {
|
|
|
|
onChild(JS::GCCellPtr(*lazyp, JS::TraceKind::LazyScript));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Override this method to receive notification when a node in the GC
|
|
|
|
// heap graph is visited.
|
|
|
|
virtual void onChild(const JS::GCCellPtr& thing) = 0;
|
2015-02-26 00:11:37 +03:00
|
|
|
|
2015-04-10 23:33:56 +03:00
|
|
|
// Access to the tracing context:
|
|
|
|
// When tracing with a JS::CallbackTracer, we invoke the callback with the
|
|
|
|
// edge location and the type of target. This is useful for operating on
|
|
|
|
// the edge in the abstract or on the target thing, satisfying most common
|
|
|
|
// use cases. However, some tracers need additional detail about the
|
|
|
|
// specific edge that is being traced in order to be useful. Unfortunately,
|
|
|
|
// the raw pointer to the edge that we provide is not enough information to
|
|
|
|
// infer much of anything useful about that edge.
|
|
|
|
//
|
|
|
|
// In order to better support use cases that care in particular about edges
|
|
|
|
// -- as opposed to the target thing -- tracing implementations are
|
|
|
|
// responsible for providing extra context information about each edge they
|
|
|
|
// trace, as it is traced. This contains, at a minimum, an edge name and,
|
|
|
|
// when tracing an array, the index. Further specialization can be achived
|
|
|
|
// (with some complexity), by associating a functor with the tracer so
|
|
|
|
// that, when requested, the user can generate totally custom edge
|
|
|
|
// descriptions.
|
|
|
|
|
|
|
|
// Returns the current edge's name. It is only valid to call this when
|
|
|
|
// inside the trace callback, however, the edge name will always be set.
|
|
|
|
const char* contextName() const { MOZ_ASSERT(contextName_); return contextName_; }
|
|
|
|
|
|
|
|
// Returns the current edge's index, if marked as part of an array of edges.
|
|
|
|
// This must be called only inside the trace callback. When not tracing an
|
|
|
|
// array, the value will be InvalidIndex.
|
|
|
|
const static size_t InvalidIndex = size_t(-1);
|
|
|
|
size_t contextIndex() const { return contextIndex_; }
|
|
|
|
|
|
|
|
// Build a description of this edge in the heap graph. This call may invoke
|
|
|
|
// the context functor, if set, which may inspect arbitrary areas of the
|
|
|
|
// heap. On the other hand, the description provided by this method may be
|
|
|
|
// substantially more accurate and useful than those provided by only the
|
|
|
|
// contextName and contextIndex.
|
2015-04-28 20:28:56 +03:00
|
|
|
void getTracingEdgeName(char* buffer, size_t bufferSize);
|
2015-04-10 23:33:56 +03:00
|
|
|
|
|
|
|
// The trace implementation may associate a callback with one or more edges
|
|
|
|
// using AutoTracingDetails. This functor is called by getTracingEdgeName
|
|
|
|
// and is responsible for providing a textual representation of the
|
|
|
|
// currently being traced edge. The callback has access to the full heap,
|
|
|
|
// including the currently set tracing context.
|
|
|
|
class ContextFunctor {
|
|
|
|
public:
|
|
|
|
virtual void operator()(CallbackTracer* trc, char* buf, size_t bufsize) = 0;
|
|
|
|
};
|
|
|
|
|
2015-05-29 02:35:08 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
enum class TracerKind { DoNotCare, Moving, GrayBuffering, VerifyTraceProtoAndIface };
|
|
|
|
virtual TracerKind getTracerKind() const { return TracerKind::DoNotCare; }
|
|
|
|
#endif
|
2015-04-10 23:33:56 +03:00
|
|
|
|
2015-06-11 20:03:33 +03:00
|
|
|
// 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
|
|
|
|
// methods have to have distinct names to allow us to override them
|
|
|
|
// individually, which is freqently useful if, for example, we only want to
|
|
|
|
// process only one type of edge.
|
|
|
|
void dispatchToOnEdge(JSObject** objp) { onObjectEdge(objp); }
|
|
|
|
void dispatchToOnEdge(JSString** strp) { onStringEdge(strp); }
|
|
|
|
void dispatchToOnEdge(JS::Symbol** symp) { onSymbolEdge(symp); }
|
|
|
|
void dispatchToOnEdge(JSScript** scriptp) { onScriptEdge(scriptp); }
|
|
|
|
void dispatchToOnEdge(js::Shape** shapep) { onShapeEdge(shapep); }
|
|
|
|
void dispatchToOnEdge(js::ObjectGroup** groupp) { onObjectGroupEdge(groupp); }
|
|
|
|
void dispatchToOnEdge(js::BaseShape** basep) { onBaseShapeEdge(basep); }
|
|
|
|
void dispatchToOnEdge(js::jit::JitCode** codep) { onJitCodeEdge(codep); }
|
|
|
|
void dispatchToOnEdge(js::LazyScript** lazyp) { onLazyScriptEdge(lazyp); }
|
|
|
|
|
2015-05-29 02:35:08 +03:00
|
|
|
private:
|
2015-04-10 23:33:56 +03:00
|
|
|
friend class AutoTracingName;
|
|
|
|
const char* contextName_;
|
|
|
|
|
|
|
|
friend class AutoTracingIndex;
|
|
|
|
size_t contextIndex_;
|
|
|
|
|
|
|
|
friend class AutoTracingDetails;
|
|
|
|
ContextFunctor* contextFunctor_;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Set the name portion of the tracer's context for the current edge.
|
|
|
|
class AutoTracingName
|
|
|
|
{
|
|
|
|
CallbackTracer* trc_;
|
2015-04-23 13:22:36 +03:00
|
|
|
const char* prior_;
|
2015-04-10 23:33:56 +03:00
|
|
|
|
|
|
|
public:
|
|
|
|
AutoTracingName(CallbackTracer* trc, const char* name) : trc_(trc), prior_(trc->contextName_) {
|
|
|
|
MOZ_ASSERT(name);
|
|
|
|
trc->contextName_ = name;
|
|
|
|
}
|
|
|
|
~AutoTracingName() {
|
|
|
|
MOZ_ASSERT(trc_->contextName_);
|
|
|
|
trc_->contextName_ = prior_;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// Set the index portion of the tracer's context for the current range.
|
|
|
|
class AutoTracingIndex
|
|
|
|
{
|
|
|
|
CallbackTracer* trc_;
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit AutoTracingIndex(JSTracer* trc, size_t initial = 0) : trc_(nullptr) {
|
|
|
|
if (trc->isCallbackTracer()) {
|
|
|
|
trc_ = trc->asCallbackTracer();
|
|
|
|
MOZ_ASSERT(trc_->contextIndex_ == CallbackTracer::InvalidIndex);
|
|
|
|
trc_->contextIndex_ = initial;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
~AutoTracingIndex() {
|
|
|
|
if (trc_) {
|
|
|
|
MOZ_ASSERT(trc_->contextIndex_ != CallbackTracer::InvalidIndex);
|
|
|
|
trc_->contextIndex_ = CallbackTracer::InvalidIndex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void operator++() {
|
|
|
|
if (trc_) {
|
|
|
|
MOZ_ASSERT(trc_->contextIndex_ != CallbackTracer::InvalidIndex);
|
|
|
|
++trc_->contextIndex_;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// Set a context callback for the trace callback to use, if it needs a detailed
|
|
|
|
// edge description.
|
|
|
|
class AutoTracingDetails
|
|
|
|
{
|
|
|
|
CallbackTracer* trc_;
|
|
|
|
|
|
|
|
public:
|
|
|
|
AutoTracingDetails(JSTracer* trc, CallbackTracer::ContextFunctor& func) : trc_(nullptr) {
|
|
|
|
if (trc->isCallbackTracer()) {
|
|
|
|
trc_ = trc->asCallbackTracer();
|
|
|
|
MOZ_ASSERT(trc_->contextFunctor_ == nullptr);
|
|
|
|
trc_->contextFunctor_ = &func;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
~AutoTracingDetails() {
|
|
|
|
if (trc_) {
|
|
|
|
MOZ_ASSERT(trc_->contextFunctor_);
|
|
|
|
trc_->contextFunctor_ = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-02-26 00:11:37 +03:00
|
|
|
} // namespace JS
|
|
|
|
|
2015-03-29 01:22:11 +03:00
|
|
|
JS::CallbackTracer*
|
2015-02-26 00:11:37 +03:00
|
|
|
JSTracer::asCallbackTracer()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(isCallbackTracer());
|
2015-03-29 01:22:11 +03:00
|
|
|
return static_cast<JS::CallbackTracer*>(this);
|
2015-02-26 00:11:37 +03:00
|
|
|
}
|
|
|
|
|
2013-09-03 09:01:18 +04:00
|
|
|
// The JS_Call*Tracer family of functions traces the given GC thing reference.
|
|
|
|
// This performs the tracing action configured on the given JSTracer:
|
|
|
|
// typically calling the JSTracer::callback or marking the thing as live.
|
|
|
|
//
|
|
|
|
// The argument to JS_Call*Tracer is an in-out param: when the function
|
|
|
|
// returns, the garbage collector might have moved the GC thing. In this case,
|
|
|
|
// the reference passed to JS_Call*Tracer will be updated to the object's new
|
|
|
|
// location. Callers of this method are responsible for updating any state
|
|
|
|
// that is dependent on the object's address. For example, if the object's
|
|
|
|
// address is used as a key in a hashtable, then the object must be removed
|
|
|
|
// and re-inserted with the correct hash.
|
|
|
|
//
|
|
|
|
extern JS_PUBLIC_API(void)
|
2015-03-29 01:22:11 +03:00
|
|
|
JS_CallValueTracer(JSTracer* trc, JS::Heap<JS::Value>* valuep, const char* name);
|
2013-09-03 09:01:18 +04:00
|
|
|
|
|
|
|
extern JS_PUBLIC_API(void)
|
2015-03-29 01:22:11 +03:00
|
|
|
JS_CallIdTracer(JSTracer* trc, JS::Heap<jsid>* idp, const char* name);
|
2013-09-03 09:01:18 +04:00
|
|
|
|
|
|
|
extern JS_PUBLIC_API(void)
|
2015-03-29 01:22:11 +03:00
|
|
|
JS_CallObjectTracer(JSTracer* trc, JS::Heap<JSObject*>* objp, const char* name);
|
2013-09-03 09:01:18 +04:00
|
|
|
|
|
|
|
extern JS_PUBLIC_API(void)
|
2015-03-29 01:22:11 +03:00
|
|
|
JS_CallStringTracer(JSTracer* trc, JS::Heap<JSString*>* strp, const char* name);
|
2013-09-03 09:01:18 +04:00
|
|
|
|
|
|
|
extern JS_PUBLIC_API(void)
|
2015-03-29 01:22:11 +03:00
|
|
|
JS_CallScriptTracer(JSTracer* trc, JS::Heap<JSScript*>* scriptp, const char* name);
|
2013-09-03 09:01:18 +04:00
|
|
|
|
|
|
|
extern JS_PUBLIC_API(void)
|
2015-03-29 01:22:11 +03:00
|
|
|
JS_CallFunctionTracer(JSTracer* trc, JS::Heap<JSFunction*>* funp, const char* name);
|
2013-09-03 09:01:18 +04:00
|
|
|
|
2014-08-13 13:05:22 +04:00
|
|
|
// The following JS_CallUnbarriered*Tracer functions should only be called where
|
|
|
|
// you know for sure that a heap post barrier is not required. Use with extreme
|
|
|
|
// caution!
|
2013-09-03 09:01:18 +04:00
|
|
|
extern JS_PUBLIC_API(void)
|
2015-03-29 01:22:11 +03:00
|
|
|
JS_CallUnbarrieredValueTracer(JSTracer* trc, JS::Value* valuep, const char* name);
|
2013-09-03 09:01:18 +04:00
|
|
|
|
|
|
|
extern JS_PUBLIC_API(void)
|
2015-03-29 01:22:11 +03:00
|
|
|
JS_CallUnbarrieredIdTracer(JSTracer* trc, jsid* idp, const char* name);
|
2013-09-03 09:01:18 +04:00
|
|
|
|
|
|
|
extern JS_PUBLIC_API(void)
|
2015-03-29 01:22:11 +03:00
|
|
|
JS_CallUnbarrieredObjectTracer(JSTracer* trc, JSObject** objp, const char* name);
|
2013-09-03 09:01:18 +04:00
|
|
|
|
|
|
|
extern JS_PUBLIC_API(void)
|
2015-03-29 01:22:11 +03:00
|
|
|
JS_CallUnbarrieredStringTracer(JSTracer* trc, JSString** strp, const char* name);
|
2013-09-03 09:01:18 +04:00
|
|
|
|
2014-01-08 04:53:17 +04:00
|
|
|
extern JS_PUBLIC_API(void)
|
2015-03-29 01:22:11 +03:00
|
|
|
JS_CallUnbarrieredScriptTracer(JSTracer* trc, JSScript** scriptp, const char* name);
|
2014-01-08 04:53:17 +04:00
|
|
|
|
2013-09-03 09:01:18 +04:00
|
|
|
template <typename HashSetEnum>
|
|
|
|
inline void
|
2015-03-29 01:22:11 +03:00
|
|
|
JS_CallHashSetObjectTracer(JSTracer* trc, HashSetEnum& e, JSObject* const& key, const char* name)
|
2013-09-03 09:01:18 +04:00
|
|
|
{
|
2015-03-29 01:22:11 +03:00
|
|
|
JSObject* updated = key;
|
2014-08-13 13:05:22 +04:00
|
|
|
JS_CallUnbarrieredObjectTracer(trc, &updated, name);
|
2013-09-03 09:01:18 +04:00
|
|
|
if (updated != key)
|
2014-11-14 12:22:26 +03:00
|
|
|
e.rekeyFront(updated);
|
2013-09-03 09:01:18 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Trace an object that is known to always be tenured. No post barriers are
|
|
|
|
// required in this case.
|
|
|
|
extern JS_PUBLIC_API(void)
|
2015-03-29 01:22:11 +03:00
|
|
|
JS_CallTenuredObjectTracer(JSTracer* trc, JS::TenuredHeap<JSObject*>* objp, const char* name);
|
2013-09-03 09:01:18 +04:00
|
|
|
|
|
|
|
extern JS_PUBLIC_API(void)
|
2015-05-22 20:40:24 +03:00
|
|
|
JS_TraceChildren(JSTracer* trc, void* thing, JS::TraceKind kind);
|
2013-09-03 09:01:18 +04:00
|
|
|
|
|
|
|
extern JS_PUBLIC_API(void)
|
2015-03-29 01:22:11 +03:00
|
|
|
JS_TraceRuntime(JSTracer* trc);
|
2013-09-03 09:01:18 +04:00
|
|
|
|
2014-11-07 13:56:00 +03:00
|
|
|
namespace JS {
|
2015-03-29 01:22:11 +03:00
|
|
|
typedef js::HashSet<Zone*, js::DefaultHasher<Zone*>, js::SystemAllocPolicy> ZoneSet;
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace JS
|
2014-11-07 13:56:00 +03:00
|
|
|
|
|
|
|
// Trace every value within |zones| that is wrapped by a cross-compartment
|
|
|
|
// wrapper from a zone that is not an element of |zones|.
|
|
|
|
extern JS_PUBLIC_API(void)
|
2015-03-29 01:22:11 +03:00
|
|
|
JS_TraceIncomingCCWs(JSTracer* trc, const JS::ZoneSet& zones);
|
2014-11-07 13:56:00 +03:00
|
|
|
|
2013-09-03 09:01:18 +04:00
|
|
|
extern JS_PUBLIC_API(void)
|
2015-03-29 01:22:11 +03:00
|
|
|
JS_GetTraceThingInfo(char* buf, size_t bufsize, JSTracer* trc,
|
2015-05-22 20:40:24 +03:00
|
|
|
void* thing, JS::TraceKind kind, bool includeDetails);
|
2013-09-03 09:01:18 +04:00
|
|
|
|
2015-08-05 21:02:00 +03:00
|
|
|
namespace js {
|
|
|
|
|
|
|
|
// Automates static dispatch for tracing for TraceableContainers.
|
|
|
|
template <typename, typename=void> struct DefaultTracer;
|
|
|
|
|
|
|
|
// The default for POD, non-pointer types is to do nothing.
|
|
|
|
template <typename T>
|
|
|
|
struct DefaultTracer<T, typename mozilla::EnableIf<!mozilla::IsPointer<T>::value &&
|
|
|
|
mozilla::IsPod<T>::value>::Type> {
|
|
|
|
static void trace(JSTracer* trc, T* t, const char* name) {
|
|
|
|
MOZ_ASSERT(mozilla::IsPod<T>::value);
|
|
|
|
MOZ_ASSERT(!mozilla::IsPointer<T>::value);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// The default for non-pod (e.g. struct) types is to call the trace method.
|
|
|
|
template <typename T>
|
|
|
|
struct DefaultTracer<T, typename mozilla::EnableIf<!mozilla::IsPod<T>::value>::Type> {
|
|
|
|
static void trace(JSTracer* trc, T* t, const char* name) {
|
|
|
|
t->trace(trc);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct DefaultTracer<jsid>
|
|
|
|
{
|
|
|
|
static void trace(JSTracer* trc, jsid* id, const char* name) {
|
|
|
|
JS_CallUnbarrieredIdTracer(trc, id, name);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace js
|
|
|
|
|
2014-04-12 02:19:05 +04:00
|
|
|
#endif /* js_TracingAPI_h */
|