/src/mozilla-central/xpcom/base/nsCycleCollectorTraceJSHelpers.cpp
Line | Count | Source (jump to first uncovered line) |
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 | | CycleCollectionNoteEdgeNameImpl(nsCycleCollectionTraversalCallback& aCallback, |
13 | | const char* aName, |
14 | | uint32_t aFlags) |
15 | 0 | { |
16 | 0 | nsAutoCString arrayEdgeName(aName); |
17 | 0 | if (aFlags & CycleCollectionEdgeNameArrayFlag) { |
18 | 0 | arrayEdgeName.AppendLiteral("[i]"); |
19 | 0 | } |
20 | 0 | aCallback.NoteNextEdgeName(arrayEdgeName.get()); |
21 | 0 | } |
22 | | |
23 | | void |
24 | | nsCycleCollectionParticipant::NoteJSChild(JS::GCCellPtr aGCThing, |
25 | | const char* aName, |
26 | | void* aClosure) |
27 | 0 | { |
28 | 0 | nsCycleCollectionTraversalCallback* cb = |
29 | 0 | static_cast<nsCycleCollectionTraversalCallback*>(aClosure); |
30 | 0 | NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(*cb, aName); |
31 | 0 | if (mozilla::AddToCCKind(aGCThing.kind())) { |
32 | 0 | cb->NoteJSChild(aGCThing); |
33 | 0 | } |
34 | 0 | } |
35 | | |
36 | | void |
37 | | TraceCallbackFunc::Trace(JS::Heap<JS::Value>* aPtr, const char* aName, |
38 | | void* aClosure) const |
39 | 0 | { |
40 | 0 | if (aPtr->unbarrieredGet().isGCThing()) { |
41 | 0 | mCallback(JS::GCCellPtr(aPtr->unbarrieredGet()), aName, aClosure); |
42 | 0 | } |
43 | 0 | } |
44 | | |
45 | | void |
46 | | TraceCallbackFunc::Trace(JS::Heap<jsid>* aPtr, const char* aName, |
47 | | void* aClosure) const |
48 | 0 | { |
49 | 0 | if (JSID_IS_GCTHING(aPtr->unbarrieredGet())) { |
50 | 0 | mCallback(JSID_TO_GCTHING(aPtr->unbarrieredGet()), aName, aClosure); |
51 | 0 | } |
52 | 0 | } |
53 | | |
54 | | void |
55 | | TraceCallbackFunc::Trace(JS::Heap<JSObject*>* aPtr, const char* aName, |
56 | | void* aClosure) const |
57 | 0 | { |
58 | 0 | if (*aPtr) { |
59 | 0 | mCallback(JS::GCCellPtr(aPtr->unbarrieredGet()), aName, aClosure); |
60 | 0 | } |
61 | 0 | } |
62 | | |
63 | | void |
64 | | TraceCallbackFunc::Trace(JSObject** aPtr, const char* aName, |
65 | | void* aClosure) const |
66 | 0 | { |
67 | 0 | if (*aPtr) { |
68 | 0 | mCallback(JS::GCCellPtr(*aPtr), aName, aClosure); |
69 | 0 | } |
70 | 0 | } |
71 | | |
72 | | void |
73 | | TraceCallbackFunc::Trace(JS::TenuredHeap<JSObject*>* aPtr, const char* aName, |
74 | | void* aClosure) const |
75 | 0 | { |
76 | 0 | if (*aPtr) { |
77 | 0 | mCallback(JS::GCCellPtr(aPtr->unbarrieredGetPtr()), aName, aClosure); |
78 | 0 | } |
79 | 0 | } |
80 | | |
81 | | void |
82 | | TraceCallbackFunc::Trace(JS::Heap<JSFunction*>* aPtr, const char* aName, |
83 | | void* aClosure) const |
84 | 0 | { |
85 | 0 | if (*aPtr) { |
86 | 0 | mCallback(JS::GCCellPtr(aPtr->unbarrieredGet()), aName, aClosure); |
87 | 0 | } |
88 | 0 | } |
89 | | |
90 | | void |
91 | | TraceCallbackFunc::Trace(JS::Heap<JSString*>* aPtr, const char* aName, |
92 | | void* aClosure) const |
93 | 0 | { |
94 | 0 | if (*aPtr) { |
95 | 0 | mCallback(JS::GCCellPtr(aPtr->unbarrieredGet()), aName, aClosure); |
96 | 0 | } |
97 | 0 | } |
98 | | |
99 | | void |
100 | | TraceCallbackFunc::Trace(JS::Heap<JSScript*>* aPtr, const char* aName, |
101 | | void* aClosure) const |
102 | 0 | { |
103 | 0 | if (*aPtr) { |
104 | 0 | mCallback(JS::GCCellPtr(aPtr->unbarrieredGet()), aName, aClosure); |
105 | 0 | } |
106 | 0 | } |