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

Unified Diff: src/builtins/builtins-string-gen.cc

Issue 2845153002: [string] Fix null handling in MaybeCallFunctionAtSymbol (Closed)
Patch Set: Clarify comments Created 3 years, 8 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 | test/mjsunit/es6/string-replace.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/builtins/builtins-string-gen.cc
diff --git a/src/builtins/builtins-string-gen.cc b/src/builtins/builtins-string-gen.cc
index 9e76f110a57d8a9a7f723f9303cc7b8ce4740703..5b457b7083b27fc469ff67dbf9a965da05fab93d 100644
--- a/src/builtins/builtins-string-gen.cc
+++ b/src/builtins/builtins-string-gen.cc
@@ -1059,12 +1059,18 @@ void StringBuiltinsAssembler::MaybeCallFunctionAtSymbol(
GotoIf(IsNullOrUndefined(object), &out);
// Fall back to a slow lookup of {object[symbol]}.
+ //
+ // The spec uses GetMethod({object}, {symbol}), which has a few quirks:
+ // * null values are turned into undefined, and
+ // * an exception is thrown if the value is not undefined, null, or callable.
+ // We handle the former by jumping to {out} for null values as well, while
+ // the latter is already handled by the Call({maybe_func}) operation.
Node* const maybe_func = GetProperty(context, object, symbol);
GotoIf(IsUndefined(maybe_func), &out);
+ GotoIf(IsNull(maybe_func), &out);
// Attempt to call the function.
-
Node* const result = generic_call(maybe_func);
Return(result);
« no previous file with comments | « no previous file | test/mjsunit/es6/string-replace.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698