Bug 683218 - Disable __noSuchMethod__ support. r=jorendorff
authorJan de Mooij <jdemooij@mozilla.com>
Mon, 21 Sep 2015 19:53:36 +0200
changeset 263589 f677c411fd9ce10d3827f9ae3af90f92d1011d4b
parent 263588 fd4353cbde80b67a1851d84368c1c1807c1864e1
child 263590 b1628bb8771e1bce1a24983dcfe0cbc546e1356a
push id65355
push userjandemooij@gmail.com
push dateMon, 21 Sep 2015 17:54:04 +0000
treeherdermozilla-inbound@f677c411fd9c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff
bugs683218
milestone44.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 683218 - Disable __noSuchMethod__ support. r=jorendorff
js/src/builtin/TestingFunctions.cpp
js/src/jit-test/tests/baseline/bug945223.js
js/src/jit-test/tests/basic/bug717208.js
js/src/jit-test/tests/basic/bug732087.js
js/src/jit-test/tests/ion/callelem.js
js/src/jit-test/tests/jaeger/bug555922.js
js/src/jit-test/tests/jaeger/bug732423.js
js/src/jsapi.h
js/src/tests/js1_5/extensions/no-such-method.js
js/src/tests/js1_5/extensions/regress-564577.js
js/src/tests/js1_8/regress/regress-384412.js
js/src/tests/js1_8_5/extensions/noSuchMethod-symbols.js
js/src/vm/Interpreter.cpp
--- a/js/src/builtin/TestingFunctions.cpp
+++ b/js/src/builtin/TestingFunctions.cpp
@@ -2789,16 +2789,25 @@ GetLcovInfo(JSContext* cx, unsigned argc
 
     if (!str)
         return false;
 
     args.rval().setString(str);
     return true;
 }
 
+static bool
+EnableNoSuchMethod(JSContext* cx, unsigned argc, Value* vp)
+{
+    CallArgs args = CallArgsFromVp(argc, vp);
+    cx->runtime()->options().setNoSuchMethod(true);
+    args.rval().setUndefined();
+    return true;
+}
+
 #ifdef DEBUG
 static bool
 SetRNGState(JSContext* cx, unsigned argc, Value* vp)
 {
     CallArgs args = CallArgsFromVp(argc, vp);
     if (!args.requireAtLeast(cx, "SetRNGState", 1))
         return false;
 
@@ -3255,16 +3264,20 @@ gc::ZealModeHelpText),
 "  On non-ARM, no-op. On ARM, set the hardware capabilities. The list of \n"
 "  flags is available by calling this function with \"help\" as the flag's name"),
 
     JS_FN_HELP("getLcovInfo", GetLcovInfo, 1, 0,
 "getLcovInfo(global)",
 "  Generate LCOV tracefile for the given compartment.  If no global are provided then\n"
 "  the current global is used as the default one.\n"),
 
+    JS_FN_HELP("enableNoSuchMethod", EnableNoSuchMethod, 0, 0,
+"enableNoSuchMethod()",
+"  Enables the deprecated, non-standard __noSuchMethod__ feature.\n"),
+
 #ifdef DEBUG
     JS_FN_HELP("setRNGState", SetRNGState, 1, 0,
 "setRNGState(seed)",
 "  Set this compartment's RNG state.\n"),
 #endif
 
     JS_FS_HELP_END
 };
--- a/js/src/jit-test/tests/baseline/bug945223.js
+++ b/js/src/jit-test/tests/baseline/bug945223.js
@@ -12,16 +12,18 @@
 // __noSuchMethod__ (Bug 964574) at the moment, which cause a differential
 // behaviour.
 //
 // As we hope to remote __noSuchMethod__ soon (Bug 683218), we disable the mode
 // which force the selection of IonMonkey ICs.
 if (getJitCompilerOptions()["ion.forceinlineCaches"])
     setJitCompilerOption("ion.forceinlineCaches", 0);
 
+enableNoSuchMethod();
+
 Array.prototype.__proto__ = Proxy.create({
     getPropertyDescriptor: function(name) {
 	return (560566);
     },
 }, null);
 function f() {}
 function g() {}
 var x = [f,f,f,undefined,g];
--- a/js/src/jit-test/tests/basic/bug717208.js
+++ b/js/src/jit-test/tests/basic/bug717208.js
@@ -1,8 +1,10 @@
+enableNoSuchMethod();
+
 var count = 0;
 var a = {__noSuchMethod__: function() { count++; } }
 
 function f() {
   for (var i = 0; i < 10; i++) {
     try {
       a.b();
     } catch (e) {
--- a/js/src/jit-test/tests/basic/bug732087.js
+++ b/js/src/jit-test/tests/basic/bug732087.js
@@ -1,6 +1,7 @@
+enableNoSuchMethod();
 gczeal(2,1);
 var count = 0;
 var a = {__noSuchMethod__: function() { count++; } }
 for (var i = 0; i < 10; i++) {
   a.b();
 }
--- a/js/src/jit-test/tests/ion/callelem.js
+++ b/js/src/jit-test/tests/ion/callelem.js
@@ -1,8 +1,10 @@
+enableNoSuchMethod();
+
 var res = 0;
 var o = {};
 o.__noSuchMethod__ = function(x) { res += x; };
 
 function f() {
     for (var i=0; i<80; i++) {
         o[i](i);
     }
--- a/js/src/jit-test/tests/jaeger/bug555922.js
+++ b/js/src/jit-test/tests/jaeger/bug555922.js
@@ -1,8 +1,10 @@
+enableNoSuchMethod();
+
 (function() {
   let(z) {
     for each(b in [{}]) { ({
         get __noSuchMethod__() { return Function }
       }).w()
     }
   }
 })()
--- a/js/src/jit-test/tests/jaeger/bug732423.js
+++ b/js/src/jit-test/tests/jaeger/bug732423.js
@@ -1,8 +1,10 @@
+enableNoSuchMethod();
+
 function testStuff(x, y) {
     for (var i = 0; i < 60; i++) {
         x[y]();
         x[y];
     }
 }
 testStuff({"elements":function(){}}, "elements");
 
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -1151,17 +1151,18 @@ class JS_PUBLIC_API(RuntimeOptions) {
       : baseline_(true),
         ion_(true),
         asmJS_(true),
         nativeRegExp_(true),
         unboxedArrays_(false),
         asyncStack_(true),
         werror_(false),
         strictMode_(false),
-        extraWarnings_(false)
+        extraWarnings_(false),
+        noSuchMethod_(false)
     {
     }
 
     bool baseline() const { return baseline_; }
     RuntimeOptions& setBaseline(bool flag) {
         baseline_ = flag;
         return *this;
     }
@@ -1233,26 +1234,33 @@ class JS_PUBLIC_API(RuntimeOptions) {
         extraWarnings_ = flag;
         return *this;
     }
     RuntimeOptions& toggleExtraWarnings() {
         extraWarnings_ = !extraWarnings_;
         return *this;
     }
 
+    bool noSuchMethod() const { return noSuchMethod_; }
+    RuntimeOptions& setNoSuchMethod(bool flag) {
+        noSuchMethod_ = flag;
+        return *this;
+    }
+
   private:
     bool baseline_ : 1;
     bool ion_ : 1;
     bool asmJS_ : 1;
     bool nativeRegExp_ : 1;
     bool unboxedArrays_ : 1;
     bool asyncStack_ : 1;
     bool werror_ : 1;
     bool strictMode_ : 1;
     bool extraWarnings_ : 1;
+    bool noSuchMethod_ : 1;
 };
 
 JS_PUBLIC_API(RuntimeOptions&)
 RuntimeOptionsRef(JSRuntime* rt);
 
 JS_PUBLIC_API(RuntimeOptions&)
 RuntimeOptionsRef(JSContext* cx);
 
--- a/js/src/tests/js1_5/extensions/no-such-method.js
+++ b/js/src/tests/js1_5/extensions/no-such-method.js
@@ -1,19 +1,22 @@
+// |reftest| skip-if(!xulRuntime.shell)
 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 //-----------------------------------------------------------------------------
 var BUGNUMBER = 196097;
 var summary = '__noSuchMethod__ handler';
 var actual = '';
 var expect = '';
 
+enableNoSuchMethod();
+
 printBugNumber(BUGNUMBER);
 printStatus (summary);
  
 var o = {
   __noSuchMethod__: function (id, args)
   {
     return(id + '('+args.join(',')+')');
   }
--- a/js/src/tests/js1_5/extensions/regress-564577.js
+++ b/js/src/tests/js1_5/extensions/regress-564577.js
@@ -1,24 +1,25 @@
+// |reftest| skip-if(!xulRuntime.shell)
 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /*
  * Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/licenses/publicdomain/
  * Contributor: Matthew Draper <matthew@trebex.net>
  */
 
 var gTestfile = 'regress-564577.js';
 //-----------------------------------------------------------------------------
 var BUGNUMBER = 564577;
 var summary = '__noSuchMethod__ when property exists';
 var actual = '';
 var expect = '';
 
-
 //-----------------------------------------------------------------------------
+enableNoSuchMethod();
 test();
 //-----------------------------------------------------------------------------
 
 function test()
 {
   enterFunc ('test');
   printBugNumber(BUGNUMBER);
   printStatus (summary);
--- a/js/src/tests/js1_8/regress/regress-384412.js
+++ b/js/src/tests/js1_8/regress/regress-384412.js
@@ -1,21 +1,23 @@
+// |reftest| skip-if(!xulRuntime.shell)
 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 //-----------------------------------------------------------------------------
 var BUGNUMBER = 384412;
 var summary = 'Exercise frame handling code';
 var actual = '';
 var expect = '';
 
 
 //-----------------------------------------------------------------------------
+enableNoSuchMethod();
 test();
 //-----------------------------------------------------------------------------
 
 function test()
 {
   enterFunc ('test');
   printBugNumber(BUGNUMBER);
   printStatus (summary);
--- a/js/src/tests/js1_8_5/extensions/noSuchMethod-symbols.js
+++ b/js/src/tests/js1_8_5/extensions/noSuchMethod-symbols.js
@@ -1,11 +1,14 @@
+// |reftest| skip-if(!xulRuntime.shell)
 // Any copyright is dedicated to the Public Domain.
 // http://creativecommons.org/licenses/publicdomain/
 
+enableNoSuchMethod();
+
 var sym = Symbol("method");
 var hits = 0;
 var obj = {
     __noSuchMethod__: function (key, args) {
         assertEq(key, sym);
         assertEq(args.length, 2);
         assertEq(args[0], "hello");
         assertEq(args[1], "world");
--- a/js/src/vm/Interpreter.cpp
+++ b/js/src/vm/Interpreter.cpp
@@ -164,16 +164,19 @@ static const Class js_NoSuchMethodClass 
  *
  * where id is the name of the method that this invocation attempted to
  * call by name, and args is an Array containing this invocation's actual
  * parameters.
  */
 bool
 js::OnUnknownMethod(JSContext* cx, HandleObject obj, Value idval_, MutableHandleValue vp)
 {
+    if (!cx->runtime()->options().noSuchMethod())
+        return true;
+
     RootedValue idval(cx, idval_);
 
     RootedValue value(cx);
     if (!GetProperty(cx, obj, obj, cx->names().noSuchMethod, &value))
         return false;
 
     if (value.isObject()) {
         NativeObject* obj = NewNativeObjectWithClassProto(cx, &js_NoSuchMethodClass, nullptr);