Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(858)

Unified Diff: src/js/i18n.js

Issue 2109223002: [intl] Clean up function name handling in AddBoundMethod (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix build, I think Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/js/macros.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/js/i18n.js
diff --git a/src/js/i18n.js b/src/js/i18n.js
index 6c769a74ab79e2ea0c08737111d0e69163ed5ae0..dd85a0526495c926bc55ba011769dca720059d3c 100644
--- a/src/js/i18n.js
+++ b/src/js/i18n.js
@@ -87,40 +87,42 @@ function InstallConstructor(object, name, func) {
function AddBoundMethod(obj, methodName, implementation, length, type) {
%CheckIsBootstrapping();
var internalName = %CreatePrivateSymbol(methodName);
- var getter = function() {
+ // Making getter an anonymous function will cause
+ // %DefineGetterPropertyUnchecked to properly set the "name"
+ // property on each JSFunction instance created here, rather
+ // than (as utils.InstallGetter would) on the SharedFunctionInfo
+ // associated with all functions returned from AddBoundMethod.
+ var getter = ANONYMOUS_FUNCTION(function() {
if (!%IsInitializedIntlObjectOfType(this, type)) {
throw MakeTypeError(kMethodCalledOnWrongObject, methodName);
}
if (IS_UNDEFINED(this[internalName])) {
var boundMethod;
if (IS_UNDEFINED(length) || length === 2) {
- boundMethod = (x, y) => implementation(this, x, y);
+ boundMethod = ANONYMOUS_FUNCTION((x, y) => implementation(this, x, y));
} else if (length === 1) {
- boundMethod = x => implementation(this, x);
+ boundMethod = ANONYMOUS_FUNCTION(x => implementation(this, x));
} else {
- boundMethod = (...args) => {
- // DateTimeFormat.format needs to be 0 arg method, but can stil
- // receive optional dateValue param. If one was provided, pass it
+ boundMethod = ANONYMOUS_FUNCTION((...args) => {
+ // DateTimeFormat.format needs to be 0 arg method, but can still
+ // receive an optional dateValue param. If one was provided, pass it
// along.
if (args.length > 0) {
return implementation(this, args[0]);
} else {
return implementation(this);
}
- }
+ });
}
- // TODO(littledan): Once function name reform is shipped, remove the
- // following line and wrap the boundMethod definition in an anonymous
- // function macro.
- %FunctionSetName(boundMethod, '__bound' + methodName + '__');
- %FunctionRemovePrototype(boundMethod);
%SetNativeFlag(boundMethod);
this[internalName] = boundMethod;
}
return this[internalName];
- };
+ });
- InstallGetter(obj.prototype, methodName, getter, DONT_ENUM);
+ %FunctionRemovePrototype(getter);
+ %DefineGetterPropertyUnchecked(obj.prototype, methodName, getter, DONT_ENUM);
+ %SetNativeFlag(getter);
}
// -------------------------------------------------------------------
« no previous file with comments | « no previous file | src/js/macros.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698