OLD | NEW |
---|---|
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/compiler.h" | 9 #include "src/compiler.h" |
10 #include "src/debug.h" | 10 #include "src/debug.h" |
(...skipping 1372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1383 // Catch the case when the debugger stops in an internal function. | 1383 // Catch the case when the debugger stops in an internal function. |
1384 Handle<SharedFunctionInfo> shared_info(function_->shared()); | 1384 Handle<SharedFunctionInfo> shared_info(function_->shared()); |
1385 Handle<ScopeInfo> scope_info(shared_info->scope_info()); | 1385 Handle<ScopeInfo> scope_info(shared_info->scope_info()); |
1386 if (shared_info->script() == isolate->heap()->undefined_value()) { | 1386 if (shared_info->script() == isolate->heap()->undefined_value()) { |
1387 while (context_->closure() == *function_) { | 1387 while (context_->closure() == *function_) { |
1388 context_ = Handle<Context>(context_->previous(), isolate_); | 1388 context_ = Handle<Context>(context_->previous(), isolate_); |
1389 } | 1389 } |
1390 return; | 1390 return; |
1391 } | 1391 } |
1392 | 1392 |
1393 // Get the debug info (create it if it does not exist). | |
1394 if (!isolate->debug()->EnsureDebugInfo(shared_info, function_)) { | |
1395 // Return if ensuring debug info failed. | |
1396 return; | |
1397 } | |
1398 | |
1399 // Currently it takes too much time to find nested scopes due to script | 1393 // Currently it takes too much time to find nested scopes due to script |
1400 // parsing. Sometimes we want to run the ScopeIterator as fast as possible | 1394 // parsing. Sometimes we want to run the ScopeIterator as fast as possible |
1401 // (for example, while collecting async call stacks on every | 1395 // (for example, while collecting async call stacks on every |
1402 // addEventListener call), even if we drop some nested scopes. | 1396 // addEventListener call), even if we drop some nested scopes. |
1403 // Later we may optimize getting the nested scopes (cache the result?) | 1397 // Later we may optimize getting the nested scopes (cache the result?) |
1404 // and include nested scopes into the "fast" iteration case as well. | 1398 // and include nested scopes into the "fast" iteration case as well. |
1405 if (!ignore_nested_scopes) { | 1399 if (!ignore_nested_scopes && !shared_info->debug_info()->IsUndefined()) { |
ulan
2015/07/14 09:12:45
What happens if there is no debug info?
Yang
2015/07/14 12:00:57
We can only ever end up here from a return stateme
| |
1406 Handle<DebugInfo> debug_info = Debug::GetDebugInfo(shared_info); | 1400 Handle<DebugInfo> debug_info = Debug::GetDebugInfo(shared_info); |
1407 | 1401 |
1408 // PC points to the instruction after the current one, possibly a break | 1402 // PC points to the instruction after the current one, possibly a break |
1409 // location as well. So the "- 1" to exclude it from the search. | 1403 // location as well. So the "- 1" to exclude it from the search. |
1410 Address call_pc = frame->pc() - 1; | 1404 Address call_pc = frame->pc() - 1; |
1411 | 1405 |
1412 // Find the break point where execution has stopped. | 1406 // Find the break point where execution has stopped. |
1413 BreakLocation location = | 1407 BreakLocation location = |
1414 BreakLocation::FromAddress(debug_info, ALL_BREAK_LOCATIONS, call_pc); | 1408 BreakLocation::FromAddress(debug_info, ALL_BREAK_LOCATIONS, call_pc); |
1415 | 1409 |
1416 // Within the return sequence at the moment it is not possible to | 1410 // With break points we can end up breaking at a return sequence, where |
1417 // get a source position which is consistent with the current scope chain. | 1411 // at the moment it is not possible to get a source position which is |
1418 // Thus all nested with, catch and block contexts are skipped and we only | 1412 // consistent with the current scope chain. Thus all nested with, catch |
1419 // provide the function scope. | 1413 // and block contexts are skipped and we only provide the function scope. |
1420 ignore_nested_scopes = location.IsExit(); | 1414 ignore_nested_scopes = location.IsReturn(); |
1421 } | 1415 } |
1422 | 1416 |
1423 if (ignore_nested_scopes) { | 1417 if (ignore_nested_scopes) { |
1424 if (scope_info->HasContext()) { | 1418 if (scope_info->HasContext()) { |
1425 context_ = Handle<Context>(context_->declaration_context(), isolate_); | 1419 context_ = Handle<Context>(context_->declaration_context(), isolate_); |
1426 } else { | 1420 } else { |
1427 while (context_->closure() == *function_) { | 1421 while (context_->closure() == *function_) { |
1428 context_ = Handle<Context>(context_->previous(), isolate_); | 1422 context_ = Handle<Context>(context_->previous(), isolate_); |
1429 } | 1423 } |
1430 } | 1424 } |
(...skipping 1790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3221 return *isolate->factory()->undefined_value(); | 3215 return *isolate->factory()->undefined_value(); |
3222 } | 3216 } |
3223 | 3217 |
3224 | 3218 |
3225 RUNTIME_FUNCTION(Runtime_DebugBreakInOptimizedCode) { | 3219 RUNTIME_FUNCTION(Runtime_DebugBreakInOptimizedCode) { |
3226 UNIMPLEMENTED(); | 3220 UNIMPLEMENTED(); |
3227 return NULL; | 3221 return NULL; |
3228 } | 3222 } |
3229 } // namespace internal | 3223 } // namespace internal |
3230 } // namespace v8 | 3224 } // namespace v8 |
OLD | NEW |