Bug 1135428 - OdinMonkey: remove compileAndGo restriction (r=bbouvier)
authorLuke Wagner <luke@mozilla.com>
Fri, 20 Mar 2015 08:52:14 -0500
changeset 252041 e246f0d09dbec63784667f55076df124a4904c25
parent 252040 c2724e2f9de9c64a3e811fcfcce75c07ac50eaff
child 252042 3c635dd1d624cfbdb4ae379a39d599ecc405168b
push id1174
push usernsm.nikhil@gmail.com
push dateSun, 22 Mar 2015 01:24:25 +0000
reviewersbbouvier
bugs1135428
milestone39.0a1
Bug 1135428 - OdinMonkey: remove compileAndGo restriction (r=bbouvier)
js/src/asmjs/AsmJSValidate.cpp
js/src/jit-test/tests/asm.js/testBug893519.js
js/src/jsscript.cpp
--- a/js/src/asmjs/AsmJSValidate.cpp
+++ b/js/src/asmjs/AsmJSValidate.cpp
@@ -9355,19 +9355,16 @@ EstablishPreconditions(ExclusiveContext 
         return Warn(parser, JSMSG_USE_ASM_TYPE_FAIL, "Disabled by lack of floating point support");
 
     if (cx->gcSystemPageSize() != AsmJSPageSize)
         return Warn(parser, JSMSG_USE_ASM_TYPE_FAIL, "Disabled by non 4KiB system page size");
 
     if (!parser.options().asmJSOption)
         return Warn(parser, JSMSG_USE_ASM_TYPE_FAIL, "Disabled by javascript.options.asmjs in about:config");
 
-    if (!parser.options().compileAndGo)
-        return Warn(parser, JSMSG_USE_ASM_TYPE_FAIL, "Temporarily disabled for event-handler and other cloneable scripts");
-
     if (cx->compartment()->debuggerObservesAsmJS())
         return Warn(parser, JSMSG_USE_ASM_TYPE_FAIL, "Disabled by debugger");
 
     if (parser.pc->isGenerator())
         return Warn(parser, JSMSG_USE_ASM_TYPE_FAIL, "Disabled by generator context");
 
     if (parser.pc->isArrowFunction())
         return Warn(parser, JSMSG_USE_ASM_TYPE_FAIL, "Disabled by arrow function context");
--- a/js/src/jit-test/tests/asm.js/testBug893519.js
+++ b/js/src/jit-test/tests/asm.js/testBug893519.js
@@ -1,4 +1,5 @@
+// |jit-test| error:Error
 var g = newGlobal();
 evaluate("function h() { function f() { 'use asm'; function g() { return 42 } return g } return f }", { compileAndGo:false, global:g});
 var h = clone(g.h);
 assertEq(h()()(), 42);
--- a/js/src/jsscript.cpp
+++ b/js/src/jsscript.cpp
@@ -3004,17 +3004,21 @@ js::CloneScript(JSContext *cx, HandleObj
                     enclosingScope = objects[FindScopeObjectIndex(src, *enclosingBlock)];
                 else
                     enclosingScope = fun;
 
                 clone = CloneNestedScopeObject(cx, enclosingScope, innerBlock);
             } else if (obj->is<JSFunction>()) {
                 RootedFunction innerFun(cx, &obj->as<JSFunction>());
                 if (innerFun->isNative()) {
-                    assertSameCompartment(cx, innerFun);
+                    if (cx->compartment() != innerFun->compartment()) {
+                        MOZ_ASSERT(innerFun->isAsmJSNative());
+                        JS_ReportError(cx, "AsmJS modules do not yet support cloning.");
+                        return false;
+                    }
                     clone = innerFun;
                 } else {
                     if (innerFun->isInterpretedLazy()) {
                         AutoCompartment ac(cx, innerFun);
                         if (!innerFun->getOrCreateScript(cx))
                             return nullptr;
                     }
                     RootedObject staticScope(cx, innerFun->nonLazyScript()->enclosingStaticScope());