[gjs/wip/ptomato/mozjs52: 33/42] js: Replace JSRuntime APIs that now take JSContext
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs/wip/ptomato/mozjs52: 33/42] js: Replace JSRuntime APIs that now take JSContext
- Date: Sat, 24 Jun 2017 06:00:15 +0000 (UTC)
commit fb33241967802f1cda8a03340ea6605b7e51efc8
Author: Philip Chimento <philip chimento gmail com>
Date: Tue May 2 22:00:03 2017 -0700
js: Replace JSRuntime APIs that now take JSContext
Many APIs that adapted to the removal of JSRuntime can be trivially
replaced with JSContext without any other code changes.
JS_AbortIfWrongThread() also takes JSContext instead of JSRuntime, but
we only called it to check that we were creating a JSContext on the
correct thread. Before creating the JSContext, there is no point in
calling it, so remove it.
gi/gtype.cpp | 5 ++---
gi/object.cpp | 4 ++--
gjs/context.cpp | 14 +++++++-------
gjs/coverage.cpp | 7 ++-----
gjs/jsapi-util.cpp | 2 +-
modules/system.cpp | 2 +-
test/gjs-test-rooting.cpp | 6 +++---
7 files changed, 18 insertions(+), 22 deletions(-)
---
diff --git a/gi/gtype.cpp b/gi/gtype.cpp
index fe365fe..ac024b8 100644
--- a/gi/gtype.cpp
+++ b/gi/gtype.cpp
@@ -58,7 +58,7 @@ gjs_get_gtype_wrapper_quark(void)
}
static void
-update_gtype_weak_pointers(JSRuntime *rt,
+update_gtype_weak_pointers(JSContext *cx,
JSCompartment *compartment,
void *data)
{
@@ -76,8 +76,7 @@ static void
ensure_weak_pointer_callback(JSContext *cx)
{
if (!weak_pointer_callback) {
- JS_AddWeakPointerCompartmentCallback(JS_GetRuntime(cx),
- update_gtype_weak_pointers,
+ JS_AddWeakPointerCompartmentCallback(cx, update_gtype_weak_pointers,
nullptr);
weak_pointer_callback = true;
}
diff --git a/gi/object.cpp b/gi/object.cpp
index c6c98af..1a1762d 100644
--- a/gi/object.cpp
+++ b/gi/object.cpp
@@ -1128,7 +1128,7 @@ init_object_private (JSContext *context,
}
static void
-update_heap_wrapper_weak_pointers(JSRuntime *rt,
+update_heap_wrapper_weak_pointers(JSContext *cx,
JSCompartment *compartment,
gpointer data)
{
@@ -1158,7 +1158,7 @@ static void
ensure_weak_pointer_callback(JSContext *cx)
{
if (!weak_pointer_callback) {
- JS_AddWeakPointerCompartmentCallback(JS_GetRuntime(cx),
+ JS_AddWeakPointerCompartmentCallback(cx,
update_heap_wrapper_weak_pointers,
nullptr);
weak_pointer_callback = true;
diff --git a/gjs/context.cpp b/gjs/context.cpp
index a1000b5..fdf3257 100644
--- a/gjs/context.cpp
+++ b/gjs/context.cpp
@@ -265,7 +265,7 @@ gjs_printerr(JSContext *context,
}
static void
-on_garbage_collect(JSRuntime *rt,
+on_garbage_collect(JSContext *cx,
JSGCStatus status,
void *data)
{
@@ -407,7 +407,7 @@ gjs_context_dispose(GObject *object)
* that we may not have the JS_GetPrivate() to access the
* context
*/
- JS_GC(js_context->runtime);
+ JS_GC(js_context->context);
JS_EndRequest(js_context->context);
js_context->destroying = true;
@@ -423,7 +423,7 @@ gjs_context_dispose(GObject *object)
js_context->auto_gc_id = 0;
}
- JS_RemoveExtraGCRootsTracer(js_context->runtime, gjs_context_tracer,
+ JS_RemoveExtraGCRootsTracer(js_context->context, gjs_context_tracer,
js_context);
js_context->global = NULL;
@@ -483,7 +483,6 @@ gjs_context_constructed(GObject *object)
js_context->runtime = gjs_runtime_ref();
- JS_AbortIfWrongThread(js_context->runtime);
js_context->owner_thread = g_thread_self();
js_context->context = JS_NewContext(js_context->runtime, 8192 /* stack chunk size */);
@@ -498,7 +497,7 @@ gjs_context_constructed(GObject *object)
JS_BeginRequest(js_context->context);
- JS_SetGCCallback(js_context->runtime, on_garbage_collect, js_context);
+ JS_SetGCCallback(js_context->context, on_garbage_collect, js_context);
/* set ourselves as the private data */
JS_SetContextPrivate(js_context->context, js_context);
@@ -517,7 +516,8 @@ gjs_context_constructed(GObject *object)
g_error("Failed to define properties on the global object");
new (&js_context->global) JS::Heap<JSObject *>(global);
- JS_AddExtraGCRootsTracer(js_context->runtime, gjs_context_tracer, js_context);
+ JS_AddExtraGCRootsTracer(js_context->context, gjs_context_tracer,
+ js_context);
gjs_define_constructor_proxy_factory(js_context->context);
@@ -703,7 +703,7 @@ gjs_context_maybe_gc (GjsContext *context)
void
gjs_context_gc (GjsContext *context)
{
- JS_GC(context->runtime);
+ JS_GC(context->context);
}
/**
diff --git a/gjs/coverage.cpp b/gjs/coverage.cpp
index 4845b15..3a1b6bf 100644
--- a/gjs/coverage.cpp
+++ b/gjs/coverage.cpp
@@ -1698,9 +1698,7 @@ bootstrap_coverage(GjsCoverage *coverage)
}
/* Add a tracer, as suggested by jdm on #jsapi */
- JS_AddExtraGCRootsTracer(JS_GetRuntime(context),
- coverage_statistics_tracer,
- coverage);
+ JS_AddExtraGCRootsTracer(context, coverage_statistics_tracer, coverage);
priv->coverage_statistics = coverage_statistics;
}
@@ -1779,8 +1777,7 @@ gjs_clear_js_side_statistics_from_coverage_object(GjsCoverage *coverage)
/* Remove GC roots trace after we've decomissioned the object
* and no longer need it to be traced here. */
- JS_RemoveExtraGCRootsTracer(JS_GetRuntime(js_context),
- coverage_statistics_tracer,
+ JS_RemoveExtraGCRootsTracer(js_context, coverage_statistics_tracer,
coverage);
priv->coverage_statistics = NULL;
diff --git a/gjs/jsapi-util.cpp b/gjs/jsapi-util.cpp
index 568318b..cfc5b5d 100644
--- a/gjs/jsapi-util.cpp
+++ b/gjs/jsapi-util.cpp
@@ -810,7 +810,7 @@ gjs_gc_if_needed (JSContext *context)
*/
if (rss_size > linux_rss_trigger) {
linux_rss_trigger = (gulong) MIN(G_MAXULONG, rss_size * 1.25);
- JS_GC(JS_GetRuntime(context));
+ JS_GC(context);
last_gc_time = now;
} else if (rss_size < (0.75 * linux_rss_trigger)) {
/* If we've shrunk by 75%, lower the trigger */
diff --git a/modules/system.cpp b/modules/system.cpp
index 137b49c..d499758 100644
--- a/modules/system.cpp
+++ b/modules/system.cpp
@@ -131,7 +131,7 @@ gjs_gc(JSContext *context,
JS::CallArgs argv = JS::CallArgsFromVp (argc, vp);
if (!gjs_parse_call_args(context, "gc", argv, ""))
return false;
- JS_GC(JS_GetRuntime(context));
+ JS_GC(context);
argv.rval().setUndefined();
return true;
}
diff --git a/test/gjs-test-rooting.cpp b/test/gjs-test-rooting.cpp
index 3c90077..6813aba 100644
--- a/test/gjs-test-rooting.cpp
+++ b/test/gjs-test-rooting.cpp
@@ -52,7 +52,7 @@ test_obj_new(GjsRootingFixture *fx)
}
static void
-on_gc(JSRuntime *rt,
+on_gc(JSContext *cx,
JSGCStatus status,
void *data)
{
@@ -70,7 +70,7 @@ setup(GjsRootingFixture *fx,
gconstpointer unused)
{
gjs_unit_test_fixture_setup(PARENT(fx), unused);
- JS_SetGCCallback(JS_GetRuntime(PARENT(fx)->cx), on_gc, fx);
+ JS_SetGCCallback(PARENT(fx)->cx, on_gc, fx);
}
static void
@@ -85,7 +85,7 @@ wait_for_gc(GjsRootingFixture *fx)
{
int count = g_atomic_int_get(&gc_counter);
- JS_GC(JS_GetRuntime(PARENT(fx)->cx));
+ JS_GC(PARENT(fx)->cx);
g_mutex_lock(&gc_lock);
while (count == g_atomic_int_get(&gc_counter)) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]