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

Unified Diff: src/string.js

Issue 10078014: Enable stepping into callback passed to builtins (e.g. Array.forEach). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 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
Index: src/string.js
diff --git a/src/string.js b/src/string.js
index a464f7ffa376f1cc4775fe3ece89ba5363ec20b5..03064beb43d106fc12c68eba7c93e664d03706ef 100644
--- a/src/string.js
+++ b/src/string.js
@@ -266,6 +266,10 @@ function StringReplace(search, replace) {
// Compute the string to replace with.
if (IS_SPEC_FUNCTION(replace)) {
var receiver = %GetDefaultReceiver(replace);
+ // Prepare break slots for debugger step in.
+ if (%DebugStepIntoBuiltinCallback(replace)) {
+ %PrepareBreakSlotsForCallback(replace);
+ }
builder.add(%_CallFunction(receiver,
search,
start,
@@ -434,24 +438,47 @@ function StringReplaceGlobalRegExpWithFunction(subject, regexp, replace) {
var match_start = 0;
var override = new InternalArray(null, 0, subject);
var receiver = %GetDefaultReceiver(replace);
- while (i < len) {
- var elem = res[i];
- if (%_IsSmi(elem)) {
- if (elem > 0) {
- match_start = (elem >> 11) + (elem & 0x7ff);
+ if (%DebugStepIntoBuiltinCallback(replace)) {
+ while (i < len) {
+ var elem = res[i];
+ if (%_IsSmi(elem)) {
+ if (elem > 0) {
+ match_start = (elem >> 11) + (elem & 0x7ff);
+ } else {
+ match_start = res[++i] - elem;
+ }
} else {
- match_start = res[++i] - elem;
+ override[0] = elem;
+ override[1] = match_start;
+ lastMatchInfoOverride = override;
+ %PrepareBreakSlotsForCallback(replace);
+ var func_result =
+ %_CallFunction(receiver, elem, match_start, subject, replace);
+ res[i] = TO_STRING_INLINE(func_result);
+ match_start += elem.length;
}
- } else {
- override[0] = elem;
- override[1] = match_start;
- lastMatchInfoOverride = override;
- var func_result =
- %_CallFunction(receiver, elem, match_start, subject, replace);
- res[i] = TO_STRING_INLINE(func_result);
- match_start += elem.length;
+ i++;
+ }
+ } else {
+ while (i < len) {
+ var elem = res[i];
+ if (%_IsSmi(elem)) {
+ if (elem > 0) {
+ match_start = (elem >> 11) + (elem & 0x7ff);
+ } else {
+ match_start = res[++i] - elem;
+ }
+ } else {
+ override[0] = elem;
+ override[1] = match_start;
+ lastMatchInfoOverride = override;
+ var func_result =
+ %_CallFunction(receiver, elem, match_start, subject, replace);
+ res[i] = TO_STRING_INLINE(func_result);
+ match_start += elem.length;
+ }
+ i++;
}
- i++;
}
} else {
var receiver = %GetDefaultReceiver(replace);
@@ -491,9 +518,12 @@ function StringReplaceNonGlobalRegExpWithFunction(subject, regexp, replace) {
if (m == 1) {
// No captures, only the match, which is always valid.
var s = SubString(subject, index, endOfMatch);
+ // Prepare break slots for debugger step in.
+ if (%DebugStepIntoBuiltinCallback(replace)) {
+ %PrepareBreakSlotsForCallback(replace);
+ }
// Don't call directly to avoid exposing the built-in global object.
- replacement =
- %_CallFunction(receiver, s, index, subject, replace);
+ replacement = %_CallFunction(receiver, s, index, subject, replace);
} else {
var parameters = new InternalArray(m + 2);
for (var j = 0; j < m; j++) {

Powered by Google App Engine
This is Rietveld 408576698