Commit 9090c6b0 authored by mstarzinger's avatar mstarzinger Committed by Commit bot

Use new.target in favor of %_IsConstructCall intrinsic (2).

This switches all remaining builtin methods to use the ES6 new.target
value when determined whether being called as a constructor or not. This
is prepatory work for fully deprecating the aforementioned intrinsic.

R=rossberg@chromium.org

Review URL: https://codereview.chromium.org/1474343002

Cr-Commit-Position: refs/heads/master@{#32447}
parent 54469cbb
......@@ -29,7 +29,7 @@ utils.Import(function(from) {
// -------------------------------------------------------------------
function ArrayBufferConstructor(length) { // length = 1
if (%_IsConstructCall()) {
if (!IS_UNDEFINED(new.target)) {
var byteLength = ToPositiveInteger(length, kInvalidArrayBufferLength);
%ArrayBufferInitialize(this, byteLength, kNotShared);
} else {
......
......@@ -197,21 +197,21 @@ function addBoundMethod(obj, methodName, implementation, length) {
var boundMethod;
if (IS_UNDEFINED(length) || length === 2) {
boundMethod = function(x, y) {
if (%_IsConstructCall()) {
if (!IS_UNDEFINED(new.target)) {
throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
}
return implementation(that, x, y);
}
} else if (length === 1) {
boundMethod = function(x) {
if (%_IsConstructCall()) {
if (!IS_UNDEFINED(new.target)) {
throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
}
return implementation(that, x);
}
} else {
boundMethod = function() {
if (%_IsConstructCall()) {
if (!IS_UNDEFINED(new.target)) {
throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
}
// DateTimeFormat.format needs to be 0 arg method, but can stil
......@@ -966,7 +966,7 @@ function initializeCollator(collator, locales, options) {
* Collator resolvedOptions method.
*/
%AddNamedProperty(Intl.Collator.prototype, 'resolvedOptions', function() {
if (%_IsConstructCall()) {
if (!IS_UNDEFINED(new.target)) {
throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
}
......@@ -1002,7 +1002,7 @@ function initializeCollator(collator, locales, options) {
* Options are optional parameter.
*/
%AddNamedProperty(Intl.Collator, 'supportedLocalesOf', function(locales) {
if (%_IsConstructCall()) {
if (!IS_UNDEFINED(new.target)) {
throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
}
......@@ -1208,7 +1208,7 @@ function initializeNumberFormat(numberFormat, locales, options) {
* NumberFormat resolvedOptions method.
*/
%AddNamedProperty(Intl.NumberFormat.prototype, 'resolvedOptions', function() {
if (%_IsConstructCall()) {
if (!IS_UNDEFINED(new.target)) {
throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
}
......@@ -1263,7 +1263,7 @@ function initializeNumberFormat(numberFormat, locales, options) {
* Options are optional parameter.
*/
%AddNamedProperty(Intl.NumberFormat, 'supportedLocalesOf', function(locales) {
if (%_IsConstructCall()) {
if (!IS_UNDEFINED(new.target)) {
throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
}
......@@ -1610,7 +1610,7 @@ function initializeDateTimeFormat(dateFormat, locales, options) {
* DateTimeFormat resolvedOptions method.
*/
%AddNamedProperty(Intl.DateTimeFormat.prototype, 'resolvedOptions', function() {
if (%_IsConstructCall()) {
if (!IS_UNDEFINED(new.target)) {
throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
}
......@@ -1684,7 +1684,7 @@ function initializeDateTimeFormat(dateFormat, locales, options) {
* Options are optional parameter.
*/
%AddNamedProperty(Intl.DateTimeFormat, 'supportedLocalesOf', function(locales) {
if (%_IsConstructCall()) {
if (!IS_UNDEFINED(new.target)) {
throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
}
......@@ -1831,7 +1831,7 @@ function initializeBreakIterator(iterator, locales, options) {
*/
%AddNamedProperty(Intl.v8BreakIterator.prototype, 'resolvedOptions',
function() {
if (%_IsConstructCall()) {
if (!IS_UNDEFINED(new.target)) {
throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
}
......@@ -1864,7 +1864,7 @@ function initializeBreakIterator(iterator, locales, options) {
*/
%AddNamedProperty(Intl.v8BreakIterator, 'supportedLocalesOf',
function(locales) {
if (%_IsConstructCall()) {
if (!IS_UNDEFINED(new.target)) {
throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
}
......@@ -1978,7 +1978,7 @@ function OverrideFunction(object, name, f) {
* Overrides the built-in method.
*/
OverrideFunction(GlobalString.prototype, 'localeCompare', function(that) {
if (%_IsConstructCall()) {
if (!IS_UNDEFINED(new.target)) {
throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
}
......@@ -2003,7 +2003,7 @@ OverrideFunction(GlobalString.prototype, 'localeCompare', function(that) {
*/
OverrideFunction(GlobalString.prototype, 'normalize', function() {
if (%_IsConstructCall()) {
if (!IS_UNDEFINED(new.target)) {
throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
}
......@@ -2031,7 +2031,7 @@ OverrideFunction(GlobalString.prototype, 'normalize', function() {
* If locale or options are omitted, defaults are used.
*/
OverrideFunction(GlobalNumber.prototype, 'toLocaleString', function() {
if (%_IsConstructCall()) {
if (!IS_UNDEFINED(new.target)) {
throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
}
......@@ -2072,7 +2072,7 @@ function toLocaleDateTime(date, locales, options, required, defaults, service) {
* present in the output.
*/
OverrideFunction(GlobalDate.prototype, 'toLocaleString', function() {
if (%_IsConstructCall()) {
if (!IS_UNDEFINED(new.target)) {
throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
}
......@@ -2090,7 +2090,7 @@ OverrideFunction(GlobalDate.prototype, 'toLocaleString', function() {
* in the output.
*/
OverrideFunction(GlobalDate.prototype, 'toLocaleDateString', function() {
if (%_IsConstructCall()) {
if (!IS_UNDEFINED(new.target)) {
throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
}
......@@ -2108,7 +2108,7 @@ OverrideFunction(GlobalDate.prototype, 'toLocaleDateString', function() {
* in the output.
*/
OverrideFunction(GlobalDate.prototype, 'toLocaleTimeString', function() {
if (%_IsConstructCall()) {
if (!IS_UNDEFINED(new.target)) {
throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
}
......
......@@ -203,7 +203,7 @@ function NAMEConstructByIterable(obj, iterable, iteratorFn) {
}
function NAMEConstructor(arg1, arg2, arg3) {
if (%_IsConstructCall()) {
if (!IS_UNDEFINED(new.target)) {
if (IS_ARRAYBUFFER(arg1) || IS_SHAREDARRAYBUFFER(arg1)) {
NAMEConstructByArrayBuffer(this, arg1, arg2, arg3);
} else if (IS_NUMBER(arg1) || IS_STRING(arg1) ||
......
......@@ -1290,7 +1290,7 @@ utils.InstallFunctions(GlobalObject, DONT_ENUM, [
function BooleanConstructor(x) {
// TODO(bmeurer): Move this to toplevel.
"use strict";
if (%_IsConstructCall()) {
if (!IS_UNDEFINED(new.target)) {
%_SetValueOf(this, TO_BOOLEAN(x));
} else {
return TO_BOOLEAN(x);
......@@ -1616,7 +1616,7 @@ function FunctionBind(this_arg) { // Length is 1.
"use strict";
// This function must not use any object literals (Object, Array, RegExp),
// since the literals-array is being used to store the bound data.
if (%_IsConstructCall()) {
if (!IS_UNDEFINED(new.target)) {
return %NewObjectFromBound(boundFunction);
}
var bindings = %BoundFunctionGetBindings(boundFunction);
......
......@@ -898,6 +898,7 @@
'regress/regress-4388': [SKIP],
'regress/regress-444805': [SKIP],
'regress/regress-446389': [SKIP],
'regress/regress-447756': [SKIP],
'regress/regress-4515': [SKIP],
'regress/regress-4521': [SKIP],
'regress/regress-4525': [SKIP],
......
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