[V8] Add flag to avoid breakpoint relocation
authorAurindam Jana <aurindam.jana@nokia.com>
Tue, 13 Mar 2012 08:13:58 +0000 (09:13 +0100)
committerQt by Nokia <qt-info@nokia.com>
Tue, 13 Mar 2012 11:21:20 +0000 (12:21 +0100)
Add a flag that prevents v8 from relocating breakpoints across
line boundaries.

This patch should be squashed into --
cf3296721194eafb9bb07ee94026cfb5bcc5d092 [V8] Add flag to avoid
breakpoint relocation -- in the next V8 rebase as this code only
improves code in that patch

Change-Id: I4fefc08f18874f2fa26ffff64eefb11dc949ddfd
Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
src/3rdparty/v8/src/debug-debugger.js
src/3rdparty/v8/src/debug.cc
src/3rdparty/v8/src/runtime.cc
src/3rdparty/v8/src/runtime.h

index 6f80a8b..4740480 100644 (file)
@@ -449,6 +449,11 @@ ScriptBreakPoint.prototype.set = function (script) {
     actual_position = position;
   }
   var actual_location = script.locationFromPosition(actual_position, true);
+  // Check for any relocation and compare it with the breakpoint_relocation flag
+  if (actual_location.line != line && !%AllowBreakPointRelocation()) {
+    %ClearBreakPoint(break_point);
+    return break_point;
+  }
   break_point.actual_location = { line: actual_location.line,
                                   column: actual_location.column,
                                   script_id: script.id };
index 38916a7..88149d8 100644 (file)
@@ -1131,17 +1131,6 @@ Handle<DebugInfo> Debug::GetDebugInfo(Handle<SharedFunctionInfo> shared) {
   return Handle<DebugInfo>(DebugInfo::cast(shared->debug_info()));
 }
 
-static bool ContainsLineBreak(String *string, int from, int to)
-{
-  ASSERT(from >= 0);
-  ASSERT(from <= to);
-  const int end = (string->length() < to) ? string->length() : to;
-  for (int pos = from; pos < end; ++pos) {
-    if (string->Get(pos) == '\n')
-      return true;
-  }
-  return false;
-}
 
 void Debug::SetBreakPoint(Handle<SharedFunctionInfo> shared,
                           Handle<Object> break_point_object,
@@ -1162,22 +1151,12 @@ void Debug::SetBreakPoint(Handle<SharedFunctionInfo> shared,
   // Find the break point and change it.
   BreakLocationIterator it(debug_info, SOURCE_BREAK_LOCATIONS);
   it.FindBreakLocationFromPosition(*source_position);
+  it.SetBreakPoint(break_point_object);
 
-  bool acceptBreak = true;
-  if (!FLAG_breakpoint_relocation) {
-    if (String *sourceStr = String::cast(shared->GetSourceCode())) {
-      acceptBreak = !ContainsLineBreak(sourceStr, *source_position, it.position());
-    }
-  }
-
-  if (acceptBreak) {
-    it.SetBreakPoint(break_point_object);
+  *source_position = it.position();
 
-    *source_position = it.position();
-
-    // At least one active break point now.
-    ASSERT(debug_info->GetBreakPointCount() > 0);
-  }
+  // At least one active break point now.
+  ASSERT(debug_info->GetBreakPointCount() > 0);
 }
 
 
index a8a5f4c..bce5d8e 100644 (file)
@@ -11350,7 +11350,6 @@ class ScopeIterator {
       case ScopeIterator::ScopeTypeGlobal:
         return Handle<JSObject>(CurrentContext()->global());
       case ScopeIterator::ScopeTypeLocal: {
-        Handle<SerializedScopeInfo> scope_info = nested_scope_chain_.last();
         ASSERT(nested_scope_chain_.length() == 1);
         // Materialize the content of the local scope into a JSObject.
         return MaterializeLocalScope(isolate_, frame_, inlined_frame_index_);
@@ -11675,6 +11674,12 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetBreakLocations) {
 }
 
 
+// Return the value of breakpoint_relocation flag
+RUNTIME_FUNCTION(MaybeObject*, Runtime_AllowBreakPointRelocation) {
+  return Smi::FromInt(FLAG_breakpoint_relocation);
+}
+
+
 // Set a break point in a function
 // args[0]: function
 // args[1]: number: break source position (within the function source)
index 04f7794..c92c457 100644 (file)
@@ -412,6 +412,7 @@ namespace internal {
   F(GetThreadDetails, 2, 1) \
   F(SetDisableBreak, 1, 1) \
   F(GetBreakLocations, 1, 1) \
+  F(AllowBreakPointRelocation, 0, 1) \
   F(SetFunctionBreakPoint, 3, 1) \
   F(SetScriptBreakPoint, 3, 1) \
   F(ClearBreakPoint, 1, 1) \