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

Side by Side Diff: src/runtime/runtime-debug.cc

Issue 967323002: Refactor BreakLocationIterator. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: static_cast instead Created 5 years, 9 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 unified diff | Download patch
« no previous file with comments | « src/ppc/debug-ppc.cc ('k') | src/x64/assembler-x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/arguments.h" 8 #include "src/arguments.h"
9 #include "src/debug.h" 9 #include "src/debug.h"
10 #include "src/deoptimizer.h" 10 #include "src/deoptimizer.h"
(...skipping 1146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1157 1157
1158 // Currently it takes too much time to find nested scopes due to script 1158 // Currently it takes too much time to find nested scopes due to script
1159 // parsing. Sometimes we want to run the ScopeIterator as fast as possible 1159 // parsing. Sometimes we want to run the ScopeIterator as fast as possible
1160 // (for example, while collecting async call stacks on every 1160 // (for example, while collecting async call stacks on every
1161 // addEventListener call), even if we drop some nested scopes. 1161 // addEventListener call), even if we drop some nested scopes.
1162 // Later we may optimize getting the nested scopes (cache the result?) 1162 // Later we may optimize getting the nested scopes (cache the result?)
1163 // and include nested scopes into the "fast" iteration case as well. 1163 // and include nested scopes into the "fast" iteration case as well.
1164 if (!ignore_nested_scopes) { 1164 if (!ignore_nested_scopes) {
1165 Handle<DebugInfo> debug_info = Debug::GetDebugInfo(shared_info); 1165 Handle<DebugInfo> debug_info = Debug::GetDebugInfo(shared_info);
1166 1166
1167 // PC points to the instruction after the current one, possibly a break
1168 // location as well. So the "- 1" to exclude it from the search.
1169 Address call_pc = frame->pc() - 1;
1170
1167 // Find the break point where execution has stopped. 1171 // Find the break point where execution has stopped.
1168 BreakLocationIterator break_location_iterator(debug_info, 1172 BreakLocation location =
1169 ALL_BREAK_LOCATIONS); 1173 BreakLocation::FromAddress(debug_info, ALL_BREAK_LOCATIONS, call_pc);
1170 // pc points to the instruction after the current one, possibly a break
1171 // location as well. So the "- 1" to exclude it from the search.
1172 break_location_iterator.FindBreakLocationFromAddress(frame->pc() - 1);
1173 1174
1174 // Within the return sequence at the moment it is not possible to 1175 // Within the return sequence at the moment it is not possible to
1175 // get a source position which is consistent with the current scope chain. 1176 // get a source position which is consistent with the current scope chain.
1176 // Thus all nested with, catch and block contexts are skipped and we only 1177 // Thus all nested with, catch and block contexts are skipped and we only
1177 // provide the function scope. 1178 // provide the function scope.
1178 ignore_nested_scopes = break_location_iterator.IsExit(); 1179 ignore_nested_scopes = location.IsExit();
1179 } 1180 }
1180 1181
1181 if (ignore_nested_scopes) { 1182 if (ignore_nested_scopes) {
1182 if (scope_info->HasContext()) { 1183 if (scope_info->HasContext()) {
1183 context_ = Handle<Context>(context_->declaration_context(), isolate_); 1184 context_ = Handle<Context>(context_->declaration_context(), isolate_);
1184 } else { 1185 } else {
1185 while (context_->closure() == *function_) { 1186 while (context_->closure() == *function_) {
1186 context_ = Handle<Context>(context_->previous(), isolate_); 1187 context_ = Handle<Context>(context_->previous(), isolate_);
1187 } 1188 }
1188 } 1189 }
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
1552 1553
1553 Handle<JSFunction> fun = Handle<JSFunction>(frame->function()); 1554 Handle<JSFunction> fun = Handle<JSFunction>(frame->function());
1554 Handle<SharedFunctionInfo> shared = Handle<SharedFunctionInfo>(fun->shared()); 1555 Handle<SharedFunctionInfo> shared = Handle<SharedFunctionInfo>(fun->shared());
1555 1556
1556 if (!isolate->debug()->EnsureDebugInfo(shared, fun)) { 1557 if (!isolate->debug()->EnsureDebugInfo(shared, fun)) {
1557 return isolate->heap()->undefined_value(); 1558 return isolate->heap()->undefined_value();
1558 } 1559 }
1559 1560
1560 Handle<DebugInfo> debug_info = Debug::GetDebugInfo(shared); 1561 Handle<DebugInfo> debug_info = Debug::GetDebugInfo(shared);
1561 1562
1562 int len = 0; 1563 // Find range of break points starting from the break point where execution
1563 Handle<JSArray> array(isolate->factory()->NewJSArray(10)); 1564 // has stopped.
1564 // Find the break point where execution has stopped. 1565 Address call_pc = frame->pc() - 1;
1565 BreakLocationIterator break_location_iterator(debug_info, 1566 List<BreakLocation> locations;
1566 ALL_BREAK_LOCATIONS); 1567 BreakLocation::FromAddressSameStatement(debug_info, ALL_BREAK_LOCATIONS,
1568 call_pc, &locations);
1567 1569
1568 break_location_iterator.FindBreakLocationFromAddress(frame->pc() - 1); 1570 Handle<JSArray> array = isolate->factory()->NewJSArray(locations.length());
1569 int current_statement_pos = break_location_iterator.statement_position();
1570 1571
1571 while (!break_location_iterator.Done()) { 1572 int index = 0;
1573 for (BreakLocation location : locations) {
1572 bool accept; 1574 bool accept;
1573 if (break_location_iterator.pc() > frame->pc()) { 1575 if (location.pc() > frame->pc()) {
1574 accept = true; 1576 accept = true;
1575 } else { 1577 } else {
1576 StackFrame::Id break_frame_id = isolate->debug()->break_frame_id(); 1578 StackFrame::Id break_frame_id = isolate->debug()->break_frame_id();
1577 // The break point is near our pc. Could be a step-in possibility, 1579 // The break point is near our pc. Could be a step-in possibility,
1578 // that is currently taken by active debugger call. 1580 // that is currently taken by active debugger call.
1579 if (break_frame_id == StackFrame::NO_ID) { 1581 if (break_frame_id == StackFrame::NO_ID) {
1580 // We are not stepping. 1582 // We are not stepping.
1581 accept = false; 1583 accept = false;
1582 } else { 1584 } else {
1583 JavaScriptFrameIterator additional_frame_it(isolate, break_frame_id); 1585 JavaScriptFrameIterator additional_frame_it(isolate, break_frame_id);
1584 // If our frame is a top frame and we are stepping, we can do step-in 1586 // If our frame is a top frame and we are stepping, we can do step-in
1585 // at this place. 1587 // at this place.
1586 accept = additional_frame_it.frame()->id() == id; 1588 accept = additional_frame_it.frame()->id() == id;
1587 } 1589 }
1588 } 1590 }
1589 if (accept) { 1591 if (accept) {
1590 if (break_location_iterator.IsStepInLocation(isolate)) { 1592 if (location.IsStepInLocation()) {
1591 Smi* position_value = Smi::FromInt(break_location_iterator.position()); 1593 Smi* position_value = Smi::FromInt(location.position());
1592 RETURN_FAILURE_ON_EXCEPTION( 1594 RETURN_FAILURE_ON_EXCEPTION(
1593 isolate, JSObject::SetElement( 1595 isolate, JSObject::SetElement(
1594 array, len, Handle<Object>(position_value, isolate), 1596 array, index, Handle<Object>(position_value, isolate),
1595 NONE, SLOPPY)); 1597 NONE, SLOPPY));
1596 len++; 1598 index++;
1597 } 1599 }
1598 } 1600 }
1599 // Advance iterator.
1600 break_location_iterator.Next();
1601 if (current_statement_pos != break_location_iterator.statement_position()) {
1602 break;
1603 }
1604 } 1601 }
1605 return *array; 1602 return *array;
1606 } 1603 }
1607 1604
1608 1605
1609 static const int kScopeDetailsTypeIndex = 0; 1606 static const int kScopeDetailsTypeIndex = 0;
1610 static const int kScopeDetailsObjectIndex = 1; 1607 static const int kScopeDetailsObjectIndex = 1;
1611 static const int kScopeDetailsSize = 2; 1608 static const int kScopeDetailsSize = 2;
1612 1609
1613 1610
(...skipping 1197 matching lines...) Expand 10 before | Expand all | Expand 10 after
2811 return Smi::FromInt(isolate->debug()->is_active()); 2808 return Smi::FromInt(isolate->debug()->is_active());
2812 } 2809 }
2813 2810
2814 2811
2815 RUNTIME_FUNCTION(RuntimeReference_DebugBreakInOptimizedCode) { 2812 RUNTIME_FUNCTION(RuntimeReference_DebugBreakInOptimizedCode) {
2816 UNIMPLEMENTED(); 2813 UNIMPLEMENTED();
2817 return NULL; 2814 return NULL;
2818 } 2815 }
2819 } 2816 }
2820 } // namespace v8::internal 2817 } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ppc/debug-ppc.cc ('k') | src/x64/assembler-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698