Debian Codegraph @

js/src/gdb/tests/test-GCCellPtr.cpp

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