Revision: 11406
Author:   [email protected]
Date:     Fri Apr 20 08:20:52 2012
Log:      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
http://code.google.com/p/v8/source/detail?r=11406

Modified:
 /branches/bleeding_edge/src/string.js
 /branches/bleeding_edge/test/mjsunit/debug-stepin-builtin-callback.js

=======================================
--- /branches/bleeding_edge/src/string.js       Fri Apr 20 04:06:12 2012
+++ /branches/bleeding_edge/src/string.js       Fri Apr 20 08:20:52 2012
@@ -266,10 +266,6 @@
   // 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 @@
     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;
-          }
+    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;
-          %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;
-          }
-        } 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++;
-      }
-      // End of duplicate.
+          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++;
     }
   } else {
     var receiver = %GetDefaultReceiver(replace);
@@ -520,10 +491,6 @@
   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 {
=======================================
--- /branches/bleeding_edge/test/mjsunit/debug-stepin-builtin-callback.js Fri Apr 20 04:06:12 2012 +++ /branches/bleeding_edge/test/mjsunit/debug-stepin-builtin-callback.js Fri Apr 20 08:20:52 2012
@@ -155,52 +155,3 @@
 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);

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to