Commit 717dbba6 authored by yangguo@chromium.org's avatar yangguo@chromium.org

Disabling stepping into callback function of String.replace.

This is being done due to performance concerns.

BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com/10134006

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@11406 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 9fda0c19
......@@ -266,10 +266,6 @@ 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 (%DebugCallbackSupportsStepping(replace)) {
%DebugPrepareStepInIfStepping(replace);
}
builder.add(%_CallFunction(receiver,
search,
start,
......@@ -438,49 +434,24 @@ function StringReplaceGlobalRegExpWithFunction(subject, regexp, replace) {
var match_start = 0;
var override = new InternalArray(null, 0, subject);
var receiver = %GetDefaultReceiver(replace);
if (%DebugCallbackSupportsStepping(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 {
override[0] = elem;
override[1] = match_start;
lastMatchInfoOverride = override;
%DebugPrepareStepInIfStepping(replace);
var func_result =
%_CallFunction(receiver, elem, match_start, subject, replace);
res[i] = TO_STRING_INLINE(func_result);
match_start += elem.length;
}
i++;
}
} else {
// This is a duplicate of the previous loop sans debug stepping.
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;
}
while (i < len) {
var elem = res[i];
if (%_IsSmi(elem)) {
if (elem > 0) {
match_start = (elem >> 11) + (elem & 0x7ff);
} 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;
match_start = res[++i] - elem;
}
i++;
} 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;
}
// End of duplicate.
i++;
}
} else {
var receiver = %GetDefaultReceiver(replace);
......@@ -520,10 +491,6 @@ 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 (%DebugCallbackSupportsStepping(replace)) {
%DebugPrepareStepInIfStepping(replace);
}
// Don't call directly to avoid exposing the built-in global object.
replacement = %_CallFunction(receiver, s, index, subject, replace);
} else {
......
......@@ -155,52 +155,3 @@ assertFalse(exception);
assertEquals(17, breaks);
Debug.setListener(null);
//Test replace callback in String.replace.
function replace_listener(event, exec_state, event_data, data) {
try {
if (event == Debug.DebugEvent.Break) {
if (breaks == 0) {
exec_state.prepareStep(Debug.StepAction.StepIn, 2);
breaks = 1;
} else {
// Check whether we break at the expected line.
assertTrue(event_data.sourceLineText().indexOf("Expected to step") > 0);
}
}
} catch (e) {
exception = true;
}
};
function cb_replace(match) {
print("matching string: " + match); // Expected to step to this point.
return "_";
}
var s = "abcdefgehijke";
Debug.setListener(replace_listener);
breaks = 0;
debugger;
assertEquals("ab_defgehijke", s.replace("c", cb_replace));
assertFalse(exception);
assertEquals(1, breaks);
breaks = 0;
debugger;
assertEquals("abcdefgehij_", s.replace(/..$/, cb_replace));
assertFalse(exception);
assertEquals(1, breaks);
breaks = 0;
debugger;
assertEquals("abcd_fg_hijk_", s.replace(/e/g, cb_replace));
assertFalse(exception);
assertEquals(1, breaks);
Debug.setListener(null);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment