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

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

Issue 1454673002: Debugger: speed up setting break points in nested SFI. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix condition Created 5 years, 1 month 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/debug/debug.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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/debug/debug.h" 5 #include "src/debug/debug.h"
6 6
7 #include "src/api.h" 7 #include "src/api.h"
8 #include "src/arguments.h" 8 #include "src/arguments.h"
9 #include "src/bootstrapper.h" 9 #include "src/bootstrapper.h"
10 #include "src/code-stubs.h" 10 #include "src/code-stubs.h"
(...skipping 1359 matching lines...) Expand 10 before | Expand all | Expand 10 after
1370 1370
1371 class SharedFunctionInfoFinder { 1371 class SharedFunctionInfoFinder {
1372 public: 1372 public:
1373 explicit SharedFunctionInfoFinder(int target_position) 1373 explicit SharedFunctionInfoFinder(int target_position)
1374 : current_candidate_(NULL), 1374 : current_candidate_(NULL),
1375 current_candidate_closure_(NULL), 1375 current_candidate_closure_(NULL),
1376 current_start_position_(RelocInfo::kNoPosition), 1376 current_start_position_(RelocInfo::kNoPosition),
1377 target_position_(target_position) {} 1377 target_position_(target_position) {}
1378 1378
1379 void NewCandidate(SharedFunctionInfo* shared, JSFunction* closure = NULL) { 1379 void NewCandidate(SharedFunctionInfo* shared, JSFunction* closure = NULL) {
1380 if (!shared->IsSubjectToDebugging()) return;
1380 int start_position = shared->function_token_position(); 1381 int start_position = shared->function_token_position();
1381 if (start_position == RelocInfo::kNoPosition) { 1382 if (start_position == RelocInfo::kNoPosition) {
1382 start_position = shared->start_position(); 1383 start_position = shared->start_position();
1383 } 1384 }
1384 1385
1385 if (start_position > target_position_) return; 1386 if (start_position > target_position_) return;
1386 if (target_position_ > shared->end_position()) return; 1387 if (target_position_ > shared->end_position()) return;
1387 1388
1388 if (current_candidate_ != NULL) { 1389 if (current_candidate_ != NULL) {
1389 if (current_start_position_ == start_position && 1390 if (current_start_position_ == start_position &&
(...skipping 29 matching lines...) Expand all
1419 1420
1420 1421
1421 // We need to find a SFI for a literal that may not yet have been compiled yet, 1422 // We need to find a SFI for a literal that may not yet have been compiled yet,
1422 // and there may not be a JSFunction referencing it. Find the SFI closest to 1423 // and there may not be a JSFunction referencing it. Find the SFI closest to
1423 // the given position, compile it to reveal possible inner SFIs and repeat. 1424 // the given position, compile it to reveal possible inner SFIs and repeat.
1424 // While we are at this, also ensure code with debug break slots so that we do 1425 // While we are at this, also ensure code with debug break slots so that we do
1425 // not have to compile a SFI without JSFunction, which is paifu for those that 1426 // not have to compile a SFI without JSFunction, which is paifu for those that
1426 // cannot be compiled without context (need to find outer compilable SFI etc.) 1427 // cannot be compiled without context (need to find outer compilable SFI etc.)
1427 Handle<Object> Debug::FindSharedFunctionInfoInScript(Handle<Script> script, 1428 Handle<Object> Debug::FindSharedFunctionInfoInScript(Handle<Script> script,
1428 int position) { 1429 int position) {
1429 while (true) { 1430 for (int iteration = 0;; iteration++) {
1430 // Go through all shared function infos associated with this script to 1431 // Go through all shared function infos associated with this script to
1431 // find the inner most function containing this position. 1432 // find the inner most function containing this position.
1432 // If there is no shared function info for this script at all, there is 1433 // If there is no shared function info for this script at all, there is
1433 // no point in looking for it by walking the heap. 1434 // no point in looking for it by walking the heap.
1434 if (!script->shared_function_infos()->IsWeakFixedArray()) break; 1435 if (!script->shared_function_infos()->IsWeakFixedArray()) break;
1435 1436
1436 SharedFunctionInfo* shared; 1437 SharedFunctionInfo* shared;
1437 { 1438 {
1438 SharedFunctionInfoFinder finder(position); 1439 SharedFunctionInfoFinder finder(position);
1439 WeakFixedArray::Iterator iterator(script->shared_function_infos()); 1440 WeakFixedArray::Iterator iterator(script->shared_function_infos());
1440 SharedFunctionInfo* candidate; 1441 SharedFunctionInfo* candidate;
1441 while ((candidate = iterator.Next<SharedFunctionInfo>())) { 1442 while ((candidate = iterator.Next<SharedFunctionInfo>())) {
1442 finder.NewCandidate(candidate); 1443 finder.NewCandidate(candidate);
1443 } 1444 }
1444 shared = finder.Result(); 1445 shared = finder.Result();
1445 if (shared == NULL) break; 1446 if (shared == NULL) break;
1446 // We found it if it's already compiled and has debug code. 1447 // We found it if it's already compiled and has debug code.
1447 if (shared->HasDebugCode()) return handle(shared); 1448 if (shared->HasDebugCode()) {
1449 Handle<SharedFunctionInfo> shared_handle(shared);
1450 // If the iteration count is larger than 1, we had to compile the outer
1451 // function in order to create this shared function info. So there can
1452 // be no JSFunction referencing it. We can anticipate creating a debug
1453 // info while bypassing PrepareFunctionForBreakpoints.
1454 if (iteration > 1) {
1455 AllowHeapAllocation allow_before_return;
1456 CreateDebugInfo(shared_handle);
1457 }
1458 return shared_handle;
1459 }
1448 } 1460 }
1449 // If not, compile to reveal inner functions, if possible. 1461 // If not, compile to reveal inner functions, if possible.
1450 if (shared->allows_lazy_compilation_without_context()) { 1462 if (shared->allows_lazy_compilation_without_context()) {
1451 HandleScope scope(isolate_); 1463 HandleScope scope(isolate_);
1452 if (!Compiler::CompileDebugCode(handle(shared))) break; 1464 if (!Compiler::CompileDebugCode(handle(shared))) break;
1453 continue; 1465 continue;
1454 } 1466 }
1455 1467
1456 // If not possible, comb the heap for the best suitable compile target. 1468 // If not possible, comb the heap for the best suitable compile target.
1457 JSFunction* closure; 1469 JSFunction* closure;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1502 return false; 1514 return false;
1503 } 1515 }
1504 1516
1505 if (!PrepareFunctionForBreakPoints(shared)) return false; 1517 if (!PrepareFunctionForBreakPoints(shared)) return false;
1506 1518
1507 // Make sure IC state is clean. This is so that we correctly flood 1519 // Make sure IC state is clean. This is so that we correctly flood
1508 // accessor pairs when stepping in. 1520 // accessor pairs when stepping in.
1509 shared->code()->ClearInlineCaches(); 1521 shared->code()->ClearInlineCaches();
1510 shared->ClearTypeFeedbackInfo(); 1522 shared->ClearTypeFeedbackInfo();
1511 1523
1524 CreateDebugInfo(shared);
1525
1526 return true;
1527 }
1528
1529
1530 void Debug::CreateDebugInfo(Handle<SharedFunctionInfo> shared) {
1512 // Create the debug info object. 1531 // Create the debug info object.
1513 DCHECK(shared->HasDebugCode()); 1532 DCHECK(shared->HasDebugCode());
1514 Handle<DebugInfo> debug_info = isolate_->factory()->NewDebugInfo(shared); 1533 Handle<DebugInfo> debug_info = isolate_->factory()->NewDebugInfo(shared);
1515 1534
1516 // Add debug info to the list. 1535 // Add debug info to the list.
1517 DebugInfoListNode* node = new DebugInfoListNode(*debug_info); 1536 DebugInfoListNode* node = new DebugInfoListNode(*debug_info);
1518 node->set_next(debug_info_list_); 1537 node->set_next(debug_info_list_);
1519 debug_info_list_ = node; 1538 debug_info_list_ = node;
1520
1521 return true;
1522 } 1539 }
1523 1540
1524 1541
1525 void Debug::RemoveDebugInfoAndClearFromShared(Handle<DebugInfo> debug_info) { 1542 void Debug::RemoveDebugInfoAndClearFromShared(Handle<DebugInfo> debug_info) {
1526 HandleScope scope(isolate_); 1543 HandleScope scope(isolate_);
1527 Handle<SharedFunctionInfo> shared(debug_info->shared()); 1544 Handle<SharedFunctionInfo> shared(debug_info->shared());
1528 1545
1529 DCHECK_NOT_NULL(debug_info_list_); 1546 DCHECK_NOT_NULL(debug_info_list_);
1530 // Run through the debug info objects to find this one and remove it. 1547 // Run through the debug info objects to find this one and remove it.
1531 DebugInfoListNode* prev = NULL; 1548 DebugInfoListNode* prev = NULL;
(...skipping 1053 matching lines...) Expand 10 before | Expand all | Expand 10 after
2585 } 2602 }
2586 2603
2587 2604
2588 void LockingCommandMessageQueue::Clear() { 2605 void LockingCommandMessageQueue::Clear() {
2589 base::LockGuard<base::Mutex> lock_guard(&mutex_); 2606 base::LockGuard<base::Mutex> lock_guard(&mutex_);
2590 queue_.Clear(); 2607 queue_.Clear();
2591 } 2608 }
2592 2609
2593 } // namespace internal 2610 } // namespace internal
2594 } // namespace v8 2611 } // namespace v8
OLDNEW
« no previous file with comments | « src/debug/debug.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698