Files
palemoon27/xpcom/glue/nsCycleCollectionParticipant.cpp
T
roytam1 6885f7ffc2 import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1185749 - Implement a DynamicTraceable HashMap subclass that can be used with Rooted; r=jonco (3f84bdb30)
- Bug 1186609 - Implement a DynamicTraceable Vector subclass for use with Rooted; r=sfink (fa5b47e5b)
- Bug 1155985 - Set FieldInto::mType just before storing to reserved slot. r=jonco, a=abillings (34dbc3ca0)
- Bug 1156295 - Refactor GC rooting in StructType::DefineInternal() r=terrence (ec40a1701)
- Bug 1185755 - Use Rooted to simplify FieldInfoHash rooting; r=jonco (8dc66d7cd)
- Bug 1189072 - Make DefaultTracer for struct types call T::trace; r=fitzgen (96f79bc6f)
- Bug 1149294 - Part 1: Don't trace permanent atoms and well known symbols that are owned by a parent JSRuntime inside SimpeEdgeVectorTracer; r=terrence (7ce049a33)
- Bug 1149294 - Part 2: expose ChromeUtils and HeapSnapshot to workers; r=bholley (5737cd923)
- Bug 1147679 - Use PR_GetFileInfo64 when deserializing heap snapshots; r=jimb (1ce8cd241)
- Bug 1147680 - Use PR_MemMap when deserializing heap snapshots; r=jimb (04e5a370d)
- Bug 1149294 - Part 3: Split thread-safe methods on ChromeUtils out in to a new (4967637e2)
- Bug 1173829. Fix some compile issues in code generated by bindings codegen for non-concrete interfaces. r=peterv (3e0f93640)
- Bug 1170274 - A better string parser for nsGenericHTMLElement::GetURIListAttr, r=ehsan (8c1595d29)
- Bug 1170274 - patch 2 - A better string parser for nsGenericHTMLElement::GetURIListAttr, r=ehsan CLOSED TREE (5626d631f)
- Bug 1096550 - Update content scale when swapping remote tabs between windows. r=roc. (ed974edf4)
- Bug 1180017: Give GCCellPtr is<T> and as<T> methods, replacing isFoo and toFoo methods. Fix callers. r=terrence (b95645bbb)
- pointer style (a46b905fe)
- pointer style (cb548fd44)
- Bug 1151182 - Fix type for JSOP_THROWMSG documentation comment. r=efaust (f9bce9df7)
- Bug 1077318 - Part 2: Fix the order of include in AsmJSModule.cpp. r=evilpie (a61716e33)
- Bug 1155006: Fix unified build sensitivities in js/src. r=shu (b0f166ec9)
- Bug 988463 - Add in support for tracelogging on ARM. r=h4writer (10345729b)
- Bug 1190077 - Move RDTSC and prmjtime.* to vm/Time.*. r=nbp (b72c1f366)
2021-04-27 09:19:42 +08:00

130 lines
3.6 KiB
C++

/* -*- 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/. */
#include "nsCycleCollectionParticipant.h"
#include "mozilla/CycleCollectedJSRuntime.h"
#include "nsCOMPtr.h"
#include "jsapi.h"
#include "jsfriendapi.h"
#ifdef MOZILLA_INTERNAL_API
#include "nsString.h"
#else
#include "nsStringAPI.h"
#endif
void
nsScriptObjectTracer::NoteJSChild(JS::GCCellPtr aGCThing, const char* aName,
void* aClosure)
{
nsCycleCollectionTraversalCallback* cb =
static_cast<nsCycleCollectionTraversalCallback*>(aClosure);
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(*cb, aName);
if (aGCThing.is<JSObject>()) {
cb->NoteJSObject(&aGCThing.as<JSObject>());
} else if (aGCThing.is<JSScript>()) {
cb->NoteJSScript(&aGCThing.as<JSScript>());
} else {
MOZ_ASSERT(!mozilla::AddToCCKind(aGCThing.kind()));
}
}
NS_IMETHODIMP_(void)
nsXPCOMCycleCollectionParticipant::Root(void* aPtr)
{
nsISupports* s = static_cast<nsISupports*>(aPtr);
NS_ADDREF(s);
}
NS_IMETHODIMP_(void)
nsXPCOMCycleCollectionParticipant::Unroot(void* aPtr)
{
nsISupports* s = static_cast<nsISupports*>(aPtr);
NS_RELEASE(s);
}
// We define a default trace function because some participants don't need
// to trace anything, so it is okay for them not to define one.
NS_IMETHODIMP_(void)
nsXPCOMCycleCollectionParticipant::Trace(void* aPtr, const TraceCallbacks& aCb,
void* aClosure)
{
}
bool
nsXPCOMCycleCollectionParticipant::CheckForRightISupports(nsISupports* aSupports)
{
nsISupports* foo;
aSupports->QueryInterface(NS_GET_IID(nsCycleCollectionISupports),
reinterpret_cast<void**>(&foo));
return aSupports == foo;
}
void
CycleCollectionNoteEdgeNameImpl(nsCycleCollectionTraversalCallback& aCallback,
const char* aName,
uint32_t aFlags)
{
nsAutoCString arrayEdgeName(aName);
if (aFlags & CycleCollectionEdgeNameArrayFlag) {
arrayEdgeName.AppendLiteral("[i]");
}
aCallback.NoteNextEdgeName(arrayEdgeName.get());
}
void
TraceCallbackFunc::Trace(JS::Heap<JS::Value>* aPtr, const char* aName,
void* aClosure) const
{
if (aPtr->isMarkable()) {
mCallback(JS::GCCellPtr(*aPtr), aName, aClosure);
}
}
void
TraceCallbackFunc::Trace(JS::Heap<jsid>* aPtr, const char* aName,
void* aClosure) const
{
if (JSID_IS_GCTHING(*aPtr)) {
mCallback(JSID_TO_GCTHING(*aPtr), aName, aClosure);
}
}
void
TraceCallbackFunc::Trace(JS::Heap<JSObject*>* aPtr, const char* aName,
void* aClosure) const
{
mCallback(JS::GCCellPtr(aPtr->get()), aName, aClosure);
}
void
TraceCallbackFunc::Trace(JS::TenuredHeap<JSObject*>* aPtr, const char* aName,
void* aClosure) const
{
mCallback(JS::GCCellPtr(aPtr->getPtr()), aName, aClosure);
}
void
TraceCallbackFunc::Trace(JS::Heap<JSFunction*>* aPtr, const char* aName,
void* aClosure) const
{
mCallback(JS::GCCellPtr(aPtr->get()), aName, aClosure);
}
void
TraceCallbackFunc::Trace(JS::Heap<JSString*>* aPtr, const char* aName,
void* aClosure) const
{
mCallback(JS::GCCellPtr(aPtr->get()), aName, aClosure);
}
void
TraceCallbackFunc::Trace(JS::Heap<JSScript*>* aPtr, const char* aName,
void* aClosure) const
{
mCallback(JS::GCCellPtr(aPtr->get()), aName, aClosure);
}