Line data Source code
1 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 : /* This Source Code Form is subject to the terms of the Mozilla Public
4 : * License, v. 2.0. If a copy of the MPL was not distributed with this
5 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 :
7 : #include "nsCycleCollectionParticipant.h"
8 : #include "jsapi.h"
9 : #include "jsfriendapi.h"
10 :
11 : void
12 0 : CycleCollectionNoteEdgeNameImpl(nsCycleCollectionTraversalCallback& aCallback,
13 : const char* aName,
14 : uint32_t aFlags)
15 : {
16 0 : nsAutoCString arrayEdgeName(aName);
17 0 : if (aFlags & CycleCollectionEdgeNameArrayFlag) {
18 0 : arrayEdgeName.AppendLiteral("[i]");
19 : }
20 0 : aCallback.NoteNextEdgeName(arrayEdgeName.get());
21 0 : }
22 :
23 : void
24 2592 : nsCycleCollectionParticipant::NoteJSChild(JS::GCCellPtr aGCThing,
25 : const char* aName,
26 : void* aClosure)
27 : {
28 : nsCycleCollectionTraversalCallback* cb =
29 2592 : static_cast<nsCycleCollectionTraversalCallback*>(aClosure);
30 2592 : NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(*cb, aName);
31 2592 : if (mozilla::AddToCCKind(aGCThing.kind())) {
32 2592 : cb->NoteJSChild(aGCThing);
33 : }
34 2592 : }
35 :
36 : void
37 3992 : TraceCallbackFunc::Trace(JS::Heap<JS::Value>* aPtr, const char* aName,
38 : void* aClosure) const
39 : {
40 3992 : if (aPtr->unbarrieredGet().isGCThing()) {
41 12 : mCallback(JS::GCCellPtr(aPtr->unbarrieredGet()), aName, aClosure);
42 : }
43 3992 : }
44 :
45 : void
46 0 : TraceCallbackFunc::Trace(JS::Heap<jsid>* aPtr, const char* aName,
47 : void* aClosure) const
48 : {
49 0 : if (JSID_IS_GCTHING(aPtr->unbarrieredGet())) {
50 0 : mCallback(JSID_TO_GCTHING(aPtr->unbarrieredGet()), aName, aClosure);
51 : }
52 0 : }
53 :
54 : void
55 48 : TraceCallbackFunc::Trace(JS::Heap<JSObject*>* aPtr, const char* aName,
56 : void* aClosure) const
57 : {
58 48 : if (*aPtr) {
59 28 : mCallback(JS::GCCellPtr(aPtr->unbarrieredGet()), aName, aClosure);
60 : }
61 48 : }
62 :
63 : void
64 5144 : TraceCallbackFunc::Trace(JSObject** aPtr, const char* aName,
65 : void* aClosure) const
66 : {
67 5144 : if (*aPtr) {
68 5144 : mCallback(JS::GCCellPtr(*aPtr), aName, aClosure);
69 : }
70 5144 : }
71 :
72 : void
73 0 : TraceCallbackFunc::Trace(JS::TenuredHeap<JSObject*>* aPtr, const char* aName,
74 : void* aClosure) const
75 : {
76 0 : if (*aPtr) {
77 0 : mCallback(JS::GCCellPtr(aPtr->unbarrieredGetPtr()), aName, aClosure);
78 : }
79 0 : }
80 :
81 : void
82 0 : TraceCallbackFunc::Trace(JS::Heap<JSFunction*>* aPtr, const char* aName,
83 : void* aClosure) const
84 : {
85 0 : if (*aPtr) {
86 0 : mCallback(JS::GCCellPtr(aPtr->unbarrieredGet()), aName, aClosure);
87 : }
88 0 : }
89 :
90 : void
91 0 : TraceCallbackFunc::Trace(JS::Heap<JSString*>* aPtr, const char* aName,
92 : void* aClosure) const
93 : {
94 0 : if (*aPtr) {
95 0 : mCallback(JS::GCCellPtr(aPtr->unbarrieredGet()), aName, aClosure);
96 : }
97 0 : }
98 :
99 : void
100 0 : TraceCallbackFunc::Trace(JS::Heap<JSScript*>* aPtr, const char* aName,
101 : void* aClosure) const
102 : {
103 0 : if (*aPtr) {
104 0 : mCallback(JS::GCCellPtr(aPtr->unbarrieredGet()), aName, aClosure);
105 : }
106 0 : }
|