Commit dfcd5456 authored by henrique.ferreiro's avatar henrique.ferreiro Committed by Commit bot

Remove the 'caller' property from the strict-mode arguments map

This was removed from ECMAScript in the September 2016 TC39 meeting, see https://github.com/tc39/ecma262/issues/670.

BUG=v8:5535

Review-Url: https://codereview.chromium.org/2430383004
Cr-Commit-Position: refs/heads/master@{#40770}
parent 5b1de36d
......@@ -2519,23 +2519,20 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
const PropertyAttributes attributes =
static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY);
// Create the ThrowTypeError functions.
// Create the ThrowTypeError function.
Handle<AccessorPair> callee = factory->NewAccessorPair();
Handle<AccessorPair> caller = factory->NewAccessorPair();
Handle<JSFunction> poison = GetStrictArgumentsPoisonFunction();
// Install the ThrowTypeError functions.
// Install the ThrowTypeError function.
callee->set_getter(*poison);
callee->set_setter(*poison);
caller->set_getter(*poison);
caller->set_setter(*poison);
// Create the map. Allocate one in-object field for length.
Handle<Map> map = factory->NewMap(
JS_ARGUMENTS_TYPE, JSStrictArgumentsObject::kSize, FAST_ELEMENTS);
// Create the descriptor array for the arguments object.
Map::EnsureDescriptorSlack(map, 3);
Map::EnsureDescriptorSlack(map, 2);
{ // length
DataDescriptor d(factory->length_string(),
......@@ -2548,11 +2545,6 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
attributes);
map->AppendDescriptor(&d);
}
{ // caller
AccessorConstantDescriptor d(factory->caller_string(), caller,
attributes);
map->AppendDescriptor(&d);
}
// @@iterator method is added later.
DCHECK_EQ(native_context()->object_function()->prototype(),
......
......@@ -164,14 +164,15 @@
SyntaxError);
var D = class extends function() {
arguments.caller;
this.args = arguments;
} {};
assertThrows(function() {
Object.getPrototypeOf(D).arguments;
}, TypeError);
assertThrows(function() {
new D;
}, TypeError);
var e = new D();
assertThrows(() => e.args.callee, TypeError);
assertEquals(undefined, Object.getOwnPropertyDescriptor(e.args, 'caller'));
assertFalse('caller' in e.args);
})();
......
......@@ -136,11 +136,9 @@ var O = {
(function testUnmappedArguments() {
// Strict/Unmapped arguments should always be used for functions with rest
// parameters
assertThrows(function(...rest) { return arguments.caller; }, TypeError);
assertThrows(function(...rest) { return arguments.callee; }, TypeError);
// TODO(caitp): figure out why this doesn't throw sometimes, even though the
// getter always does =)
// assertThrows(function(...rest) { arguments.caller = 1; }, TypeError);
// assertThrows(function(...rest) { arguments.callee = 1; }, TypeError);
})();
......
......@@ -26,13 +26,13 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Tests that we always return the same type error function when trying to
// access strict mode caller and callee.
// access or set strict mode callee.
function foo() {
'use strict';
return arguments;
}
var get1 = Object.getOwnPropertyDescriptor(foo(), "caller").get;
var get2 = Object.getOwnPropertyDescriptor(foo(), "callee").get;
assertEquals(get1, get2);
var get = Object.getOwnPropertyDescriptor(foo(), "callee").get;
var set = Object.getOwnPropertyDescriptor(foo(), "callee").set;
assertEquals(get, set);
......@@ -1111,14 +1111,14 @@ function CheckArgumentsPillDescriptor(func, name) {
}
var args = strict();
CheckArgumentsPillDescriptor(args, "caller");
assertEquals(undefined, Object.getOwnPropertyDescriptor(args, "caller"));
CheckArgumentsPillDescriptor(args, "callee");
args = strict(17, "value", strict);
assertEquals(17, args[0])
assertEquals("value", args[1])
assertEquals(strict, args[2]);
CheckArgumentsPillDescriptor(args, "caller");
assertEquals(undefined, Object.getOwnPropertyDescriptor(args, "caller"));
CheckArgumentsPillDescriptor(args, "callee");
function outer() {
......@@ -1130,14 +1130,14 @@ function CheckArgumentsPillDescriptor(func, name) {
}
var args = outer()();
CheckArgumentsPillDescriptor(args, "caller");
assertEquals(undefined, Object.getOwnPropertyDescriptor(args, "caller"));
CheckArgumentsPillDescriptor(args, "callee");
args = outer()(17, "value", strict);
assertEquals(17, args[0])
assertEquals("value", args[1])
assertEquals(strict, args[2]);
CheckArgumentsPillDescriptor(args, "caller");
assertEquals(undefined, Object.getOwnPropertyDescriptor(args, "caller"));
CheckArgumentsPillDescriptor(args, "callee");
})();
......
......@@ -202,6 +202,17 @@
# https://bugs.chromium.org/p/v8/issues/detail?id=4034
'built-ins/ThrowTypeError/unique-per-realm-function-proto': [FAIL],
# https://bugs.chromium.org/p/v8/issues/detail?id=5535
'built-ins/ThrowTypeError/unique-per-realm-non-simple': [FAIL],
'built-ins/ThrowTypeError/unique-per-realm-unmapped-args': [FAIL],
'language/arguments-object/10.6-13-b-1-s': [FAIL],
'language/arguments-object/10.6-13-b-2-s': [FAIL],
'language/arguments-object/10.6-13-b-3-s': [FAIL],
'language/arguments-object/10.6-14-1-s': [FAIL],
'language/arguments-object/10.6-14-b-1-s': [FAIL],
'language/arguments-object/10.6-14-b-4-s': [FAIL],
'language/statements/class/strict-mode/arguments-caller': [FAIL],
# https://bugs.chromium.org/p/v8/issues/detail?id=4231
'language/eval-code/direct/var-env-lower-lex-catch-non-strict': [FAIL],
......
......@@ -80,13 +80,13 @@ PASS (function (){(function (){var a; function f() {'use strict'; delete a;} })(
PASS (function (){'use strict'; with(1){};}) threw exception SyntaxError: Strict mode code may not include a with statement.
PASS (function (){(function (){'use strict'; with(1){};})}) threw exception SyntaxError: Strict mode code may not include a with statement.
PASS (function (){'use strict'; arguments.callee; })() threw exception TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them.
PASS (function (){'use strict'; arguments.caller; })() threw exception TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them.
PASS (function (){'use strict'; arguments.caller; })() is undefined.
PASS (function f(){'use strict'; f.arguments; })() threw exception TypeError: 'caller' and 'arguments' are restricted function properties and cannot be accessed in this context..
PASS (function f(){'use strict'; f.caller; })() threw exception TypeError: 'caller' and 'arguments' are restricted function properties and cannot be accessed in this context..
PASS (function f(){'use strict'; f.arguments=5; })() threw exception TypeError: 'caller' and 'arguments' are restricted function properties and cannot be accessed in this context..
PASS (function f(){'use strict'; f.caller=5; })() threw exception TypeError: 'caller' and 'arguments' are restricted function properties and cannot be accessed in this context..
PASS (function (arg){'use strict'; arguments.callee; })() threw exception TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them.
PASS (function (arg){'use strict'; arguments.caller; })() threw exception TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them.
PASS (function (arg){'use strict'; arguments.caller; })() is undefined.
PASS (function f(arg){'use strict'; f.arguments; })() threw exception TypeError: 'caller' and 'arguments' are restricted function properties and cannot be accessed in this context..
PASS (function f(arg){'use strict'; f.caller; })() threw exception TypeError: 'caller' and 'arguments' are restricted function properties and cannot be accessed in this context..
PASS (function f(arg){'use strict'; f.arguments=5; })() threw exception TypeError: 'caller' and 'arguments' are restricted function properties and cannot be accessed in this context..
......@@ -200,8 +200,7 @@ PASS (function (){var a = true; eval('"use strict"; var a = false'); return a; }
PASS (function f(arg){'use strict'; return Object.getOwnPropertyDescriptor(f.__proto__, 'arguments').value; })() is undefined.
PASS (function f(arg){'use strict'; return Object.getOwnPropertyDescriptor(f.__proto__, 'caller').value; })() is undefined.
PASS (function f(arg){'use strict'; return Object.getOwnPropertyDescriptor(arguments, 'callee').value; })() is undefined.
PASS (function f(arg){'use strict'; return Object.getOwnPropertyDescriptor(arguments, 'caller').value; })() is undefined.
PASS (function f(arg){'use strict'; var descriptor = Object.getOwnPropertyDescriptor(arguments, 'caller'); return descriptor.get === descriptor.set; })() is true
PASS (function f(arg){'use strict'; return Object.getOwnPropertyDescriptor(arguments, 'caller'); })() is undefined.
PASS (function f(arg){'use strict'; var descriptor = Object.getOwnPropertyDescriptor(arguments, 'callee'); return descriptor.get === descriptor.set; })() is true
PASS (function f(arg){'use strict'; var descriptor = Object.getOwnPropertyDescriptor(f.__proto__, 'caller'); return descriptor.get === descriptor.set; })() is true
PASS (function f(arg){'use strict'; var descriptor = Object.getOwnPropertyDescriptor(f.__proto__, 'arguments'); return descriptor.get === descriptor.set; })() is true
......
......@@ -97,13 +97,13 @@ shouldBeSyntaxError("(function (){'use strict'; var a; delete a;})()");
shouldBeSyntaxError("(function (){var a; function f() {'use strict'; delete a;} })()");
shouldBeSyntaxError("(function (){'use strict'; with(1){};})");
shouldThrow("(function (){'use strict'; arguments.callee; })()");
shouldThrow("(function (){'use strict'; arguments.caller; })()");
shouldBeUndefined("(function (){'use strict'; arguments.caller; })()");
shouldThrow("(function f(){'use strict'; f.arguments; })()");
shouldThrow("(function f(){'use strict'; f.caller; })()");
shouldThrow("(function f(){'use strict'; f.arguments=5; })()");
shouldThrow("(function f(){'use strict'; f.caller=5; })()");
shouldThrow("(function (arg){'use strict'; arguments.callee; })()");
shouldThrow("(function (arg){'use strict'; arguments.caller; })()");
shouldBeUndefined("(function (arg){'use strict'; arguments.caller; })()");
shouldThrow("(function f(arg){'use strict'; f.arguments; })()");
shouldThrow("(function f(arg){'use strict'; f.caller; })()");
shouldThrow("(function f(arg){'use strict'; f.arguments=5; })()");
......@@ -199,8 +199,7 @@ shouldBeTrue("(function (){var a = true; eval('\"use strict\"; var a = false');
shouldBeUndefined("(function f(arg){'use strict'; return Object.getOwnPropertyDescriptor(f.__proto__, 'arguments').value; })()");
shouldBeUndefined("(function f(arg){'use strict'; return Object.getOwnPropertyDescriptor(f.__proto__, 'caller').value; })()");
shouldBeUndefined("(function f(arg){'use strict'; return Object.getOwnPropertyDescriptor(arguments, 'callee').value; })()");
shouldBeUndefined("(function f(arg){'use strict'; return Object.getOwnPropertyDescriptor(arguments, 'caller').value; })()");
shouldBeTrue("(function f(arg){'use strict'; var descriptor = Object.getOwnPropertyDescriptor(arguments, 'caller'); return descriptor.get === descriptor.set; })()");
shouldBeUndefined("(function f(arg){'use strict'; return Object.getOwnPropertyDescriptor(arguments, 'caller'); })()");
shouldBeTrue("(function f(arg){'use strict'; var descriptor = Object.getOwnPropertyDescriptor(arguments, 'callee'); return descriptor.get === descriptor.set; })()");
shouldBeTrue("(function f(arg){'use strict'; var descriptor = Object.getOwnPropertyDescriptor(f.__proto__, 'caller'); return descriptor.get === descriptor.set; })()");
shouldBeTrue("(function f(arg){'use strict'; var descriptor = Object.getOwnPropertyDescriptor(f.__proto__, 'arguments'); return descriptor.get === descriptor.set; })()");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment