Bug 1145491 part 4. Emit JSOP_IMPLICITTHIS for JSOP_GETGNAME as well, because otherwise bareword calls in polluted-global scripts won't work right. r=luke
☠☠ backed out by 3b7a4d9da546 ☠ ☠
authorBoris Zbarsky <bzbarsky@mit.edu>
Fri, 20 Mar 2015 21:34:18 -0400
changeset 263678 151e4cdb34cfe930c221bb2e84377e3f260c5414
parent 263677 97b16da6169bb0abc619d95ebddbcc22ba53b1c6
child 263679 8066b21e74a00e4613ddbf27d70777c95dd27c69
push id4718
push userraliiev@mozilla.com
push dateMon, 11 May 2015 18:39:53 +0000
treeherdermozilla-beta@c20c4ef55f08 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs1145491
milestone39.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 1145491 part 4. Emit JSOP_IMPLICITTHIS for JSOP_GETGNAME as well, because otherwise bareword calls in polluted-global scripts won't work right. r=luke
js/src/frontend/BytecodeEmitter.cpp
js/src/jit-test/tests/basic/weird-scopechains.js
js/src/vm/Xdr.h
--- a/js/src/frontend/BytecodeEmitter.cpp
+++ b/js/src/frontend/BytecodeEmitter.cpp
@@ -2330,17 +2330,17 @@ EmitNameOp(ExclusiveContext *cx, Bytecod
         } else {
             if (!EmitAtomOp(cx, pn, op, bce))
                 return false;
         }
     }
 
     /* Need to provide |this| value for call */
     if (callContext) {
-        if (op == JSOP_GETNAME) {
+        if (op == JSOP_GETNAME || op == JSOP_GETGNAME) {
             JSOp thisOp =
                 bce->needsImplicitThis() ? JSOP_IMPLICITTHIS : JSOP_GIMPLICITTHIS;
             if (!EmitAtomOp(cx, pn, thisOp, bce))
                 return false;
         } else {
             if (Emit1(cx, bce, JSOP_UNDEFINED) < 0)
                 return false;
         }
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/basic/weird-scopechains.js
@@ -0,0 +1,27 @@
+function checkNameLookup() {
+    return "global";
+}
+
+function assertWithMessage(got, expected, message) {
+    assertEq(message + ": " + got, message + ": " + expected);
+}
+
+// Create our test func via "evaluate" so it won't be compileAndGo and
+// we can clone it.
+evaluate(`function testFunc() {
+    assertWithMessage(checkNameLookup(), "local", "nameLookup");
+    assertWithMessage(checkThisBinding(), "local", "thisBinding");
+}`, { compileAndGo: false });
+
+var obj = {
+    checkNameLookup: function() {
+	return "local";
+    },
+
+    checkThisBinding: function() {
+	return this.checkNameLookup();
+    },
+};
+
+var cloneFunc = clone(testFunc, obj);
+cloneFunc();
--- a/js/src/vm/Xdr.h
+++ b/js/src/vm/Xdr.h
@@ -24,17 +24,17 @@ namespace js {
  * versions.  If deserialization fails, the data should be invalidated if
  * possible.
  *
  * When you change this, run make_opcode_doc.py and copy the new output into
  * this wiki page:
  *
  *  https://developer.mozilla.org/en-US/docs/SpiderMonkey/Internals/Bytecode
  */
-static const uint32_t XDR_BYTECODE_VERSION_SUBTRAHEND = 265;
+static const uint32_t XDR_BYTECODE_VERSION_SUBTRAHEND = 266;
 static const uint32_t XDR_BYTECODE_VERSION =
     uint32_t(0xb973c0de - XDR_BYTECODE_VERSION_SUBTRAHEND);
 
 static_assert(JSErr_Limit == 388,
               "GREETINGS, POTENTIAL SUBTRAHEND INCREMENTER! If you added or "
               "removed MSG_DEFs from js.msg, you should increment "
               "XDR_BYTECODE_VERSION_SUBTRAHEND and update this assertion's "
               "expected JSErr_Limit value.");