1 #include "gdb-tests.h"
2 
3 #include "jsapi.h"
4 
5 #include "gc/Barrier.h"
6 #include "js/Array.h"  // JS::NewArrayObject
7 #include "vm/JSFunction.h"
8 
FRAGMENT(Root,null)9 FRAGMENT(Root, null) {
10   JS::Rooted<JSObject*> null(cx, nullptr);
11 
12   breakpoint();
13 
14   use(null);
15 }
16 
callee(JS::Handle<JSObject * > obj,JS::MutableHandle<JSObject * > mutableObj)17 void callee(JS::Handle<JSObject*> obj,
18             JS::MutableHandle<JSObject*> mutableObj) {
19   // Prevent the linker from unifying this function with others that are
20   // equivalent in machine code but not type.
21   fprintf(stderr, "Called " __FILE__ ":callee\n");
22   breakpoint();
23 }
24 
FRAGMENT(Root,handle)25 FRAGMENT(Root, handle) {
26   JS::Rooted<JSObject*> global(cx, JS::CurrentGlobalOrNull(cx));
27   callee(global, &global);
28   use(global);
29 }
30 
FRAGMENT(Root,HeapSlot)31 FRAGMENT(Root, HeapSlot) {
32   JS::Rooted<JS::Value> plinth(
33       cx, JS::StringValue(JS_NewStringCopyZ(cx, "plinth")));
34   JS::Rooted<JSObject*> array(
35       cx, JS::NewArrayObject(cx, JS::HandleValueArray(plinth)));
36 
37   breakpoint();
38 
39   use(plinth);
40   use(array);
41 }
42 
FRAGMENT(Root,barriers)43 FRAGMENT(Root, barriers) {
44   JSObject* obj = JS_NewPlainObject(cx);
45   js::PreBarriered<JSObject*> prebarriered(obj);
46   js::GCPtrObject heapptr(obj);
47   js::HeapPtr<JSObject*> relocatable(obj);
48 
49   JS::Value val = JS::ObjectValue(*obj);
50   js::PreBarrieredValue prebarrieredValue(JS::ObjectValue(*obj));
51   js::GCPtrValue heapValue(JS::ObjectValue(*obj));
52   js::HeapPtr<JS::Value> relocatableValue(JS::ObjectValue(*obj));
53 
54   breakpoint();
55 
56   use(prebarriered);
57   use(heapptr);
58   use(relocatable);
59   use(val);
60   use(prebarrieredValue);
61   use(heapValue);
62   use(relocatableValue);
63 }
64