Bug 1542130 - Fix asm.js check in PrivateScriptData::Clone to check for realms instead of compartments. r=luke
authorJan de Mooij <jdemooij@mozilla.com>
Mon, 08 Apr 2019 09:30:23 +0000
changeset 468325 4ff589e86c0a0c5c9a36c3876977633eedbab153
parent 468324 e2fdd460d7b1fb022134963b57578df7a9485a2c
child 468326 7e2aef09165a8ea94a27a8ee51537bb8f9c8a99e
push id35833
push userdvarga@mozilla.com
push dateMon, 08 Apr 2019 16:16:26 +0000
treeherdermozilla-central@50ce9167f1ce [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs1542130
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1542130 - Fix asm.js check in PrivateScriptData::Clone to check for realms instead of compartments. r=luke Differential Revision: https://phabricator.services.mozilla.com/D26318
js/src/jit-test/tests/asm.js/bug1542130.js
js/src/vm/JSScript.cpp
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/asm.js/bug1542130.js
@@ -0,0 +1,14 @@
+// |jit-test| error:AsmJS modules do not yet support cloning; skip-if: !isAsmJSCompilationAvailable()
+var g = newGlobal();
+g.evaluate(`
+  function h() {
+    function f() {
+      'use asm';
+      function g() {}
+      return g
+    }
+    return f;
+  }
+`);
+var h = clone(g.h);
+h();
--- a/js/src/vm/JSScript.cpp
+++ b/js/src/vm/JSScript.cpp
@@ -4118,17 +4118,17 @@ bool PrivateScriptData::Clone(JSContext*
     for (const GCPtrObject& elem : srcData->objects()) {
       obj = elem.get();
       clone = nullptr;
       if (obj->is<RegExpObject>()) {
         clone = CloneScriptRegExpObject(cx, obj->as<RegExpObject>());
       } else if (obj->is<JSFunction>()) {
         RootedFunction innerFun(cx, &obj->as<JSFunction>());
         if (innerFun->isNative()) {
-          if (cx->compartment() != innerFun->compartment()) {
+          if (cx->realm() != innerFun->realm()) {
             MOZ_ASSERT(innerFun->isAsmJSNative());
             JS_ReportErrorASCII(cx,
                                 "AsmJS modules do not yet support cloning.");
             return false;
           }
           clone = innerFun;
         } else {
           if (innerFun->isInterpretedLazy()) {