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

Unified Diff: src/string.js

Issue 1325573004: [runtime] Replace many buggy uses of %_CallFunction with %_Call. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Address feedback. Created 5 years, 3 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 | « src/runtime/runtime-function.cc ('k') | src/typedarray.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/string.js
diff --git a/src/string.js b/src/string.js
index 1db65bb0bad25b677c7fa38144976c6a39f4ca18..19d89c0fe628a23ea137d232e4fb9c64976a6952 100644
--- a/src/string.js
+++ b/src/string.js
@@ -318,8 +318,7 @@ function StringReplace(search, replace) {
// Compute the string to replace with.
if (IS_CALLABLE(replace)) {
- var receiver = UNDEFINED;
- result += %_CallFunction(receiver, search, start, subject, replace);
+ result += replace(search, start, subject);
} else {
reusableMatchInfo[CAPTURE0] = start;
reusableMatchInfo[CAPTURE1] = end;
@@ -482,8 +481,7 @@ function StringReplaceGlobalRegExpWithFunction(subject, regexp, replace) {
override[0] = elem;
override[1] = match_start;
$regexpLastMatchInfoOverride = override;
- var func_result =
- %_CallFunction(UNDEFINED, elem, match_start, subject, replace);
+ var func_result = replace(elem, match_start, subject);
// Overwrite the i'th element in the results with the string we got
// back from the callback function.
res[i] = TO_STRING_INLINE(func_result);
@@ -529,7 +527,7 @@ function StringReplaceNonGlobalRegExpWithFunction(subject, regexp, replace) {
// No captures, only the match, which is always valid.
var s = %_SubString(subject, index, endOfMatch);
// Don't call directly to avoid exposing the built-in global object.
- replacement = %_CallFunction(UNDEFINED, s, index, subject, replace);
+ replacement = replace(s, index, subject);
} else {
var parameters = new InternalArray(m + 2);
for (var j = 0; j < m; j++) {
« no previous file with comments | « src/runtime/runtime-function.cc ('k') | src/typedarray.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698