1 #include "gdb-tests.h"
2 
3 #include "jsapi.h"
4 
5 #include "js/CompileOptions.h"
6 #include "js/CompilationAndEvaluation.h"
7 #include "js/HeapAPI.h"
8 #include "js/RegExpFlags.h"
9 #include "js/SourceText.h"
10 #include "js/Symbol.h"
11 #include "js/TypeDecls.h"
12 #include "vm/BigIntType.h"
13 #include "vm/JSObject.h"
14 #include "vm/RegExpObject.h"
15 #include "vm/Shape.h"
16 
17 #include "vm/JSObject-inl.h"
18 
FRAGMENT(GCCellPtr,simple)19 FRAGMENT(GCCellPtr, simple) {
20   JS::Rooted<JSObject*> glob(cx, JS::CurrentGlobalOrNull(cx));
21   JS::Rooted<JSString*> empty(cx, JS_NewStringCopyN(cx, nullptr, 0));
22   JS::Rooted<JS::Symbol*> unique(cx, JS::NewSymbol(cx, nullptr));
23   JS::Rooted<JS::BigInt*> zeroBigInt(cx, JS::BigInt::zero(cx));
24   JS::Rooted<js::RegExpObject*> regExp(
25       cx, js::RegExpObject::create(cx, u"", 0, JS::RegExpFlags{},
26                                    js::GenericObject));
27   JS::Rooted<js::RegExpShared*> rootedRegExpShared(
28       cx, js::RegExpObject::getShared(cx, regExp));
29 
30   JS::CompileOptions options(cx);
31   options.setFileAndLine(__FILE__, __LINE__);
32   JS::SourceText<char16_t> srcBuf;
33   (void)srcBuf.init(cx, nullptr, 0, JS::SourceOwnership::Borrowed);
34   JS::RootedScript emptyScript(cx, JS::Compile(cx, options, srcBuf));
35 
36   // Inline TraceKinds.
37   JS::GCCellPtr nulll(nullptr);
38   JS::GCCellPtr object(glob.get());
39   JS::GCCellPtr string(empty.get());
40   JS::GCCellPtr symbol(unique.get());
41   JS::GCCellPtr bigint(zeroBigInt.get());
42   JS::GCCellPtr shape(glob->shape());
43 
44   // Out-of-line TraceKinds.
45   JS::GCCellPtr baseShape(glob->shape()->base());
46   // JitCode can't easily be tested here, so skip it.
47   JS::GCCellPtr script(emptyScript.get());
48   JS::GCCellPtr scope(emptyScript->bodyScope());
49   JS::GCCellPtr regExpShared(rootedRegExpShared.get());
50 
51   breakpoint();
52 
53   use(nulll);
54   use(object);
55   use(string);
56   use(symbol);
57   use(bigint);
58   use(shape);
59   use(baseShape);
60   use(script);
61   use(scope);
62   use(regExpShared);
63 }
64