Changed Linux hosted mode code to use JSRuntime* instead of JSContext* for
adding/removing JS roots. This fixes the problem where the JSContext has
been destroyed by the time the Java finalizer runs -- there is one JSRuntime
instance and it always exists.
In the future, the JSContext will not be stored in the JsRootedValue at all,
but will be kept in a stack from gwtOnLoad calls much like the Safari code.
This will also cut in half the storage required for JsRootedValue object.
In addition to this basic change, two additional changes were incorporated:
* an unreferenced "staging" target in the jni/Linux Makefile to ease
development on Linux hosted mode
* the void-valued JsRootedValue constructor did not register itself as
a root. This was missed when we changed from only rooting values that
need to be GC'd, versus always rooting the value regardless of what it
holds. When the value is destroyed, the root would be removed that was
never added, which would fail depending on the value held at that time.
After discussion with Kelly and Miguel, this was committed since it was
causing intermittent test failures (JUnit unloading a module and reloading
the next one has the same basic behavior that refreshing in hosted mode
does). As Kelly is not familiar with the code in question, I will also have
Scott review it after the checkin since he is traveling.
Review by: knorton (desk review)
scottb (after commit)
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@666 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/jni/linux/ExternalWrapper.cpp b/jni/linux/ExternalWrapper.cpp
index 4f0ae72..eff2802 100644
--- a/jni/linux/ExternalWrapper.cpp
+++ b/jni/linux/ExternalWrapper.cpp
@@ -40,6 +40,8 @@
jsval *argv, jsval *rval)
{
Tracer tracer("gwtOnLoad");
+ tracer.log("context=%08x", unsigned(cx));
+ JsRootedValue::ensureRuntime(cx);
if (argc < 2) {
tracer.setFail("less than 2 args");
return JS_FALSE;
@@ -78,6 +80,9 @@
tracer.setFail("can't get module name in Java string");
return JS_FALSE;
}
+ tracer.log("module name=%s", JS_GetStringBytes(moduleName));
+ } else {
+ tracer.log("null module name");
}
jobject externalObject = NS_REINTERPRET_CAST(jobject, JS_GetPrivate(cx, obj));
@@ -94,6 +99,8 @@
return JS_FALSE;
}
+ tracer.log("scriptGlobal=%08x", unsigned(scriptGlobal.get()));
+
jboolean result = savedJNIEnv->CallBooleanMethod(externalObject, methodID,
NS_REINTERPRET_CAST(jint, scriptGlobal.get()), jModuleName);
if (savedJNIEnv->ExceptionCheck()) {