[gjs: 4/25] js: Rename "compartments" to "realms"



commit 7b6446260bb4c73050ab544b69d1ca2481e18d6d
Author: Philip Chimento <philip chimento gmail com>
Date:   Sat May 18 20:33:59 2019 -0700

    js: Rename "compartments" to "realms"
    
    In SpiderMonkey 68, a "realm" is the term for the environment belonging
    to a particular global object, so when you enter the "realm" of a global
    object you are executing code with that object as the global object.
    
    "Compartments" are still a thing but they are now more focused on
    security, and are used for isolating code in different browser tabs in
    Firefox, for example. All code in GJS except the debugger and the
    coverage collector is run within the same compartment.
    
    Some APIs that previously operated on a global object that was passed
    in, now operate on the current realm.

 gi/closure.cpp              |  2 +-
 gi/function.cpp             |  7 +++----
 gi/gobject.cpp              |  6 +++---
 gi/object.cpp               |  7 ++++---
 gi/object.h                 |  2 +-
 gi/value.cpp                |  2 +-
 gjs/atoms.cpp               |  2 +-
 gjs/context.cpp             | 10 +++++-----
 gjs/coverage.cpp            | 26 +++++++++++++-------------
 gjs/debugger.cpp            | 13 ++++++-------
 gjs/engine.cpp              |  9 ++++-----
 gjs/global.cpp              | 37 ++++++++++++++++++-------------------
 gjs/jsapi-dynamic-class.cpp |  2 +-
 test/gjs-test-utils.cpp     |  4 ++--
 test/gjs-test-utils.h       |  6 ++++--
 tools/heapgraph.py          |  4 ++--
 16 files changed, 69 insertions(+), 70 deletions(-)
---
diff --git a/gi/closure.cpp b/gi/closure.cpp
index 4e9ec3c8..76f127db 100644
--- a/gi/closure.cpp
+++ b/gi/closure.cpp
@@ -195,7 +195,7 @@ gjs_closure_invoke(GClosure                   *closure,
     }
 
     context = c->context;
-    JSAutoCompartment ac(context, JS_GetFunctionObject(c->func));
+    JSAutoRealm ar(context, JS_GetFunctionObject(c->func));
 
     if (JS_IsExceptionPending(context)) {
         gjs_debug_closure("Exception was pending before invoking callback??? "
diff --git a/gi/function.cpp b/gi/function.cpp
index cc3df9b4..74655ad8 100644
--- a/gi/function.cpp
+++ b/gi/function.cpp
@@ -229,8 +229,8 @@ static void gjs_callback_closure(ffi_cif* cif G_GNUC_UNUSED, void* result,
         return;
     }
 
-    JSAutoCompartment ac(context, JS_GetFunctionObject(gjs_closure_get_callable(
-                                      trampoline->js_function)));
+    JSAutoRealm ar(context, JS_GetFunctionObject(gjs_closure_get_callable(
+                                trampoline->js_function)));
 
     bool can_throw_gerror = g_callable_info_can_throw_gerror(trampoline->info);
     n_args = g_callable_info_get_n_args(trampoline->info);
@@ -1751,8 +1751,7 @@ GJS_USE
 static inline JSObject *
 gjs_builtin_function_get_proto(JSContext *cx)
 {
-    JS::RootedObject global(cx, gjs_get_import_global(cx));
-    return JS_GetFunctionPrototype(cx, global);
+    return JS::GetRealmFunctionPrototype(cx);
 }
 
 GJS_DEFINE_PROTO_FUNCS_WITH_PARENT(function, builtin_function)
diff --git a/gi/gobject.cpp b/gi/gobject.cpp
index d72f7ad6..9f82b30c 100644
--- a/gi/gobject.cpp
+++ b/gi/gobject.cpp
@@ -106,7 +106,7 @@ static GObject* gjs_object_constructor(
      * Construct the JS object from the constructor, then use the GObject
      * that was associated in gjs_object_custom_init()
      */
-    JSAutoCompartment ac(cx, gjs_get_import_global(cx));
+    JSAutoRealm ar(cx, gjs_get_import_global(cx));
 
     JS::RootedObject constructor(
         cx, gjs_lookup_object_constructor_from_info(cx, nullptr, type));
@@ -150,7 +150,7 @@ static void gjs_object_set_gproperty(GObject* object,
     JSContext *cx = current_context();
 
     JS::RootedObject js_obj(cx, priv->wrapper());
-    JSAutoCompartment ac(cx, js_obj);
+    JSAutoRealm ar(cx, js_obj);
 
     if (!jsobj_set_gproperty(cx, js_obj, value, pspec))
         gjs_log_exception(cx);
@@ -164,7 +164,7 @@ static void gjs_object_get_gproperty(GObject* object,
 
     JS::RootedObject js_obj(cx, priv->wrapper());
     JS::RootedValue jsvalue(cx);
-    JSAutoCompartment ac(cx, js_obj);
+    JSAutoRealm ar(cx, js_obj);
 
     GjsAutoChar underscore_name = gjs_hyphen_to_underscore(pspec->name);
     if (!JS_GetProperty(cx, js_obj, underscore_name, &jsvalue) ||
diff --git a/gi/object.cpp b/gi/object.cpp
index c5fb697c..51196819 100644
--- a/gi/object.cpp
+++ b/gi/object.cpp
@@ -1124,8 +1124,8 @@ ObjectInstance::toggle_up(void)
      * in case the wrapper has data in it that the app cares about
      */
     if (!wrapper_is_rooted()) {
-        /* FIXME: thread the context through somehow. Maybe by looking up
-         * the compartment that obj belongs to. */
+        // FIXME: thread the context through somehow. Maybe by looking up the
+        // realm that obj belongs to.
         debug_lifecycle("Rooting wrapper");
         auto* cx = GjsContextPrivate::from_current_context()->context();
         switch_to_rooted(cx);
@@ -1301,7 +1301,8 @@ bool ObjectPrototype::init(JSContext* cx) {
  * notifies when weak pointers need to be either moved or swept.
  */
 void ObjectInstance::update_heap_wrapper_weak_pointers(JSContext*,
-                                                       JSCompartment*, void*) {
+                                                       JS::Compartment*,
+                                                       void*) {
     gjs_debug_lifecycle(GJS_DEBUG_GOBJECT, "Weak pointer update callback, "
                         "%zu wrapped GObject(s) to examine",
                         ObjectInstance::num_wrapped_gobjects());
diff --git a/gi/object.h b/gi/object.h
index 3acffc83..47aca983 100644
--- a/gi/object.h
+++ b/gi/object.h
@@ -348,7 +348,7 @@ class ObjectInstance : public GIWrapperInstance<ObjectBase, ObjectPrototype,
     GJS_USE bool weak_pointer_was_finalized(void);
     static void ensure_weak_pointer_callback(JSContext* cx);
     static void update_heap_wrapper_weak_pointers(JSContext* cx,
-                                                  JSCompartment* compartment,
+                                                  JS::Compartment* compartment,
                                                   void* data);
 
  public:
diff --git a/gi/value.cpp b/gi/value.cpp
index cf3d38fd..02700ac5 100644
--- a/gi/value.cpp
+++ b/gi/value.cpp
@@ -171,7 +171,7 @@ closure_marshal(GClosure        *closure,
     }
 
     JSFunction* func = gjs_closure_get_callable(closure);
-    JSAutoCompartment ac(context, JS_GetFunctionObject(func));
+    JSAutoRealm ar(context, JS_GetFunctionObject(func));
 
     if (marshal_data) {
         /* we are used for a signal handler */
diff --git a/gjs/atoms.cpp b/gjs/atoms.cpp
index f8f968a3..699a8908 100644
--- a/gjs/atoms.cpp
+++ b/gjs/atoms.cpp
@@ -47,7 +47,7 @@ bool GjsSymbolAtom::init(JSContext* cx, const char* str) {
     return true;
 }
 
-/* Requires a current compartment. This can GC, so it needs to be done after the
+/* Requires a current realm. This can GC, so it needs to be done after the
  * tracing has been set up. */
 bool GjsAtoms::init_atoms(JSContext* cx) {
 #define INITIALIZE_ATOM(identifier, str) \
diff --git a/gjs/context.cpp b/gjs/context.cpp
index f1da8c77..6373157b 100644
--- a/gjs/context.cpp
+++ b/gjs/context.cpp
@@ -88,7 +88,7 @@ void GjsContextPrivate::EnvironmentPreparer::invoke(JS::HandleObject scope,
                                                     Closure& closure) {
     g_assert(!JS_IsExceptionPending(m_cx));
 
-    JSAutoCompartment ac(m_cx, scope);
+    JSAutoRealm ar(m_cx, scope);
     if (!closure(m_cx))
         gjs_log_exception(m_cx);
 }
@@ -488,7 +488,7 @@ GjsContextPrivate::GjsContextPrivate(JSContext* cx, GjsContext* public_context)
         g_error("Failed to initialize global object");
     }
 
-    JSAutoCompartment ac(m_cx, global);
+    JSAutoRealm ar(m_cx, global);
 
     m_global = global;
     JS_AddExtraGCRootsTracer(m_cx, &GjsContextPrivate::trace, this);
@@ -725,7 +725,7 @@ bool GjsContextPrivate::run_jobs(void) {
 
         m_job_queue[ix] = nullptr;
         {
-            JSAutoCompartment ac(m_cx, job);
+            JSAutoRealm ar(m_cx, job);
             if (!JS::Call(m_cx, JS::UndefinedHandleValue, job, args, &rval)) {
                 /* Uncatchable exception - return false so that
                  * System.exit() works in the interactive shell and when
@@ -869,7 +869,7 @@ bool GjsContextPrivate::eval(const char* script, ssize_t script_len,
         (_gjs_profiler_is_running(m_profiler) || m_should_listen_sigusr2))
         auto_profile = false;
 
-    JSAutoCompartment ac(m_cx, m_global);
+    JSAutoRealm ar(m_cx, m_global);
 
     if (auto_profile)
         gjs_profiler_start(m_profiler);
@@ -1046,7 +1046,7 @@ gjs_context_define_string_array(GjsContext  *js_context,
     g_return_val_if_fail(GJS_IS_CONTEXT(js_context), false);
     GjsContextPrivate* gjs = GjsContextPrivate::from_object(js_context);
 
-    JSAutoCompartment ac(gjs->context(), gjs->global());
+    JSAutoRealm ar(gjs->context(), gjs->global());
 
     JS::RootedObject global_root(gjs->context(), gjs->global());
     if (!gjs_define_string_array(gjs->context(), global_root, array_name,
diff --git a/gjs/coverage.cpp b/gjs/coverage.cpp
index d070c1a4..f1e93781 100644
--- a/gjs/coverage.cpp
+++ b/gjs/coverage.cpp
@@ -48,7 +48,7 @@ struct _GjsCoverage {
 typedef struct {
     gchar **prefixes;
     GjsContext *context;
-    JS::Heap<JSObject *> compartment;
+    JS::Heap<JSObject*> global;
 
     GFile *output_dir;
 } GjsCoveragePrivate;
@@ -309,7 +309,7 @@ gjs_coverage_write_statistics(GjsCoverage *coverage)
     GError *error = nullptr;
 
     auto cx = static_cast<JSContext *>(gjs_context_get_native_context(priv->context));
-    JSAutoCompartment ac(cx, gjs_get_import_global(cx));
+    JSAutoRealm ar(cx, gjs_get_import_global(cx));
 
     GjsAutoUnref<GFile> output_file = write_statistics_internal(coverage, cx, &error);
     if (!output_file) {
@@ -330,7 +330,7 @@ coverage_tracer(JSTracer *trc, void *data)
     GjsCoverage *coverage = (GjsCoverage *) data;
     GjsCoveragePrivate *priv = (GjsCoveragePrivate *) gjs_coverage_get_instance_private(coverage);
 
-    JS::TraceEdge<JSObject *>(trc, &priv->compartment, "Coverage compartment");
+    JS::TraceEdge<JSObject*>(trc, &priv->global, "Coverage global object");
 }
 
 GJS_JSAPI_RETURN_CONVENTION
@@ -342,26 +342,26 @@ bootstrap_coverage(GjsCoverage *coverage)
     JSContext *context = (JSContext *) gjs_context_get_native_context(priv->context);
 
     JSObject *debuggee = gjs_get_import_global(context);
-    JS::RootedObject debugger_compartment(context,
-                                          gjs_create_global_object(context));
+    JS::RootedObject debugger_global(context,
+                                     gjs_create_global_object(context));
     {
-        JSAutoCompartment compartment(context, debugger_compartment);
+        JSAutoRealm ar(context, debugger_global);
         JS::RootedObject debuggeeWrapper(context, debuggee);
         if (!JS_WrapObject(context, &debuggeeWrapper))
             return false;
 
         const GjsAtoms& atoms = GjsContextPrivate::atoms(context);
         JS::RootedValue debuggeeWrapperValue(context, JS::ObjectValue(*debuggeeWrapper));
-        if (!JS_SetPropertyById(context, debugger_compartment, atoms.debuggee(),
+        if (!JS_SetPropertyById(context, debugger_global, atoms.debuggee(),
                                 debuggeeWrapperValue) ||
-            !gjs_define_global_properties(context, debugger_compartment,
+            !gjs_define_global_properties(context, debugger_global,
                                           "GJS coverage", "coverage"))
             return false;
 
         /* Add a tracer, as suggested by jdm on #jsapi */
         JS_AddExtraGCRootsTracer(context, coverage_tracer, coverage);
 
-        priv->compartment = debugger_compartment;
+        priv->global = debugger_global;
     }
 
     return true;
@@ -374,11 +374,11 @@ gjs_coverage_constructed(GObject *object)
 
     GjsCoverage *coverage = GJS_COVERAGE(object);
     GjsCoveragePrivate *priv = (GjsCoveragePrivate *) gjs_coverage_get_instance_private(coverage);
-    new (&priv->compartment) JS::Heap<JSObject *>();
+    new (&priv->global) JS::Heap<JSObject*>();
 
     if (!bootstrap_coverage(coverage)) {
         JSContext *context = static_cast<JSContext *>(gjs_context_get_native_context(priv->context));
-        JSAutoCompartment compartment(context, gjs_get_import_global(context));
+        JSAutoRealm ar(context, gjs_get_import_global(context));
         gjs_log_exception(context);
     }
 }
@@ -420,7 +420,7 @@ gjs_coverage_dispose(GObject *object)
      * disposing of the context */
     auto cx = static_cast<JSContext *>(gjs_context_get_native_context(priv->context));
     JS_RemoveExtraGCRootsTracer(cx, coverage_tracer, coverage);
-    priv->compartment = nullptr;
+    priv->global = nullptr;
 
     g_clear_object(&priv->context);
 
@@ -435,7 +435,7 @@ gjs_coverage_finalize (GObject *object)
 
     g_strfreev(priv->prefixes);
     g_clear_object(&priv->output_dir);
-    priv->compartment.~Heap();
+    priv->global.~Heap();
 
     G_OBJECT_CLASS(gjs_coverage_parent_class)->finalize(object);
 }
diff --git a/gjs/debugger.cpp b/gjs/debugger.cpp
index 289ba1c7..66478a73 100644
--- a/gjs/debugger.cpp
+++ b/gjs/debugger.cpp
@@ -129,10 +129,10 @@ void gjs_context_setup_debugger_console(GjsContext* gjs) {
     auto cx = static_cast<JSContext*>(gjs_context_get_native_context(gjs));
 
     JS::RootedObject debuggee(cx, gjs_get_import_global(cx));
-    JS::RootedObject debugger_compartment(cx, gjs_create_global_object(cx));
+    JS::RootedObject debugger_global(cx, gjs_create_global_object(cx));
 
-    /* Enter compartment of the debugger and initialize it with the debuggee */
-    JSAutoCompartment compartment(cx, debugger_compartment);
+    // Enter realm of the debugger and initialize it with the debuggee
+    JSAutoRealm ar(cx, debugger_global);
     JS::RootedObject debuggee_wrapper(cx, debuggee);
     if (!JS_WrapObject(cx, &debuggee_wrapper)) {
         gjs_log_exception(cx);
@@ -141,10 +141,9 @@ void gjs_context_setup_debugger_console(GjsContext* gjs) {
 
     const GjsAtoms& atoms = GjsContextPrivate::atoms(cx);
     JS::RootedValue v_wrapper(cx, JS::ObjectValue(*debuggee_wrapper));
-    if (!JS_SetPropertyById(cx, debugger_compartment, atoms.debuggee(),
-                            v_wrapper) ||
-        !JS_DefineFunctions(cx, debugger_compartment, debugger_funcs) ||
-        !gjs_define_global_properties(cx, debugger_compartment, "GJS debugger",
+    if (!JS_SetPropertyById(cx, debugger_global, atoms.debuggee(), v_wrapper) ||
+        !JS_DefineFunctions(cx, debugger_global, debugger_funcs) ||
+        !gjs_define_global_properties(cx, debugger_global, "GJS debugger",
                                       "debugger"))
         gjs_log_exception(cx);
 }
diff --git a/gjs/engine.cpp b/gjs/engine.cpp
index e03d13db..b9307639 100644
--- a/gjs/engine.cpp
+++ b/gjs/engine.cpp
@@ -336,11 +336,10 @@ JSContext* gjs_create_js_context(GjsContextPrivate* uninitialized_gjs) {
     JS::SetPromiseRejectionTrackerCallback(cx, on_promise_unhandled_rejection,
                                            uninitialized_gjs);
 
-    /* We use this to handle "lazy sources" that SpiderMonkey doesn't need to
-     * keep in memory. Most sources should be kept in memory, but we can skip
-     * doing that for the compartment bootstrap code, as it is already in memory
-     * in the form of a GResource. Instead we use the "source hook" to
-     * retrieve it. */
+    // We use this to handle "lazy sources" that SpiderMonkey doesn't need to
+    // keep in memory. Most sources should be kept in memory, but we can skip
+    // doing that for the realm bootstrap code, as it is already in memory in
+    // the form of a GResource. Instead we use the "source hook" to retrieve it.
     auto hook = mozilla::MakeUnique<GjsSourceHook>();
     js::SetSourceHook(cx, std::move(hook));
 
diff --git a/gjs/global.cpp b/gjs/global.cpp
index 7113e617..41d9cba2 100644
--- a/gjs/global.cpp
+++ b/gjs/global.cpp
@@ -44,7 +44,7 @@ run_bootstrap(JSContext       *cx,
     GjsAutoChar uri = g_strdup_printf(
         "resource:///org/gnome/gjs/modules/_bootstrap/%s.js", bootstrap_script);
 
-    JSAutoCompartment ac(cx, global);
+    JSAutoRealm ar(cx, global);
 
     JS::CompileOptions options(cx);
     options.setUTF8(true)
@@ -237,14 +237,14 @@ class GjsGlobal {
     static JSObject *
     create(JSContext *cx)
     {
-        JS::CompartmentOptions compartment_options;
-        JS::RootedObject global(cx,
-            JS_NewGlobalObject(cx, &GjsGlobal::klass, nullptr,
-                               JS::FireOnNewGlobalHook, compartment_options));
+        JS::RealmOptions options;
+        JS::RootedObject global(
+            cx, JS_NewGlobalObject(cx, &GjsGlobal::klass, nullptr,
+                                   JS::FireOnNewGlobalHook, options));
         if (!global)
             return nullptr;
 
-        JSAutoCompartment ac(cx, global);
+        JSAutoRealm ar(cx, global);
 
         if (!JS_InitReflectParse(cx, global) ||
             !JS_DefineDebuggerObject(cx, global))
@@ -255,7 +255,7 @@ class GjsGlobal {
 
     GJS_JSAPI_RETURN_CONVENTION
     static bool define_properties(JSContext* cx, JS::HandleObject global,
-                                  const char* compartment_name,
+                                  const char* realm_name,
                                   const char* bootstrap_script) {
         const GjsAtoms& atoms = GjsContextPrivate::atoms(cx);
         if (!JS_DefinePropertyById(cx, global, atoms.window(), global,
@@ -263,10 +263,10 @@ class GjsGlobal {
             !JS_DefineFunctions(cx, global, GjsGlobal::static_funcs))
             return false;
 
-        JSCompartment* compartment = js::GetObjectCompartment(global);
-        // const_cast is allowed here if we never free the compartment data
-        JS_SetCompartmentPrivate(compartment,
-                                 const_cast<char*>(compartment_name));
+        JS::Realm* realm = JS::GetObjectRealmOrNull(global);
+        g_assert(realm && "Global object must be associated with a realm");
+        // const_cast is allowed here if we never free the realm data
+        JS::SetRealmPrivate(realm, const_cast<char*>(realm_name));
 
         JS::Value v_importer = gjs_get_global_slot(cx, GJS_GLOBAL_SLOT_IMPORTS);
         g_assert(((void) "importer should be defined before passing null "
@@ -274,8 +274,7 @@ class GjsGlobal {
                   v_importer.isObject()));
         JS::RootedObject root_importer(cx, &v_importer.toObject());
 
-        /* Wrapping is a no-op if the importer is already in the same
-         * compartment. */
+        // Wrapping is a no-op if the importer is already in the same realm.
         if (!JS_WrapObject(cx, &root_importer) ||
             !JS_DefinePropertyById(cx, global, atoms.imports(), root_importer,
                                    GJS_MODULE_PROP_FLAGS))
@@ -309,7 +308,7 @@ gjs_create_global_object(JSContext *cx)
  * gjs_define_global_properties:
  * @cx: a #JSContext
  * @global: a JS global object that has not yet been passed to this function
- * @compartment_name: (nullable): name of the compartment, for debug output
+ * @realm_name: (nullable): name of the realm, for debug output
  * @bootstrap_script: (nullable): name of a bootstrap script (found at
  * resource://org/gnome/gjs/modules/_bootstrap/@bootstrap_script) or %NULL for
  * none
@@ -324,17 +323,17 @@ gjs_create_global_object(JSContext *cx)
  * root importer in between calling gjs_create_global_object() and
  * gjs_define_global_properties().
  *
- * The caller of this function should be in the compartment for @global.
- * If the root importer object belongs to a different compartment, this
- * function will create a cross-compartment wrapper for it.
+ * The caller of this function should be in the realm for @global.
+ * If the root importer object belongs to a different realm, this function will
+ * create a wrapper for it.
  *
  * Returns: true on success, false otherwise, in which case an exception is
  * pending on @cx
  */
 bool gjs_define_global_properties(JSContext* cx, JS::HandleObject global,
-                                  const char* compartment_name,
+                                  const char* realm_name,
                                   const char* bootstrap_script) {
-    return GjsGlobal::define_properties(cx, global, compartment_name,
+    return GjsGlobal::define_properties(cx, global, realm_name,
                                         bootstrap_script);
 }
 
diff --git a/gjs/jsapi-dynamic-class.cpp b/gjs/jsapi-dynamic-class.cpp
index a5388f0b..a1a16a70 100644
--- a/gjs/jsapi-dynamic-class.cpp
+++ b/gjs/jsapi-dynamic-class.cpp
@@ -278,7 +278,7 @@ gjs_dynamic_property_private_slot(JSObject *accessor_obj)
 bool gjs_object_in_prototype_chain(JSContext* cx, JS::HandleObject proto,
                                    JS::HandleObject check_obj,
                                    bool* is_in_chain) {
-    JS::RootedObject object_prototype(cx, JS_GetObjectPrototype(cx, check_obj));
+    JS::RootedObject object_prototype(cx, JS::GetRealmObjectPrototype(cx));
     if (!object_prototype)
         return false;
 
diff --git a/test/gjs-test-utils.cpp b/test/gjs-test-utils.cpp
index b6e2a303..3c83a247 100644
--- a/test/gjs-test-utils.cpp
+++ b/test/gjs-test-utils.cpp
@@ -37,7 +37,7 @@ void gjs_unit_test_fixture_setup(GjsUnitTestFixture* fx, const void*) {
     fx->cx = (JSContext *) gjs_context_get_native_context(fx->gjs_context);
 
     JS::RootedObject global(fx->cx, gjs_get_import_global(fx->cx));
-    fx->compartment = JS_EnterCompartment(fx->cx, global);
+    fx->realm = JS::EnterRealm(fx->cx, global);
 }
 
 void
@@ -47,7 +47,7 @@ gjs_unit_test_destroy_context(GjsUnitTestFixture *fx)
     if (message)
         g_printerr("**\n%s\n", message.get());
 
-    JS_LeaveCompartment(fx->cx, fx->compartment);
+    JS::LeaveRealm(fx->cx, fx->realm);
 
     g_object_unref(fx->gjs_context);
 }
diff --git a/test/gjs-test-utils.h b/test/gjs-test-utils.h
index 6af5d2d9..94519253 100644
--- a/test/gjs-test-utils.h
+++ b/test/gjs-test-utils.h
@@ -28,14 +28,16 @@
 
 #include "gjs/context.h"
 
-struct JSCompartment;
 struct JSContext;
+namespace JS {
+class Realm;
+};
 
 typedef struct _GjsUnitTestFixture GjsUnitTestFixture;
 struct _GjsUnitTestFixture {
     GjsContext *gjs_context;
     JSContext *cx;
-    JSCompartment *compartment;
+    JS::Realm* realm;
 };
 
 void gjs_unit_test_fixture_setup(GjsUnitTestFixture* fx, const void* unused);
diff --git a/tools/heapgraph.py b/tools/heapgraph.py
index 820806a9..1db2ecb8 100755
--- a/tools/heapgraph.py
+++ b/tools/heapgraph.py
@@ -158,7 +158,7 @@ def parse_roots(fobj):
                                                    key=wme.group(2),
                                                    keyDelegate=wme.group(3),
                                                    value=wme.group(4)))
-            # Skip comments, arenas, compartments and zones
+            # Skip comments, arenas, realms and zones
             elif line[0] == '#':
                 continue
             # Marks the end of the roots section
@@ -222,7 +222,7 @@ def parse_graph(fobj):
                         break
                 else:
                     addNode(node_addr, node_label)
-            # Skip comments, arenas, compartments and zones
+            # Skip comments, arenas, realms and zones
             elif line[0] == '#':
                 continue
             else:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]