diff --git a/js/src/builtin/TestingFunctions.cpp b/js/src/builtin/TestingFunctions.cpp index 1e61ca33dc1f..6e7218dd20be 100644 --- a/js/src/builtin/TestingFunctions.cpp +++ b/js/src/builtin/TestingFunctions.cpp @@ -1377,12 +1377,11 @@ ShellObjectMetadataCallback(JSContext* cx, JSObject*) } static bool -SetObjectMetadataCallback(JSContext* cx, unsigned argc, Value* vp) +EnableShellObjectMetadataCallback(JSContext* cx, unsigned argc, Value* vp) { CallArgs args = CallArgsFromVp(argc, vp); - bool enabled = args.length() ? ToBoolean(args[0]) : false; - SetObjectMetadataCallback(cx, enabled ? ShellObjectMetadataCallback : nullptr); + SetObjectMetadataCallback(cx, ShellObjectMetadataCallback); args.rval().setUndefined(); return true; @@ -2934,9 +2933,9 @@ gc::ZealModeHelpText), "isRelazifiableFunction(fun)", " Ture if fun is a JSFunction with a relazifiable JSScript."), - JS_FN_HELP("setObjectMetadataCallback", SetObjectMetadataCallback, 1, 0, -"setObjectMetadataCallback(fn)", -" Specify function to supply metadata for all newly created objects."), + JS_FN_HELP("enableShellObjectMetadataCallback", EnableShellObjectMetadataCallback, 0, 0, +"enableShellObjectMetadataCallback()", +" Use ShellObjectMetadataCallback to supply metadata for all newly created objects."), JS_FN_HELP("getObjectMetadata", GetObjectMetadata, 1, 0, "getObjectMetadata(obj)", diff --git a/js/src/jit-test/tests/baseline/metadata-hook-on-stack.js b/js/src/jit-test/tests/baseline/metadata-hook-on-stack.js index 7064772f1afe..a4df753898b8 100644 --- a/js/src/jit-test/tests/baseline/metadata-hook-on-stack.js +++ b/js/src/jit-test/tests/baseline/metadata-hook-on-stack.js @@ -4,7 +4,7 @@ function f() { for (var i=0; i<100; i++) { if (i === 20) - setObjectMetadataCallback(true); + enableShellObjectMetadataCallback(); var o = {x: 1}; if (i >= 20) { var md = getObjectMetadata(o); diff --git a/js/src/jit-test/tests/basic/bug951213.js b/js/src/jit-test/tests/basic/bug951213.js index 4f773cf03b77..be4f27261b6c 100644 --- a/js/src/jit-test/tests/basic/bug951213.js +++ b/js/src/jit-test/tests/basic/bug951213.js @@ -1,5 +1,5 @@ -setObjectMetadataCallback(function(obj) {}); +enableShellObjectMetadataCallback(); function foo(x, y) { this.g = x + y; } diff --git a/js/src/jit-test/tests/basic/bug951346.js b/js/src/jit-test/tests/basic/bug951346.js index 2034d6ba0f8f..fa68da631642 100644 --- a/js/src/jit-test/tests/basic/bug951346.js +++ b/js/src/jit-test/tests/basic/bug951346.js @@ -1,3 +1,3 @@ -setObjectMetadataCallback(function(obj) {}); +enableShellObjectMetadataCallback(); eval(uneval({'-1':true})); diff --git a/js/src/jit-test/tests/basic/bug951632.js b/js/src/jit-test/tests/basic/bug951632.js index a2e6a89adcdb..fa0dbd3bebec 100644 --- a/js/src/jit-test/tests/basic/bug951632.js +++ b/js/src/jit-test/tests/basic/bug951632.js @@ -1,4 +1,4 @@ -setObjectMetadataCallback(true); +enableShellObjectMetadataCallback(); var g = newGlobal() g.eval("function f(a) { return h(); }"); g.h = function () { diff --git a/js/src/jit-test/tests/basic/metadata-hook.js b/js/src/jit-test/tests/basic/metadata-hook.js index 38b24a8d7e79..a589b381afe4 100644 --- a/js/src/jit-test/tests/basic/metadata-hook.js +++ b/js/src/jit-test/tests/basic/metadata-hook.js @@ -1,5 +1,5 @@ -setObjectMetadataCallback(true); +enableShellObjectMetadataCallback(); function Foo() { this.x = 0; diff --git a/js/src/jit-test/tests/debug/Memory-trackingAllocationSites-03.js b/js/src/jit-test/tests/debug/Memory-trackingAllocationSites-03.js index 08b904777150..0447d7d32234 100644 --- a/js/src/jit-test/tests/debug/Memory-trackingAllocationSites-03.js +++ b/js/src/jit-test/tests/debug/Memory-trackingAllocationSites-03.js @@ -4,8 +4,6 @@ load(libdir + "asserts.js"); let dbg1, dbg2, root1, root2; -function FakeMetadata() {} - function isTrackingAllocations(global, dbgObj) { const site = dbgObj.makeDebuggeeValue(global.eval("({})")).allocationSite; if (site) { @@ -65,7 +63,7 @@ test("Setting trackingAllocationSites to true should throw if the debugger " + let d1r2 = dbg1.addDebuggee(root2); // Can't install allocation hooks for root2 with this set. - root2.setObjectMetadataCallback(function () { return new FakeMetadata; }); + root2.enableShellObjectMetadataCallback(); assertThrowsInstanceOf(() => dbg1.memory.trackingAllocationSites = true, Error); @@ -96,7 +94,7 @@ test("Re-enabling throws an error if we can't reinstall allocations tracking " + let d1r2 = dbg1.addDebuggee(root2); // Can't install allocation hooks for root2 with this set. - root2.setObjectMetadataCallback(function () { return new FakeMetadata; }); + root2.enableShellObjectMetadataCallback(); assertThrowsInstanceOf(() => dbg1.enabled = true, Error); diff --git a/js/src/jit-test/tests/gc/bug-1148383.js b/js/src/jit-test/tests/gc/bug-1148383.js index eea1d6c1ddcc..fcd7fcc0cb81 100644 --- a/js/src/jit-test/tests/gc/bug-1148383.js +++ b/js/src/jit-test/tests/gc/bug-1148383.js @@ -14,6 +14,6 @@ function reportCompare () { } reportCompare(); gczeal(4, 1000); -setObjectMetadataCallback(true); +enableShellObjectMetadataCallback(); for (var i = 0; i < 10000; ++i) reportCompare(); diff --git a/js/src/jit-test/tests/gc/bug-886560.js b/js/src/jit-test/tests/gc/bug-886560.js index 9880e9194187..bdd6a80c9cb1 100644 --- a/js/src/jit-test/tests/gc/bug-886560.js +++ b/js/src/jit-test/tests/gc/bug-886560.js @@ -1,5 +1,9 @@ // |jit-test| error: x is not defined -setObjectMetadataCallback(function(obj) { + +// enableShellObjectMetadataCallback ignores its argument, because we don't +// permit metadata callbacks to run JS any more, so this test may be +// unnecessary. We'll preserve its structure just in case. +enableShellObjectMetadataCallback(function(obj) { var res = {}; return res; }); diff --git a/js/src/jit-test/tests/gc/bug-935022.js b/js/src/jit-test/tests/gc/bug-935022.js index b4a5eb0fe614..d47bc3c9b555 100644 --- a/js/src/jit-test/tests/gc/bug-935022.js +++ b/js/src/jit-test/tests/gc/bug-935022.js @@ -1,4 +1,4 @@ function callback(obj) {} -setObjectMetadataCallback(callback); +enableShellObjectMetadataCallback(); gczeal(7); var statusitems = []; diff --git a/js/src/jit-test/tests/gc/bug-945280.js b/js/src/jit-test/tests/gc/bug-945280.js index 48b9695d8ed4..9340c6d3fb84 100644 --- a/js/src/jit-test/tests/gc/bug-945280.js +++ b/js/src/jit-test/tests/gc/bug-945280.js @@ -1,4 +1,4 @@ gczeal(7,1); -setObjectMetadataCallback(setObjectMetadataCallback); +enableShellObjectMetadataCallback(); gczeal(false); var statusitems = []; diff --git a/js/src/jit-test/tests/gc/bug-945285.js b/js/src/jit-test/tests/gc/bug-945285.js index c2d83d215f82..d2d6afd0c8c2 100644 --- a/js/src/jit-test/tests/gc/bug-945285.js +++ b/js/src/jit-test/tests/gc/bug-945285.js @@ -1,3 +1,3 @@ gczeal(11); function callback(obj) {} -setObjectMetadataCallback(callback); +enableShellObjectMetadataCallback(); diff --git a/js/src/jit-test/tests/gc/bug-961741.js b/js/src/jit-test/tests/gc/bug-961741.js index a4d0ee7a9d8b..c1777fb84de8 100644 --- a/js/src/jit-test/tests/gc/bug-961741.js +++ b/js/src/jit-test/tests/gc/bug-961741.js @@ -1,5 +1,5 @@ function r() { for (var x in undefined) {} } -setObjectMetadataCallback(true); +enableShellObjectMetadataCallback(); r(); diff --git a/js/src/jit-test/tests/ion/bug1006899.js b/js/src/jit-test/tests/ion/bug1006899.js index 6502bd7daf2d..f9549d6436ac 100644 --- a/js/src/jit-test/tests/ion/bug1006899.js +++ b/js/src/jit-test/tests/ion/bug1006899.js @@ -7,7 +7,7 @@ this.__defineGetter__("x", } ); function callback(obj) {} -setObjectMetadataCallback(callback); +enableShellObjectMetadataCallback(); evaluate("\ var { ArrayType, StructType, uint32 } = TypedObject;\ var L = 1024;\ diff --git a/js/src/jit-test/tests/ion/bug1054241.js b/js/src/jit-test/tests/ion/bug1054241.js index 80caf8d7a279..fb45badaf70d 100644 --- a/js/src/jit-test/tests/ion/bug1054241.js +++ b/js/src/jit-test/tests/ion/bug1054241.js @@ -1,7 +1,7 @@ setJitCompilerOption("baseline.warmup.trigger", 10); setJitCompilerOption("ion.warmup.trigger", 20); -setObjectMetadataCallback(true); +enableShellObjectMetadataCallback(); (function(){ for(var i = 0; i < 100; i++) { try{ diff --git a/js/src/jit-test/tests/ion/bug1057598.js b/js/src/jit-test/tests/ion/bug1057598.js index 36c84c0cade4..be3b5173c769 100644 --- a/js/src/jit-test/tests/ion/bug1057598.js +++ b/js/src/jit-test/tests/ion/bug1057598.js @@ -1,4 +1,7 @@ -setObjectMetadataCallback(function( r, ... d) {}); +// enableShellObjectMetadataCallback ignores its argument, because we don't +// permit metadata callbacks to run JS any more, so this test may be +// unnecessary. We'll preserve its structure just in case. +enableShellObjectMetadataCallback(function( r, ... d) {}); setJitCompilerOption("ion.warmup.trigger", 20); var uceFault = function (i) { if (i > 98) diff --git a/js/src/jit-test/tests/ion/recover-lambdas-bug1113940.js b/js/src/jit-test/tests/ion/recover-lambdas-bug1113940.js index 0d0ebf894d40..dd18e82a69f1 100644 --- a/js/src/jit-test/tests/ion/recover-lambdas-bug1113940.js +++ b/js/src/jit-test/tests/ion/recover-lambdas-bug1113940.js @@ -4,7 +4,11 @@ gczeal(14); // The object metadata callback can iterate over the stack. Thus during the // allocation of the lambda we might inspect the stack which is still incomplete // because the lambda is not yet reconstructed. -setObjectMetadataCallback(function() {}); +// +// enableShellObjectMetadataCallback ignores its argument, because we don't +// permit metadata callbacks to run JS any more, so this test may be +// unnecessary. We'll preserve its structure just in case. +enableShellObjectMetadataCallback(function() {}); function f() { (function() { '' ^ Object @@ -17,7 +21,8 @@ for (var j = 0; j < 99; ++j) { try { x = true; - setObjectMetadataCallback(function([x, y, z], ... Debugger) {}); + // Same comment as above. + enableShellObjectMetadataCallback(function([x, y, z], ... Debugger) {}); for (var i = 0; i < 10; ++i) { var f = function() { function g() {