|
|
Chromium Code Reviews|
Created:
4 years ago by Dan Ehrenberg Modified:
4 years ago CC:
v8-reviews_googlegroups.com Target Ref:
refs/pending/heads/master Project:
v8 Visibility:
Public. |
Description[intl] Remove new.target check in Intl functions and method
The Intl implementation included manual checks to see if they were
being called as a constructor. However, these checks are redundant,
as %FunctionRemovePrototype has already marked the functions as
un-constructable. This path removes the unnecessary checks.
R=yangguo
Review-Url: https://codereview.chromium.org/2587713002
Cr-Commit-Position: refs/heads/master@{#41867}
Committed: https://chromium.googlesource.com/v8/v8/+/b88d96c73a5a38d08c38768f1ff149a6e99bd317
Patch Set 1 #
Total comments: 1
Patch Set 2 : rebase #
Messages
Total messages: 20 (12 generated)
The CQ bit was checked by littledan@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
littledan@chromium.org changed reviewers: + yangguo@chromium.org - yangguo@google.com
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
lgtm
jshin@chromium.org changed reviewers: + jshin@chromium.org
Thank you, Dan, for removing the check in other i18n functions. https://codereview.chromium.org/2587713002/diff/1/src/js/i18n.js File src/js/i18n.js (left): https://codereview.chromium.org/2587713002/diff/1/src/js/i18n.js#oldcode2126 src/js/i18n.js:2126: } I dropped the check in To(Locale){Lower,Upper}CaseI18N in my case conversion CL as you saw. :-)
On 2016/12/19 20:56:09, jungshik at google wrote: > Thank you, Dan, for removing the check in other i18n functions. > > https://codereview.chromium.org/2587713002/diff/1/src/js/i18n.js > File src/js/i18n.js (left): > > https://codereview.chromium.org/2587713002/diff/1/src/js/i18n.js#oldcode2126 > src/js/i18n.js:2126: } > I dropped the check in To(Locale){Lower,Upper}CaseI18N in my case conversion CL > as you saw. :-) To be clear, that CL was landed earlier today so that you just need to rebase it. Thanks again. LGTM
The CQ bit was checked by littledan@chromium.org
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Failed to apply patch for src/js/i18n.js:
While running git apply --index -p1;
error: patch failed: src/js/i18n.js:2121
error: src/js/i18n.js: patch does not apply
Patch: src/js/i18n.js
Index: src/js/i18n.js
diff --git a/src/js/i18n.js b/src/js/i18n.js
index
b051b090bcee57af0da4a558eb4c79fa824ba426..cdb6d920bdd96d1a860d66f3ed25bd121d69a714
100644
--- a/src/js/i18n.js
+++ b/src/js/i18n.js
@@ -912,10 +912,6 @@ var resolvedAccessor = {
// ECMA 402 section 8.2.1
InstallFunction(Intl, 'getCanonicalLocales', function(locales) {
- if (!IS_UNDEFINED(new.target)) {
- throw %make_type_error(kOrdinaryFunctionCalledAsConstructor);
- }
-
return makeArray(canonicalizeLocaleList(locales));
}
);
@@ -1051,10 +1047,6 @@ InstallConstructor(Intl, 'Collator', function() {
* Collator resolvedOptions method.
*/
InstallFunction(Intl.Collator.prototype, 'resolvedOptions', function() {
- if (!IS_UNDEFINED(new.target)) {
- throw %make_type_error(kOrdinaryFunctionCalledAsConstructor);
- }
-
if (!%IsInitializedIntlObjectOfType(this, 'collator')) {
throw %make_type_error(kResolvedOptionsCalledOnNonObject, "Collator");
}
@@ -1083,10 +1075,6 @@ InstallFunction(Intl.Collator.prototype,
'resolvedOptions', function() {
* Options are optional parameter.
*/
InstallFunction(Intl.Collator, 'supportedLocalesOf', function(locales) {
- if (!IS_UNDEFINED(new.target)) {
- throw %make_type_error(kOrdinaryFunctionCalledAsConstructor);
- }
-
return supportedLocalesOf('collator', locales, arguments[1]);
}
);
@@ -1292,10 +1280,6 @@ InstallConstructor(Intl, 'NumberFormat', function() {
* NumberFormat resolvedOptions method.
*/
InstallFunction(Intl.NumberFormat.prototype, 'resolvedOptions', function() {
- if (!IS_UNDEFINED(new.target)) {
- throw %make_type_error(kOrdinaryFunctionCalledAsConstructor);
- }
-
if (!%IsInitializedIntlObjectOfType(this, 'numberformat')) {
throw %make_type_error(kResolvedOptionsCalledOnNonObject,
"NumberFormat");
}
@@ -1342,10 +1326,6 @@ InstallFunction(Intl.NumberFormat.prototype,
'resolvedOptions', function() {
* Options are optional parameter.
*/
InstallFunction(Intl.NumberFormat, 'supportedLocalesOf', function(locales) {
- if (!IS_UNDEFINED(new.target)) {
- throw %make_type_error(kOrdinaryFunctionCalledAsConstructor);
- }
-
return supportedLocalesOf('numberformat', locales, arguments[1]);
}
);
@@ -1674,10 +1654,6 @@ InstallConstructor(Intl, 'DateTimeFormat', function() {
* DateTimeFormat resolvedOptions method.
*/
InstallFunction(Intl.DateTimeFormat.prototype, 'resolvedOptions', function() {
- if (!IS_UNDEFINED(new.target)) {
- throw %make_type_error(kOrdinaryFunctionCalledAsConstructor);
- }
-
if (!%IsInitializedIntlObjectOfType(this, 'dateformat')) {
throw %make_type_error(kResolvedOptionsCalledOnNonObject,
"DateTimeFormat");
}
@@ -1734,10 +1710,6 @@ InstallFunction(Intl.DateTimeFormat.prototype,
'resolvedOptions', function() {
* Options are optional parameter.
*/
InstallFunction(Intl.DateTimeFormat, 'supportedLocalesOf', function(locales) {
- if (!IS_UNDEFINED(new.target)) {
- throw %make_type_error(kOrdinaryFunctionCalledAsConstructor);
- }
-
return supportedLocalesOf('dateformat', locales, arguments[1]);
}
);
@@ -1763,9 +1735,6 @@ function formatDate(formatter, dateValue) {
}
function FormatDateToParts(dateValue) {
- if (!IS_UNDEFINED(new.target)) {
- throw %make_type_error(kOrdinaryFunctionCalledAsConstructor);
- }
CHECK_OBJECT_COERCIBLE(this, "Intl.DateTimeFormat.prototype.formatToParts");
if (!IS_OBJECT(this)) {
throw %make_type_error(kCalledOnNonObject, this);
@@ -2073,10 +2042,6 @@ function LocaleConvertCase(s, locales, isToUpper) {
* Overrides the built-in method.
*/
OverrideFunction(GlobalString.prototype, 'localeCompare', function(that) {
- if (!IS_UNDEFINED(new.target)) {
- throw %make_type_error(kOrdinaryFunctionCalledAsConstructor);
- }
-
if (IS_NULL_OR_UNDEFINED(this)) {
throw %make_type_error(kMethodInvokedOnNullOrUndefined);
}
@@ -2098,10 +2063,6 @@ OverrideFunction(GlobalString.prototype, 'localeCompare',
function(that) {
*/
OverrideFunction(GlobalString.prototype, 'normalize', function() {
- if (!IS_UNDEFINED(new.target)) {
- throw %make_type_error(kOrdinaryFunctionCalledAsConstructor);
- }
-
CHECK_OBJECT_COERCIBLE(this, "String.prototype.normalize");
var s = TO_STRING(this);
@@ -2121,27 +2082,18 @@ OverrideFunction(GlobalString.prototype, 'normalize',
function() {
);
function ToLowerCaseI18N() {
- if (!IS_UNDEFINED(new.target)) {
- throw %make_type_error(kOrdinaryFunctionCalledAsConstructor);
- }
CHECK_OBJECT_COERCIBLE(this, "String.prototype.toLowerCase");
var s = TO_STRING(this);
return %StringToLowerCaseI18N(s);
}
function ToUpperCaseI18N() {
- if (!IS_UNDEFINED(new.target)) {
- throw %make_type_error(kOrdinaryFunctionCalledAsConstructor);
- }
CHECK_OBJECT_COERCIBLE(this, "String.prototype.toUpperCase");
var s = TO_STRING(this);
return %StringToUpperCaseI18N(s);
}
function ToLocaleLowerCaseI18N(locales) {
- if (!IS_UNDEFINED(new.target)) {
- throw %make_type_error(kOrdinaryFunctionCalledAsConstructor);
- }
CHECK_OBJECT_COERCIBLE(this, "String.prototype.toLocaleLowerCase");
return LocaleConvertCase(TO_STRING(this), locales, false);
}
@@ -2149,9 +2101,6 @@ function ToLocaleLowerCaseI18N(locales) {
%FunctionSetLength(ToLocaleLowerCaseI18N, 0);
function ToLocaleUpperCaseI18N(locales) {
- if (!IS_UNDEFINED(new.target)) {
- throw %make_type_error(kOrdinaryFunctionCalledAsConstructor);
- }
CHECK_OBJECT_COERCIBLE(this, "String.prototype.toLocaleUpperCase");
return LocaleConvertCase(TO_STRING(this), locales, true);
}
@@ -2176,10 +2125,6 @@ utils.Export(function(to) {
* If locale or options are omitted, defaults are used.
*/
OverrideFunction(GlobalNumber.prototype, 'toLocaleString', function() {
- if (!IS_UNDEFINED(new.target)) {
- throw %make_type_error(kOrdinaryFunctionCalledAsConstructor);
- }
-
if (!(this instanceof GlobalNumber) && typeof(this) !== 'number') {
throw %make_type_error(kMethodInvokedOnWrongType, "Number");
}
@@ -2218,10 +2163,6 @@ function toLocaleDateTime(date, locales, options,
required, defaults, service) {
* present in the output.
*/
OverrideFunction(GlobalDate.prototype, 'toLocaleString', function() {
- if (!IS_UNDEFINED(new.target)) {
- throw %make_type_error(kOrdinaryFunctionCalledAsConstructor);
- }
-
var locales = arguments[0];
var options = arguments[1];
return toLocaleDateTime(
@@ -2236,10 +2177,6 @@ OverrideFunction(GlobalDate.prototype, 'toLocaleString',
function() {
* in the output.
*/
OverrideFunction(GlobalDate.prototype, 'toLocaleDateString', function() {
- if (!IS_UNDEFINED(new.target)) {
- throw %make_type_error(kOrdinaryFunctionCalledAsConstructor);
- }
-
var locales = arguments[0];
var options = arguments[1];
return toLocaleDateTime(
@@ -2254,10 +2191,6 @@ OverrideFunction(GlobalDate.prototype,
'toLocaleDateString', function() {
* in the output.
*/
OverrideFunction(GlobalDate.prototype, 'toLocaleTimeString', function() {
- if (!IS_UNDEFINED(new.target)) {
- throw %make_type_error(kOrdinaryFunctionCalledAsConstructor);
- }
-
var locales = arguments[0];
var options = arguments[1];
return toLocaleDateTime(
The CQ bit was checked by littledan@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from jshin@chromium.org, yangguo@chromium.org Link to the patchset: https://codereview.chromium.org/2587713002/#ps20001 (title: "rebase")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
CQ is committing da patch.
Bot data: {"patchset_id": 20001, "attempt_start_ts": 1482248443963790,
"parent_rev": "6e8338865a39dceafdfd4654f39c05fc5f760c44", "commit_rev":
"b88d96c73a5a38d08c38768f1ff149a6e99bd317"}
Message was sent while issue was closed.
Description was changed from ========== [intl] Remove new.target check in Intl functions and method The Intl implementation included manual checks to see if they were being called as a constructor. However, these checks are redundant, as %FunctionRemovePrototype has already marked the functions as un-constructable. This path removes the unnecessary checks. R=yangguo ========== to ========== [intl] Remove new.target check in Intl functions and method The Intl implementation included manual checks to see if they were being called as a constructor. However, these checks are redundant, as %FunctionRemovePrototype has already marked the functions as un-constructable. This path removes the unnecessary checks. R=yangguo Review-Url: https://codereview.chromium.org/2587713002 Cr-Commit-Position: refs/heads/master@{#41867} Committed: https://chromium.googlesource.com/v8/v8/+/b88d96c73a5a38d08c38768f1ff149a6e99... ==========
Message was sent while issue was closed.
Committed patchset #2 (id:20001) as https://chromium.googlesource.com/v8/v8/+/b88d96c73a5a38d08c38768f1ff149a6e99... |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
