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