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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/gdb/tests/test-Root.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,34 @@
     1.4 +#include "gdb-tests.h"
     1.5 +#include "jsapi.h"
     1.6 +
     1.7 +FRAGMENT(Root, null) {
     1.8 +  JS::Rooted<JSObject *> null(cx, nullptr);
     1.9 +
    1.10 +  breakpoint();
    1.11 +
    1.12 +  (void) null;
    1.13 +}
    1.14 +
    1.15 +void callee(JS::Handle<JSObject *> obj, JS::MutableHandle<JSObject *> mutableObj)
    1.16 +{
    1.17 +  // Prevent the linker from unifying this function with others that are
    1.18 +  // equivalent in machine code but not type.
    1.19 +  fprintf(stderr, "Called " __FILE__ ":callee\n");
    1.20 +  breakpoint();
    1.21 +}
    1.22 +
    1.23 +FRAGMENT(Root, handle) {
    1.24 +  JS::Rooted<JSObject *> global(cx, JS::CurrentGlobalOrNull(cx));
    1.25 +  callee(global, &global);
    1.26 +  (void) global;
    1.27 +}
    1.28 +
    1.29 +FRAGMENT(Root, HeapSlot) {
    1.30 +  JS::Rooted<jsval> plinth(cx, STRING_TO_JSVAL(JS_NewStringCopyZ(cx, "plinth")));
    1.31 +  JS::Rooted<JSObject *> array(cx, JS_NewArrayObject(cx, plinth));
    1.32 +
    1.33 +  breakpoint();
    1.34 +
    1.35 +  (void) plinth;
    1.36 +  (void) array;
    1.37 +}

mercurial