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

Side by Side Diff: src/debug.cc

Issue 12033011: Add Isolate parameter to Persistent class. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Added explicit Created 7 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « src/debug.h ('k') | src/deoptimizer.h » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 if (entry->value != NULL) { 610 if (entry->value != NULL) {
611 ASSERT(*script == *reinterpret_cast<Script**>(entry->value)); 611 ASSERT(*script == *reinterpret_cast<Script**>(entry->value));
612 return; 612 return;
613 } 613 }
614 614
615 // Globalize the script object, make it weak and use the location of the 615 // Globalize the script object, make it weak and use the location of the
616 // global handle as the value in the hash map. 616 // global handle as the value in the hash map.
617 Handle<Script> script_ = 617 Handle<Script> script_ =
618 Handle<Script>::cast( 618 Handle<Script>::cast(
619 (global_handles->Create(*script))); 619 (global_handles->Create(*script)));
620 global_handles->MakeWeak( 620 global_handles->MakeWeak(reinterpret_cast<Object**>(script_.location()),
621 reinterpret_cast<Object**>(script_.location()), 621 this,
622 this, 622 NULL,
623 ScriptCache::HandleWeakScript); 623 ScriptCache::HandleWeakScript);
624 entry->value = script_.location(); 624 entry->value = script_.location();
625 } 625 }
626 626
627 627
628 Handle<FixedArray> ScriptCache::GetScripts() { 628 Handle<FixedArray> ScriptCache::GetScripts() {
629 Handle<FixedArray> instances = FACTORY->NewFixedArray(occupancy()); 629 Handle<FixedArray> instances = FACTORY->NewFixedArray(occupancy());
630 int count = 0; 630 int count = 0;
631 for (HashMap::Entry* entry = Start(); entry != NULL; entry = Next(entry)) { 631 for (HashMap::Entry* entry = Start(); entry != NULL; entry = Next(entry)) {
632 ASSERT(entry->value != NULL); 632 ASSERT(entry->value != NULL);
633 if (entry->value != NULL) { 633 if (entry->value != NULL) {
(...skipping 22 matching lines...) Expand all
656 Object** location = reinterpret_cast<Object**>(entry->value); 656 Object** location = reinterpret_cast<Object**>(entry->value);
657 ASSERT((*location)->IsScript()); 657 ASSERT((*location)->IsScript());
658 global_handles->ClearWeakness(location); 658 global_handles->ClearWeakness(location);
659 global_handles->Destroy(location); 659 global_handles->Destroy(location);
660 } 660 }
661 // Clear the content of the hash map. 661 // Clear the content of the hash map.
662 HashMap::Clear(); 662 HashMap::Clear();
663 } 663 }
664 664
665 665
666 void ScriptCache::HandleWeakScript(v8::Persistent<v8::Value> obj, void* data) { 666 void ScriptCache::HandleWeakScript(v8::Isolate* isolate,
667 v8::Persistent<v8::Value> obj,
668 void* data) {
667 ScriptCache* script_cache = reinterpret_cast<ScriptCache*>(data); 669 ScriptCache* script_cache = reinterpret_cast<ScriptCache*>(data);
668 // Find the location of the global handle. 670 // Find the location of the global handle.
669 Script** location = 671 Script** location =
670 reinterpret_cast<Script**>(Utils::OpenHandle(*obj).location()); 672 reinterpret_cast<Script**>(Utils::OpenHandle(*obj).location());
671 ASSERT((*location)->IsScript()); 673 ASSERT((*location)->IsScript());
672 674
673 // Remove the entry from the cache. 675 // Remove the entry from the cache.
674 int id = Smi::cast((*location)->id())->value(); 676 int id = Smi::cast((*location)->id())->value();
675 script_cache->Remove(reinterpret_cast<void*>(id), Hash(id)); 677 script_cache->Remove(reinterpret_cast<void*>(id), Hash(id));
676 script_cache->collected_scripts_.Add(id); 678 script_cache->collected_scripts_.Add(id);
677 679
678 // Clear the weak handle. 680 // Clear the weak handle.
679 obj.Dispose(); 681 obj.Dispose(isolate);
680 obj.Clear(); 682 obj.Clear();
681 } 683 }
682 684
683 685
684 void Debug::SetUp(bool create_heap_objects) { 686 void Debug::SetUp(bool create_heap_objects) {
685 ThreadInit(); 687 ThreadInit();
686 if (create_heap_objects) { 688 if (create_heap_objects) {
687 // Get code to handle debug break on return. 689 // Get code to handle debug break on return.
688 debug_break_return_ = 690 debug_break_return_ =
689 isolate_->builtins()->builtin(Builtins::kReturn_DebugBreak); 691 isolate_->builtins()->builtin(Builtins::kReturn_DebugBreak);
690 ASSERT(debug_break_return_->IsCode()); 692 ASSERT(debug_break_return_->IsCode());
691 // Get code to handle debug break in debug break slots. 693 // Get code to handle debug break in debug break slots.
692 debug_break_slot_ = 694 debug_break_slot_ =
693 isolate_->builtins()->builtin(Builtins::kSlot_DebugBreak); 695 isolate_->builtins()->builtin(Builtins::kSlot_DebugBreak);
694 ASSERT(debug_break_slot_->IsCode()); 696 ASSERT(debug_break_slot_->IsCode());
695 } 697 }
696 } 698 }
697 699
698 700
699 void Debug::HandleWeakDebugInfo(v8::Persistent<v8::Value> obj, void* data) { 701 void Debug::HandleWeakDebugInfo(v8::Isolate* isolate,
700 Debug* debug = Isolate::Current()->debug(); 702 v8::Persistent<v8::Value> obj,
703 void* data) {
704 Debug* debug = reinterpret_cast<Isolate*>(isolate)->debug();
701 DebugInfoListNode* node = reinterpret_cast<DebugInfoListNode*>(data); 705 DebugInfoListNode* node = reinterpret_cast<DebugInfoListNode*>(data);
702 // We need to clear all breakpoints associated with the function to restore 706 // We need to clear all breakpoints associated with the function to restore
703 // original code and avoid patching the code twice later because 707 // original code and avoid patching the code twice later because
704 // the function will live in the heap until next gc, and can be found by 708 // the function will live in the heap until next gc, and can be found by
705 // Debug::FindSharedFunctionInfoInScript. 709 // Debug::FindSharedFunctionInfoInScript.
706 BreakLocationIterator it(node->debug_info(), ALL_BREAK_LOCATIONS); 710 BreakLocationIterator it(node->debug_info(), ALL_BREAK_LOCATIONS);
707 it.ClearAllDebugBreak(); 711 it.ClearAllDebugBreak();
708 debug->RemoveDebugInfo(node->debug_info()); 712 debug->RemoveDebugInfo(node->debug_info());
709 #ifdef DEBUG 713 #ifdef DEBUG
710 node = debug->debug_info_list_; 714 node = debug->debug_info_list_;
711 while (node != NULL) { 715 while (node != NULL) {
712 ASSERT(node != reinterpret_cast<DebugInfoListNode*>(data)); 716 ASSERT(node != reinterpret_cast<DebugInfoListNode*>(data));
713 node = node->next(); 717 node = node->next();
714 } 718 }
715 #endif 719 #endif
716 } 720 }
717 721
718 722
719 DebugInfoListNode::DebugInfoListNode(DebugInfo* debug_info): next_(NULL) { 723 DebugInfoListNode::DebugInfoListNode(DebugInfo* debug_info): next_(NULL) {
720 GlobalHandles* global_handles = Isolate::Current()->global_handles(); 724 GlobalHandles* global_handles = Isolate::Current()->global_handles();
721 // Globalize the request debug info object and make it weak. 725 // Globalize the request debug info object and make it weak.
722 debug_info_ = Handle<DebugInfo>::cast( 726 debug_info_ = Handle<DebugInfo>::cast(
723 (global_handles->Create(debug_info))); 727 (global_handles->Create(debug_info)));
724 global_handles->MakeWeak( 728 global_handles->MakeWeak(reinterpret_cast<Object**>(debug_info_.location()),
725 reinterpret_cast<Object**>(debug_info_.location()), 729 this,
726 this, 730 NULL,
727 Debug::HandleWeakDebugInfo); 731 Debug::HandleWeakDebugInfo);
728 } 732 }
729 733
730 734
731 DebugInfoListNode::~DebugInfoListNode() { 735 DebugInfoListNode::~DebugInfoListNode() {
732 Isolate::Current()->global_handles()->Destroy( 736 Isolate::Current()->global_handles()->Destroy(
733 reinterpret_cast<Object**>(debug_info_.location())); 737 reinterpret_cast<Object**>(debug_info_.location()));
734 } 738 }
735 739
736 740
737 bool Debug::CompileDebuggerScript(int index) { 741 bool Debug::CompileDebuggerScript(int index) {
(...skipping 3039 matching lines...) Expand 10 before | Expand all | Expand 10 after
3777 { 3781 {
3778 Locker locker(reinterpret_cast<v8::Isolate*>(isolate)); 3782 Locker locker(reinterpret_cast<v8::Isolate*>(isolate));
3779 isolate->debugger()->CallMessageDispatchHandler(); 3783 isolate->debugger()->CallMessageDispatchHandler();
3780 } 3784 }
3781 } 3785 }
3782 } 3786 }
3783 3787
3784 #endif // ENABLE_DEBUGGER_SUPPORT 3788 #endif // ENABLE_DEBUGGER_SUPPORT
3785 3789
3786 } } // namespace v8::internal 3790 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/debug.h ('k') | src/deoptimizer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698