Commit 5f4a0d69 authored by Michael Achenbach's avatar Michael Achenbach Committed by Commit Bot

Revert "[runtime] Make all built-in functions strict."

This reverts commit 72b88fda.

Reason for revert: Changes a layout test:
https://build.chromium.org/p/client.v8.fyi/builders/V8-Blink%20Linux%2064/builds/16595

Original change's description:
> [runtime] Make all built-in functions strict.
> 
> According to ES#sec-built-in-function-objects all built-in functions
> must be strict.
> 
> This is a preliminary CL before changing the way we define built-in
> functions in native JS files.
> 
> Bug: v8:6459
> Change-Id: I8e60b342f04ea1b0843fe1990334cbb9b26ebac4
> Reviewed-on: https://chromium-review.googlesource.com/546215
> Reviewed-by: Toon Verwaest <verwaest@chromium.org>
> Reviewed-by: Adam Klein <adamk@chromium.org>
> Commit-Queue: Igor Sheludko <ishell@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#46237}

TBR=adamk@chromium.org,ishell@chromium.org,verwaest@chromium.org

Change-Id: Ic458b478b2dd23aae7ea2a51aa6052c1f5931c56
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: v8:6459
Reviewed-on: https://chromium-review.googlesource.com/549322Reviewed-by: 's avatarMichael Achenbach <machenbach@chromium.org>
Commit-Queue: Michael Achenbach <machenbach@chromium.org>
Cr-Commit-Position: refs/heads/master@{#46242}
parent 3e9797f7
This diff is collapsed.
...@@ -1486,7 +1486,6 @@ Handle<JSFunction> Factory::NewFunction(Handle<Map> map, ...@@ -1486,7 +1486,6 @@ Handle<JSFunction> Factory::NewFunction(Handle<Map> map,
Handle<Context> context(isolate()->native_context()); Handle<Context> context(isolate()->native_context());
Handle<SharedFunctionInfo> info = Handle<SharedFunctionInfo> info =
NewSharedFunctionInfo(name, code, map->is_constructor()); NewSharedFunctionInfo(name, code, map->is_constructor());
// Proper language mode in shared function info will be set outside.
DCHECK(is_sloppy(info->language_mode())); DCHECK(is_sloppy(info->language_mode()));
DCHECK(!map->IsUndefined(isolate())); DCHECK(!map->IsUndefined(isolate()));
DCHECK( DCHECK(
...@@ -1505,10 +1504,8 @@ Handle<JSFunction> Factory::NewFunction(Handle<Map> map, ...@@ -1505,10 +1504,8 @@ Handle<JSFunction> Factory::NewFunction(Handle<Map> map,
Handle<JSFunction> Factory::NewFunction(Handle<String> name) { Handle<JSFunction> Factory::NewFunction(Handle<String> name) {
Handle<JSFunction> result = return NewFunction(
NewFunction(isolate()->sloppy_function_map(), name, MaybeHandle<Code>()); isolate()->sloppy_function_map(), name, MaybeHandle<Code>());
DCHECK(is_sloppy(result->shared()->language_mode()));
return result;
} }
...@@ -1518,9 +1515,7 @@ Handle<JSFunction> Factory::NewFunctionWithoutPrototype(Handle<String> name, ...@@ -1518,9 +1515,7 @@ Handle<JSFunction> Factory::NewFunctionWithoutPrototype(Handle<String> name,
Handle<Map> map = is_strict Handle<Map> map = is_strict
? isolate()->strict_function_without_prototype_map() ? isolate()->strict_function_without_prototype_map()
: isolate()->sloppy_function_without_prototype_map(); : isolate()->sloppy_function_without_prototype_map();
Handle<JSFunction> result = NewFunction(map, name, code); return NewFunction(map, name, code);
result->shared()->set_language_mode(is_strict ? STRICT : SLOPPY);
return result;
} }
...@@ -1531,7 +1526,6 @@ Handle<JSFunction> Factory::NewFunction(Handle<String> name, Handle<Code> code, ...@@ -1531,7 +1526,6 @@ Handle<JSFunction> Factory::NewFunction(Handle<String> name, Handle<Code> code,
: isolate()->sloppy_function_map(); : isolate()->sloppy_function_map();
Handle<JSFunction> result = NewFunction(map, name, code); Handle<JSFunction> result = NewFunction(map, name, code);
result->set_prototype_or_initial_map(*prototype); result->set_prototype_or_initial_map(*prototype);
result->shared()->set_language_mode(is_strict ? STRICT : SLOPPY);
return result; return result;
} }
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
// found in the LICENSE file. // found in the LICENSE file.
(function(global, utils) { (function(global, utils) {
"use strict"; "use strict";
%CheckIsBootstrapping(); %CheckIsBootstrapping();
......
...@@ -4,8 +4,6 @@ ...@@ -4,8 +4,6 @@
(function(global, utils) { (function(global, utils) {
"use strict";
%CheckIsBootstrapping(); %CheckIsBootstrapping();
function MaxSimple(a, b) { function MaxSimple(a, b) {
......
...@@ -6,8 +6,6 @@ ...@@ -6,8 +6,6 @@
(function(global, utils) { (function(global, utils) {
"use strict";
%CheckIsBootstrapping(); %CheckIsBootstrapping();
// ------------------------------------------------------------------- // -------------------------------------------------------------------
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
(function(global, utils) { (function(global, utils) {
"use strict"; 'use strict';
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Imports // Imports
......
...@@ -4,8 +4,6 @@ ...@@ -4,8 +4,6 @@
(function(global, utils) { (function(global, utils) {
"use strict";
%CheckIsBootstrapping(); %CheckIsBootstrapping();
// ------------------------------------------------------------------- // -------------------------------------------------------------------
......
...@@ -4,8 +4,6 @@ ...@@ -4,8 +4,6 @@
(function(global, utils) { (function(global, utils) {
"use strict";
%CheckIsBootstrapping(); %CheckIsBootstrapping();
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
......
...@@ -46,9 +46,11 @@ f(null); ...@@ -46,9 +46,11 @@ f(null);
// Check called from eval. // Check called from eval.
eval('f(null)'); eval('f(null)');
// Check called from builtin functions. // Check called from strict builtin functions.
[null, null].sort(f); [null, null].sort(f);
[null].forEach(f, null); [null].forEach(f, null);
// Check called from sloppy builtin functions.
"abel".replace(/b/g, function h() { "abel".replace(/b/g, function h() {
assertEquals(null, h.caller); assertEquals(String.prototype.replace, h.caller);
}); });
...@@ -26,11 +26,7 @@ ...@@ -26,11 +26,7 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
var builtInPropertyNames = [ var builtInPropertyNames = [
'prototype', 'length', 0, 1, '$1', 'name', 'message', 'constructor' 'prototype', 'length', 'caller', 0, 1, '$1', 'arguments', 'name', 'message', 'constructor'
];
var builtInPropertyNamesMayThrow = [
'caller', 'arguments'
]; ];
function getAnException() { function getAnException() {
...@@ -81,13 +77,6 @@ function runTest(fun) { ...@@ -81,13 +77,6 @@ function runTest(fun) {
var propertyName = builtInPropertyNames[k]; var propertyName = builtInPropertyNames[k];
fun(obj, propertyName); fun(obj, propertyName);
} }
for (var k in builtInPropertyNamesMayThrow) {
var propertyName = builtInPropertyNamesMayThrow[k];
try {
fun(obj, propertyName);
} catch (e) {
}
}
} }
} }
} }
......
...@@ -625,11 +625,6 @@ if (testFailed) { ...@@ -625,11 +625,6 @@ if (testFailed) {
} }
(function ExtractedAsyncFromSyncIteratorMethods() { (function ExtractedAsyncFromSyncIteratorMethods() {
// TODO(ishell, caitp): Rewrite the test without using function.caller.
// According to ES#sec-built-in-function-objects all built-in functions
// must be strict. And ES#sec-forbidden-extensions states that the value of
// a function.caller must not be a strict function.
return;
// Async-from-Sync iterator methods can be extracted via function.caller. // Async-from-Sync iterator methods can be extracted via function.caller.
// TODO(caitp): test extracted `throw` method using yield* in async generator. // TODO(caitp): test extracted `throw` method using yield* in async generator.
let extractor = [0, 1, 2, 3, 4,5,6,7,8,9]; let extractor = [0, 1, 2, 3, 4,5,6,7,8,9];
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
let success = false; let success = false;
function f() { function f() {
success = (f.caller === null); success = (f.caller.arguments === null);
} }
Promise.resolve().then(f); Promise.resolve().then(f);
%RunMicrotasks(); %RunMicrotasks();
......
...@@ -12,9 +12,6 @@ function CheckMethodEx(object, prop_name, function_name, length) { ...@@ -12,9 +12,6 @@ function CheckMethodEx(object, prop_name, function_name, length) {
assertTrue(desc.configurable); assertTrue(desc.configurable);
assertTrue(desc.writable); assertTrue(desc.writable);
assertThrows(() => new desc.value()); assertThrows(() => new desc.value());
// Check that built-in function is strict.
assertThrows(() => desc.value.arguments);
assertThrows(() => desc.value.caller);
} }
function CheckMethod(object, name, length) { function CheckMethod(object, name, length) {
...@@ -35,9 +32,6 @@ function CheckGetter(object, name) { ...@@ -35,9 +32,6 @@ function CheckGetter(object, name) {
assertEquals(0, desc.get.length); assertEquals(0, desc.get.length);
assertFalse(desc.enumerable); assertFalse(desc.enumerable);
assertTrue(desc.configurable); assertTrue(desc.configurable);
// Check that built-in function is strict.
assertThrows(() => desc.get.arguments);
assertThrows(() => desc.get.caller);
} }
......
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