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

Side by Side Diff: src/debug.cc

Issue 1255793003: Debugger: do not hold onto debug infos weakly. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase and address comments Created 5 years, 4 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/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/v8.h" 5 #include "src/v8.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 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 global_handles->Create(Object::cast(*new_table))); 407 global_handles->Create(Object::cast(*new_table)));
408 } 408 }
409 409
410 410
411 ScriptCache::~ScriptCache() { 411 ScriptCache::~ScriptCache() {
412 isolate_->global_handles()->Destroy(Handle<Object>::cast(table_).location()); 412 isolate_->global_handles()->Destroy(Handle<Object>::cast(table_).location());
413 table_ = Handle<WeakValueHashTable>(); 413 table_ = Handle<WeakValueHashTable>();
414 } 414 }
415 415
416 416
417 void Debug::HandlePhantomDebugInfo(
418 const v8::WeakCallbackInfo<DebugInfoListNode>& data) {
419 DebugInfoListNode* node = data.GetParameter();
420 node->ClearInfo();
421 Debug* debug = reinterpret_cast<Isolate*>(data.GetIsolate())->debug();
422 debug->RemoveDebugInfo(node);
423 #ifdef DEBUG
424 for (DebugInfoListNode* n = debug->debug_info_list_;
425 n != NULL;
426 n = n->next()) {
427 DCHECK(n != node);
428 }
429 #endif
430 }
431
432
433 DebugInfoListNode::DebugInfoListNode(DebugInfo* debug_info): next_(NULL) { 417 DebugInfoListNode::DebugInfoListNode(DebugInfo* debug_info): next_(NULL) {
434 // Globalize the request debug info object and make it weak. 418 // Globalize the request debug info object and make it weak.
435 GlobalHandles* global_handles = debug_info->GetIsolate()->global_handles(); 419 GlobalHandles* global_handles = debug_info->GetIsolate()->global_handles();
436 debug_info_ = 420 debug_info_ =
437 Handle<DebugInfo>::cast(global_handles->Create(debug_info)).location(); 421 Handle<DebugInfo>::cast(global_handles->Create(debug_info)).location();
438 typedef WeakCallbackInfo<void>::Callback Callback;
439 GlobalHandles::MakeWeak(
440 reinterpret_cast<Object**>(debug_info_), this,
441 reinterpret_cast<Callback>(Debug::HandlePhantomDebugInfo),
442 v8::WeakCallbackType::kParameter);
443 } 422 }
444 423
445 424
446 void DebugInfoListNode::ClearInfo() { 425 DebugInfoListNode::~DebugInfoListNode() {
447 if (debug_info_ == nullptr) return; 426 if (debug_info_ == nullptr) return;
448 GlobalHandles::Destroy(reinterpret_cast<Object**>(debug_info_)); 427 GlobalHandles::Destroy(reinterpret_cast<Object**>(debug_info_));
449 debug_info_ = nullptr; 428 debug_info_ = nullptr;
450 } 429 }
451 430
452 431
453 bool Debug::CompileDebuggerScript(Isolate* isolate, int index) { 432 bool Debug::CompileDebuggerScript(Isolate* isolate, int index) {
454 Factory* factory = isolate->factory(); 433 Factory* factory = isolate->factory();
455 HandleScope scope(isolate); 434 HandleScope scope(isolate);
456 435
(...skipping 1190 matching lines...) Expand 10 before | Expand all | Expand 10 after
1647 1626
1648 // Add debug info to the list. 1627 // Add debug info to the list.
1649 DebugInfoListNode* node = new DebugInfoListNode(*debug_info); 1628 DebugInfoListNode* node = new DebugInfoListNode(*debug_info);
1650 node->set_next(debug_info_list_); 1629 node->set_next(debug_info_list_);
1651 debug_info_list_ = node; 1630 debug_info_list_ = node;
1652 1631
1653 return true; 1632 return true;
1654 } 1633 }
1655 1634
1656 1635
1657 void Debug::RemoveDebugInfo(DebugInfoListNode* prev, DebugInfoListNode* node) {
1658 // Unlink from list. If prev is NULL we are looking at the first element.
1659 if (prev == NULL) {
1660 debug_info_list_ = node->next();
1661 } else {
1662 prev->set_next(node->next());
1663 }
1664 delete node;
1665 }
1666
1667
1668 void Debug::RemoveDebugInfo(DebugInfo** debug_info) {
1669 DCHECK(debug_info_list_ != NULL);
1670 // Run through the debug info objects to find this one and remove it.
1671 DebugInfoListNode* prev = NULL;
1672 DebugInfoListNode* current = debug_info_list_;
1673 while (current != NULL) {
1674 if (current->debug_info().location() == debug_info) {
1675 RemoveDebugInfo(prev, current);
1676 return;
1677 }
1678 // Move to next in list.
1679 prev = current;
1680 current = current->next();
1681 }
1682 UNREACHABLE();
1683 }
1684
1685
1686 void Debug::RemoveDebugInfo(DebugInfoListNode* node) {
1687 DCHECK(debug_info_list_ != NULL);
1688 // Run through the debug info objects to find this one and remove it.
1689 DebugInfoListNode* prev = NULL;
1690 DebugInfoListNode* current = debug_info_list_;
1691 while (current != NULL) {
1692 if (current == node) {
1693 RemoveDebugInfo(prev, node);
1694 return;
1695 }
1696 // Move to next in list.
1697 prev = current;
1698 current = current->next();
1699 }
1700 UNREACHABLE();
1701 }
1702
1703
1704 void Debug::RemoveDebugInfoAndClearFromShared(Handle<DebugInfo> debug_info) { 1636 void Debug::RemoveDebugInfoAndClearFromShared(Handle<DebugInfo> debug_info) {
1705 HandleScope scope(isolate_); 1637 HandleScope scope(isolate_);
1706 Handle<SharedFunctionInfo> shared(debug_info->shared()); 1638 Handle<SharedFunctionInfo> shared(debug_info->shared());
1707 1639
1708 RemoveDebugInfo(debug_info.location()); 1640 DCHECK_NOT_NULL(debug_info_list_);
1641 // Run through the debug info objects to find this one and remove it.
1642 DebugInfoListNode* prev = NULL;
1643 DebugInfoListNode* current = debug_info_list_;
1644 while (current != NULL) {
1645 if (current->debug_info().is_identical_to(debug_info)) {
1646 // Unlink from list. If prev is NULL we are looking at the first element.
1647 if (prev == NULL) {
1648 debug_info_list_ = current->next();
1649 } else {
1650 prev->set_next(current->next());
1651 }
1652 delete current;
1653 shared->set_debug_info(isolate_->heap()->undefined_value());
1654 return;
1655 }
1656 // Move to next in list.
1657 prev = current;
1658 current = current->next();
1659 }
1709 1660
1710 shared->set_debug_info(isolate_->heap()->undefined_value()); 1661 UNREACHABLE();
1711 } 1662 }
1712 1663
1713 1664
1714 void Debug::SetAfterBreakTarget(JavaScriptFrame* frame) { 1665 void Debug::SetAfterBreakTarget(JavaScriptFrame* frame) {
1715 after_break_target_ = NULL; 1666 after_break_target_ = NULL;
1716 1667
1717 if (LiveEdit::SetAfterBreakTarget(this)) return; // LiveEdit did the job. 1668 if (LiveEdit::SetAfterBreakTarget(this)) return; // LiveEdit did the job.
1718 1669
1719 // Continue just after the slot. 1670 // Continue just after the slot.
1720 after_break_target_ = frame->pc(); 1671 after_break_target_ = frame->pc();
(...skipping 1104 matching lines...) Expand 10 before | Expand all | Expand 10 after
2825 } 2776 }
2826 2777
2827 2778
2828 void LockingCommandMessageQueue::Clear() { 2779 void LockingCommandMessageQueue::Clear() {
2829 base::LockGuard<base::Mutex> lock_guard(&mutex_); 2780 base::LockGuard<base::Mutex> lock_guard(&mutex_);
2830 queue_.Clear(); 2781 queue_.Clear();
2831 } 2782 }
2832 2783
2833 } // namespace internal 2784 } // namespace internal
2834 } // namespace v8 2785 } // namespace v8
OLDNEW
« no previous file with comments | « src/debug.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698