[gjs/wip/ptomato/mozjs38: 2/4] js: Root IDs passed to JS_DefinePropertyById
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs/wip/ptomato/mozjs38: 2/4] js: Root IDs passed to JS_DefinePropertyById
- Date: Sat, 7 Jan 2017 02:09:50 +0000 (UTC)
commit e2e762cc2d404c37f4ada4e2863f248aca514637
Author: Philip Chimento <philip endlessm com>
Date: Fri Jan 6 18:04:23 2017 -0800
js: Root IDs passed to JS_DefinePropertyById
In mozjs38, rooting is required on these jsids, presumably because the
function can GC where before it could not.
https://bugzilla.gnome.org/show_bug.cgi?id=776966
gi/gerror.cpp | 10 ++++++----
gi/repo.cpp | 7 ++++---
gjs/importer.cpp | 16 +++++-----------
3 files changed, 15 insertions(+), 18 deletions(-)
---
diff --git a/gi/gerror.cpp b/gi/gerror.cpp
index 4949175..001e2fc 100644
--- a/gi/gerror.cpp
+++ b/gi/gerror.cpp
@@ -399,7 +399,6 @@ static void
define_error_properties(JSContext *context,
JSObject *obj)
{
- jsid stack_name, filename_name, linenumber_name;
JS::RootedValue stack(context), fileName(context), lineNumber(context);
/* COMPAT: mozilla::Maybe gains a much more usable API in future versions */
mozilla::Maybe<JS::MutableHandleValue> m_stack, m_file, m_line;
@@ -410,9 +409,12 @@ define_error_properties(JSContext *context,
if (!gjs_context_get_frame_info(context, m_stack, m_file, m_line))
return;
- stack_name = gjs_context_get_const_string(context, GJS_STRING_STACK);
- filename_name = gjs_context_get_const_string(context, GJS_STRING_FILENAME);
- linenumber_name = gjs_context_get_const_string(context, GJS_STRING_LINE_NUMBER);
+ JS::RootedId stack_name(context,
+ gjs_context_get_const_string(context, GJS_STRING_STACK));
+ JS::RootedId filename_name(context,
+ gjs_context_get_const_string(context, GJS_STRING_FILENAME));
+ JS::RootedId linenumber_name(context,
+ gjs_context_get_const_string(context, GJS_STRING_LINE_NUMBER));
JS_DefinePropertyById(context, obj, stack_name, stack,
NULL, NULL, JSPROP_ENUMERATE);
diff --git a/gi/repo.cpp b/gi/repo.cpp
index 7e8a19a..dff585e 100644
--- a/gi/repo.cpp
+++ b/gi/repo.cpp
@@ -236,7 +236,6 @@ repo_new(JSContext *context)
JSObject *versions;
JSObject *private_ns;
bool found;
- jsid versions_name, private_ns_name;
JS::RootedObject global(context, gjs_get_import_global(context));
@@ -291,7 +290,8 @@ repo_new(JSContext *context)
"repo constructor, obj %p priv %p", repo.get(), priv);
versions = JS_NewObject(context, NULL, JS::NullPtr(), global);
- versions_name = gjs_context_get_const_string(context, GJS_STRING_GI_VERSIONS);
+ JS::RootedId versions_name(context,
+ gjs_context_get_const_string(context, GJS_STRING_GI_VERSIONS));
JS_DefinePropertyById(context, repo,
versions_name,
JS::ObjectValue(*versions),
@@ -299,7 +299,8 @@ repo_new(JSContext *context)
JSPROP_PERMANENT);
private_ns = JS_NewObject(context, NULL, JS::NullPtr(), global);
- private_ns_name = gjs_context_get_const_string(context, GJS_STRING_PRIVATE_NS_MARKER);
+ JS::RootedId private_ns_name(context,
+ gjs_context_get_const_string(context, GJS_STRING_PRIVATE_NS_MARKER));
JS_DefinePropertyById(context, repo,
private_ns_name,
JS::ObjectValue(*private_ns),
diff --git a/gjs/importer.cpp b/gjs/importer.cpp
index 2f54be8..f0f8877 100644
--- a/gjs/importer.cpp
+++ b/gjs/importer.cpp
@@ -1184,28 +1184,22 @@ gjs_define_root_importer_object(JSContext *context,
JS::HandleObject in_object,
JS::HandleObject root_importer)
{
- bool success;
- jsid imports_name;
-
- success = false;
- JS_BeginRequest(context);
+ JSAutoRequest ar(context);
JS::RootedValue importer (JS_GetRuntime(context),
JS::ObjectValue(*root_importer));
- imports_name = gjs_context_get_const_string(context, GJS_STRING_IMPORTS);
+ JS::RootedId imports_name(context,
+ gjs_context_get_const_string(context, GJS_STRING_IMPORTS));
if (!JS_DefinePropertyById(context, in_object,
imports_name, importer,
NULL, NULL,
GJS_MODULE_PROP_FLAGS)) {
gjs_debug(GJS_DEBUG_IMPORTER, "DefineProperty imports on %p failed",
in_object.get());
- goto fail;
+ return false;
}
- success = true;
- fail:
- JS_EndRequest(context);
- return success;
+ return true;
}
bool
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]