Bug 1258314 - Use TraceNullableEdge where appropriate throughout the engine r=terrence

This commit is contained in:
Jon Coppeard 2016-03-23 09:41:17 +00:00
parent a96e801d60
commit 3342e15fa9
18 changed files with 52 additions and 112 deletions

View File

@ -908,13 +908,10 @@ Module::~Module()
/* virtual */ void
Module::trace(JSTracer* trc)
{
for (const Import& import : imports()) {
if (importToExit(import).fun)
TraceEdge(trc, &importToExit(import).fun, "wasm function import");
}
for (const Import& import : imports())
TraceNullableEdge(trc, &importToExit(import).fun, "wasm function import");
if (heap_)
TraceEdge(trc, &heap_, "wasm buffer");
TraceNullableEdge(trc, &heap_, "wasm buffer");
MOZ_ASSERT(ownerObject_);
TraceEdge(trc, &ownerObject_, "wasm owner object");

View File

@ -2943,16 +2943,14 @@ MemoryTracingVisitor::visitReference(ReferenceTypeDescr& descr, uint8_t* mem)
case ReferenceTypeDescr::TYPE_OBJECT:
{
HeapPtrObject* objectPtr = reinterpret_cast<js::HeapPtrObject*>(mem);
if (*objectPtr)
TraceEdge(trace_, objectPtr, "reference-obj");
TraceNullableEdge(trace_, objectPtr, "reference-obj");
return;
}
case ReferenceTypeDescr::TYPE_STRING:
{
HeapPtrString* stringPtr = reinterpret_cast<js::HeapPtrString*>(mem);
if (*stringPtr)
TraceEdge(trace_, stringPtr, "reference-str");
TraceNullableEdge(trace_, stringPtr, "reference-str");
return;
}
}

View File

@ -1284,10 +1284,8 @@ class ICSetElem_DenseOrUnboxedArrayAddImpl : public ICSetElem_DenseOrUnboxedArra
public:
void traceShapes(JSTracer* trc) {
for (size_t i = 0; i < NumShapes; i++) {
if (shapes_[i])
TraceEdge(trc, &shapes_[i], "baseline-setelem-denseadd-stub-shape");
}
for (size_t i = 0; i < NumShapes; i++)
TraceNullableEdge(trc, &shapes_[i], "baseline-setelem-denseadd-stub-shape");
}
Shape* shape(size_t i) const {
MOZ_ASSERT(i < NumShapes);

View File

@ -456,8 +456,7 @@ void
BaselineScript::trace(JSTracer* trc)
{
TraceEdge(trc, &method_, "baseline-method");
if (templateScope_)
TraceEdge(trc, &templateScope_, "baseline-template-scope");
TraceNullableEdge(trc, &templateScope_, "baseline-template-scope");
// Mark all IC stub codes hanging off the IC stub entries.
for (size_t i = 0; i < numICEntries(); i++) {

View File

@ -187,21 +187,18 @@ ICStub::trace(JSTracer* trc)
case ICStub::Call_Scripted: {
ICCall_Scripted* callStub = toCall_Scripted();
TraceEdge(trc, &callStub->callee(), "baseline-callscripted-callee");
if (callStub->templateObject())
TraceEdge(trc, &callStub->templateObject(), "baseline-callscripted-template");
TraceNullableEdge(trc, &callStub->templateObject(), "baseline-callscripted-template");
break;
}
case ICStub::Call_Native: {
ICCall_Native* callStub = toCall_Native();
TraceEdge(trc, &callStub->callee(), "baseline-callnative-callee");
if (callStub->templateObject())
TraceEdge(trc, &callStub->templateObject(), "baseline-callnative-template");
TraceNullableEdge(trc, &callStub->templateObject(), "baseline-callnative-template");
break;
}
case ICStub::Call_ClassHook: {
ICCall_ClassHook* callStub = toCall_ClassHook();
if (callStub->templateObject())
TraceEdge(trc, &callStub->templateObject(), "baseline-callclasshook-template");
TraceNullableEdge(trc, &callStub->templateObject(), "baseline-callclasshook-template");
break;
}
case ICStub::Call_StringSplit: {
@ -285,8 +282,7 @@ ICStub::trace(JSTracer* trc)
}
case ICStub::SetElem_DenseOrUnboxedArray: {
ICSetElem_DenseOrUnboxedArray* setElemStub = toSetElem_DenseOrUnboxedArray();
if (setElemStub->shape())
TraceEdge(trc, &setElemStub->shape(), "baseline-getelem-dense-shape");
TraceNullableEdge(trc, &setElemStub->shape(), "baseline-getelem-dense-shape");
TraceEdge(trc, &setElemStub->group(), "baseline-setelem-dense-group");
break;
}
@ -425,10 +421,8 @@ ICStub::trace(JSTracer* trc)
else
propStub = toGetProp_CallDOMProxyWithGenerationNative();
propStub->receiverGuard().trace(trc);
if (propStub->expandoShape()) {
TraceEdge(trc, &propStub->expandoShape(),
"baseline-getproplistbasenative-stub-expandoshape");
}
TraceNullableEdge(trc, &propStub->expandoShape(),
"baseline-getproplistbasenative-stub-expandoshape");
TraceEdge(trc, &propStub->holder(), "baseline-getproplistbasenative-stub-holder");
TraceEdge(trc, &propStub->holderShape(), "baseline-getproplistbasenative-stub-holdershape");
TraceEdge(trc, &propStub->getter(), "baseline-getproplistbasenative-stub-getter");
@ -481,8 +475,7 @@ ICStub::trace(JSTracer* trc)
ICSetProp_NativeAdd* propStub = toSetProp_NativeAdd();
TraceEdge(trc, &propStub->group(), "baseline-setpropnativeadd-stub-group");
TraceEdge(trc, &propStub->newShape(), "baseline-setpropnativeadd-stub-newshape");
if (propStub->newGroup())
TraceEdge(trc, &propStub->newGroup(), "baseline-setpropnativeadd-stub-new-group");
TraceNullableEdge(trc, &propStub->newGroup(), "baseline-setpropnativeadd-stub-new-group");
JS_STATIC_ASSERT(ICSetProp_NativeAdd::MAX_PROTO_CHAIN_DEPTH == 4);
switch (propStub->protoChainDepth()) {
case 0: propStub->toImpl<0>()->traceShapes(trc); break;
@ -529,15 +522,13 @@ ICStub::trace(JSTracer* trc)
}
case ICStub::NewArray_Fallback: {
ICNewArray_Fallback* stub = toNewArray_Fallback();
if (stub->templateObject())
TraceEdge(trc, &stub->templateObject(), "baseline-newarray-template");
TraceNullableEdge(trc, &stub->templateObject(), "baseline-newarray-template");
TraceEdge(trc, &stub->templateGroup(), "baseline-newarray-template-group");
break;
}
case ICStub::NewObject_Fallback: {
ICNewObject_Fallback* stub = toNewObject_Fallback();
if (stub->templateObject())
TraceEdge(trc, &stub->templateObject(), "baseline-newobject-template");
TraceNullableEdge(trc, &stub->templateObject(), "baseline-newobject-template");
break;
}
case ICStub::Rest_Fallback: {

View File

@ -51,10 +51,8 @@ struct MyContainer
MyContainer() : obj(nullptr), str(nullptr) {}
void trace(JSTracer* trc) {
if (obj)
js::TraceEdge(trc, &obj, "test container");
if (str)
js::TraceEdge(trc, &str, "test container");
js::TraceNullableEdge(trc, &obj, "test container");
js::TraceNullableEdge(trc, &str, "test container");
}
};

View File

@ -700,8 +700,7 @@ JSFunction::trace(JSTracer* trc)
(HeapValue*)toExtended()->extendedSlots, "nativeReserved");
}
if (atom_)
TraceEdge(trc, &atom_, "atom");
TraceNullableEdge(trc, &atom_, "atom");
if (isInterpreted()) {
// Functions can be be marked as interpreted despite having no script

View File

@ -57,8 +57,7 @@ NativeIterator::mark(JSTracer* trc)
{
for (HeapPtrFlatString* str = begin(); str < end(); str++)
TraceEdge(trc, str, "prop");
if (obj)
TraceEdge(trc, &obj, "obj");
TraceNullableEdge(trc, &obj, "obj");
for (size_t i = 0; i < guard_length; i++)
guard_array[i].trace(trc);

View File

@ -346,8 +346,7 @@ Binding::trace(JSTracer* trc)
void
Bindings::trace(JSTracer* trc)
{
if (callObjShape_)
TraceEdge(trc, &callObjShape_, "callObjShape");
TraceNullableEdge(trc, &callObjShape_, "callObjShape");
/*
* As the comment in Bindings explains, bindingsArray may point into freed
@ -3966,10 +3965,8 @@ JSScript::traceChildren(JSTracer* trc)
zone()->isCollecting());
if (atoms) {
for (uint32_t i = 0; i < natoms(); ++i) {
if (atoms[i])
TraceEdge(trc, &atoms[i], "atom");
}
for (uint32_t i = 0; i < natoms(); ++i)
TraceNullableEdge(trc, &atoms[i], "atom");
}
if (hasObjects()) {
@ -3982,19 +3979,13 @@ JSScript::traceChildren(JSTracer* trc)
TraceRange(trc, constarray->length, constarray->vector, "consts");
}
if (sourceObject()) {
MOZ_ASSERT(MaybeForwarded(sourceObject())->compartment() == compartment());
TraceEdge(trc, &sourceObject_, "sourceObject");
}
MOZ_ASSERT_IF(sourceObject(), MaybeForwarded(sourceObject())->compartment() == compartment());
TraceNullableEdge(trc, &sourceObject_, "sourceObject");
if (functionNonDelazifying())
TraceEdge(trc, &function_, "function");
TraceNullableEdge(trc, &function_, "function");
TraceNullableEdge(trc, &module_, "module");
if (module_)
TraceEdge(trc, &module_, "module");
if (enclosingStaticScope_)
TraceEdge(trc, &enclosingStaticScope_, "enclosingStaticScope");
TraceNullableEdge(trc, &enclosingStaticScope_, "enclosingStaticScope");
if (maybeLazyScript())
TraceManuallyBarrieredEdge(trc, &lazyScript, "lazyScript");

View File

@ -48,8 +48,7 @@ WeakMapBase::markAll(JS::Zone* zone, JSTracer* tracer)
MOZ_ASSERT(tracer->weakMapAction() != DoNotTraceWeakMaps);
for (WeakMapBase* m : zone->gcWeakMapList) {
m->trace(tracer);
if (m->memberOf)
TraceEdge(tracer, &m->memberOf, "memberOf");
TraceNullableEdge(tracer, &m->memberOf, "memberOf");
}
}

View File

@ -2767,8 +2767,7 @@ Debugger::traceObject(JSTracer* trc, JSObject* obj)
void
Debugger::trace(JSTracer* trc)
{
if (uncaughtExceptionHook)
TraceEdge(trc, &uncaughtExceptionHook, "hooks");
TraceNullableEdge(trc, &uncaughtExceptionHook, "hooks");
/*
* Mark Debugger.Frame objects. These are all reachable from JS, because the

View File

@ -338,10 +338,8 @@ class Debugger : private mozilla::LinkedListElement<Debugger>
bool inNursery;
void trace(JSTracer* trc) {
if (frame)
TraceEdge(trc, &frame, "Debugger::AllocationsLogEntry::frame");
if (ctorName)
TraceEdge(trc, &ctorName, "Debugger::AllocationsLogEntry::ctorName");
TraceNullableEdge(trc, &frame, "Debugger::AllocationsLogEntry::frame");
TraceNullableEdge(trc, &ctorName, "Debugger::AllocationsLogEntry::ctorName");
}
};

View File

@ -61,8 +61,6 @@ HeapReceiverGuard::keyBits(JSObject* obj)
void
HeapReceiverGuard::trace(JSTracer* trc)
{
if (shape_)
TraceEdge(trc, &shape_, "receiver_guard_shape");
if (group_)
TraceEdge(trc, &group_, "receiver_guard_group");
TraceNullableEdge(trc, &shape_, "receiver_guard_shape");
TraceNullableEdge(trc, &group_, "receiver_guard_group");
}

View File

@ -498,13 +498,11 @@ RegExpShared::trace(JSTracer* trc)
if (trc->isMarkingTracer())
marked_ = true;
if (source)
TraceEdge(trc, &source, "RegExpShared source");
TraceNullableEdge(trc, &source, "RegExpShared source");
for (size_t i = 0; i < ArrayLength(compilationArray); i++) {
RegExpCompilation& compilation = compilationArray[i];
if (compilation.jitCode)
TraceEdge(trc, &compilation.jitCode, "RegExpShared code");
TraceNullableEdge(trc, &compilation.jitCode, "RegExpShared code");
}
}

View File

@ -93,12 +93,9 @@ class RegExpStatics
* Changes to this function must also be reflected in
* RegExpStatics::AutoRooter::trace().
*/
if (matchesInput)
TraceEdge(trc, &matchesInput, "res->matchesInput");
if (lazySource)
TraceEdge(trc, &lazySource, "res->lazySource");
if (pendingInput)
TraceEdge(trc, &pendingInput, "res->pendingInput");
TraceNullableEdge(trc, &matchesInput, "res->matchesInput");
TraceNullableEdge(trc, &lazySource, "res->lazySource");
TraceNullableEdge(trc, &pendingInput, "res->pendingInput");
}
/* Value creators. */

View File

@ -235,8 +235,7 @@ class SavedStacks {
{ }
void trace(JSTracer* trc) {
if (source)
TraceEdge(trc, &source, "SavedStacks::LocationValue::source");
TraceNullableEdge(trc, &source, "SavedStacks::LocationValue::source");
}
bool needsSweep() {

View File

@ -3420,8 +3420,7 @@ PreliminaryObjectArray::sweep()
void
PreliminaryObjectArrayWithTemplate::trace(JSTracer* trc)
{
if (shape_)
TraceEdge(trc, &shape_, "PreliminaryObjectArrayWithTemplate_shape");
TraceNullableEdge(trc, &shape_, "PreliminaryObjectArrayWithTemplate_shape");
}
/* static */ void
@ -3981,15 +3980,9 @@ void
TypeNewScript::trace(JSTracer* trc)
{
TraceEdge(trc, &function_, "TypeNewScript_function");
if (templateObject_)
TraceEdge(trc, &templateObject_, "TypeNewScript_templateObject");
if (initializedShape_)
TraceEdge(trc, &initializedShape_, "TypeNewScript_initializedShape");
if (initializedGroup_)
TraceEdge(trc, &initializedGroup_, "TypeNewScript_initializedGroup");
TraceNullableEdge(trc, &templateObject_, "TypeNewScript_templateObject");
TraceNullableEdge(trc, &initializedShape_, "TypeNewScript_initializedShape");
TraceNullableEdge(trc, &initializedGroup_, "TypeNewScript_initializedGroup");
}
/* static */ void

View File

@ -35,20 +35,11 @@ UnboxedLayout::trace(JSTracer* trc)
if (newScript())
newScript()->trace(trc);
if (nativeGroup_)
TraceEdge(trc, &nativeGroup_, "unboxed_layout_nativeGroup");
if (nativeShape_)
TraceEdge(trc, &nativeShape_, "unboxed_layout_nativeShape");
if (allocationScript_)
TraceEdge(trc, &allocationScript_, "unboxed_layout_allocationScript");
if (replacementGroup_)
TraceEdge(trc, &replacementGroup_, "unboxed_layout_replacementGroup");
if (constructorCode_)
TraceEdge(trc, &constructorCode_, "unboxed_layout_constructorCode");
TraceNullableEdge(trc, &nativeGroup_, "unboxed_layout_nativeGroup");
TraceNullableEdge(trc, &nativeShape_, "unboxed_layout_nativeShape");
TraceNullableEdge(trc, &allocationScript_, "unboxed_layout_allocationScript");
TraceNullableEdge(trc, &replacementGroup_, "unboxed_layout_replacementGroup");
TraceNullableEdge(trc, &constructorCode_, "unboxed_layout_constructorCode");
}
size_t
@ -327,8 +318,7 @@ UnboxedPlainObject::trace(JSTracer* trc, JSObject* obj)
list++;
while (*list != -1) {
HeapPtrObject* heap = reinterpret_cast<HeapPtrObject*>(data + *list);
if (*heap)
TraceEdge(trc, heap, "unboxed_object");
TraceNullableEdge(trc, heap, "unboxed_object");
list++;
}
@ -1146,8 +1136,7 @@ UnboxedArrayObject::trace(JSTracer* trc, JSObject* obj)
case JSVAL_TYPE_OBJECT:
for (size_t i = 0; i < initlen; i++) {
HeapPtrObject* heap = reinterpret_cast<HeapPtrObject*>(elements + i);
if (*heap)
TraceEdge(trc, heap, "unboxed_object");
TraceNullableEdge(trc, heap, "unboxed_object");
}
break;