Debian Codegraph @

js/src/devtools/rootAnalysis/t/sixgill-tree/source.cpp

raw
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 #define ANNOTATE(property) __attribute__((annotate(property)))
8
9 namespace js {
10 namespace gc {
11 struct Cell {
12 int f;
13 } ANNOTATE("GC Thing");
14 } // namespace gc
15 } // namespace js
16
17 struct Bogon {};
18
19 struct JustACell : public js::gc::Cell {
20 bool iHaveNoDataMembers() { return true; }
21 };
22
23 struct JSObject : public js::gc::Cell, public Bogon {
24 int g;
25 };
26
27 struct SpecialObject : public JSObject {
28 int z;
29 };
30
31 struct ErrorResult {
32 bool hasObj;
33 JSObject* obj;
34 void trace() {}
35 } ANNOTATE("Suppressed GC Pointer");
36
37 struct OkContainer {
38 ErrorResult res;
39 bool happy;
40 };
41
42 struct UnrootedPointer {
43 JSObject* obj;
44 };
45
46 template <typename T>
47 class Rooted {
48 T data;
49 } ANNOTATE("Rooted Pointer");
50
51 extern void js_GC() ANNOTATE("GC Call") ANNOTATE("Slow");
52
53 void js_GC() {}
54
55 void root_arg(JSObject* obj, JSObject* random) {
56 // Use all these types so they get included in the output.
57 SpecialObject so;
58 UnrootedPointer up;
59 Bogon b;
60 OkContainer okc;
61 Rooted<JSObject*> ro;
62 Rooted<SpecialObject*> rso;
63
64 obj = random;
65
66 JSObject* other1 = obj;
67 js_GC();
68
69 float MARKER1 = 0;
70 JSObject* other2 = obj;
71 other1->f = 1;
72 other2->f = -1;
73
74 unsigned int u1 = 1;
75 unsigned int u2 = -1;
76 }