OLD | NEW |
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 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 ASSERT(*script == *reinterpret_cast<Script**>(entry->value)); | 612 ASSERT(*script == *reinterpret_cast<Script**>(entry->value)); |
613 return; | 613 return; |
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(reinterpret_cast<Object**>(script_.location()), | 620 global_handles->MakeWeak(reinterpret_cast<Object**>(script_.location()), |
621 this, | 621 this, |
622 NULL, | |
623 ScriptCache::HandleWeakScript); | 622 ScriptCache::HandleWeakScript); |
624 entry->value = script_.location(); | 623 entry->value = script_.location(); |
625 } | 624 } |
626 | 625 |
627 | 626 |
628 Handle<FixedArray> ScriptCache::GetScripts() { | 627 Handle<FixedArray> ScriptCache::GetScripts() { |
629 Handle<FixedArray> instances = FACTORY->NewFixedArray(occupancy()); | 628 Handle<FixedArray> instances = FACTORY->NewFixedArray(occupancy()); |
630 int count = 0; | 629 int count = 0; |
631 for (HashMap::Entry* entry = Start(); entry != NULL; entry = Next(entry)) { | 630 for (HashMap::Entry* entry = Start(); entry != NULL; entry = Next(entry)) { |
632 ASSERT(entry->value != NULL); | 631 ASSERT(entry->value != NULL); |
(...skipping 24 matching lines...) Expand all Loading... |
657 ASSERT((*location)->IsScript()); | 656 ASSERT((*location)->IsScript()); |
658 global_handles->ClearWeakness(location); | 657 global_handles->ClearWeakness(location); |
659 global_handles->Destroy(location); | 658 global_handles->Destroy(location); |
660 } | 659 } |
661 // Clear the content of the hash map. | 660 // Clear the content of the hash map. |
662 HashMap::Clear(); | 661 HashMap::Clear(); |
663 } | 662 } |
664 | 663 |
665 | 664 |
666 void ScriptCache::HandleWeakScript(v8::Isolate* isolate, | 665 void ScriptCache::HandleWeakScript(v8::Isolate* isolate, |
667 v8::Persistent<v8::Value> obj, | 666 v8::Persistent<v8::Value>* obj, |
668 void* data) { | 667 void* data) { |
669 ScriptCache* script_cache = reinterpret_cast<ScriptCache*>(data); | 668 ScriptCache* script_cache = reinterpret_cast<ScriptCache*>(data); |
670 // Find the location of the global handle. | 669 // Find the location of the global handle. |
671 Script** location = | 670 Script** location = |
672 reinterpret_cast<Script**>(Utils::OpenHandle(*obj).location()); | 671 reinterpret_cast<Script**>(Utils::OpenHandle(**obj).location()); |
673 ASSERT((*location)->IsScript()); | 672 ASSERT((*location)->IsScript()); |
674 | 673 |
675 // Remove the entry from the cache. | 674 // Remove the entry from the cache. |
676 int id = Smi::cast((*location)->id())->value(); | 675 int id = Smi::cast((*location)->id())->value(); |
677 script_cache->Remove(reinterpret_cast<void*>(id), Hash(id)); | 676 script_cache->Remove(reinterpret_cast<void*>(id), Hash(id)); |
678 script_cache->collected_scripts_.Add(id); | 677 script_cache->collected_scripts_.Add(id); |
679 | 678 |
680 // Clear the weak handle. | 679 // Clear the weak handle. |
681 obj.Dispose(isolate); | 680 obj->Dispose(isolate); |
682 obj.Clear(); | |
683 } | 681 } |
684 | 682 |
685 | 683 |
686 void Debug::SetUp(bool create_heap_objects) { | 684 void Debug::SetUp(bool create_heap_objects) { |
687 ThreadInit(); | 685 ThreadInit(); |
688 if (create_heap_objects) { | 686 if (create_heap_objects) { |
689 // Get code to handle debug break on return. | 687 // Get code to handle debug break on return. |
690 debug_break_return_ = | 688 debug_break_return_ = |
691 isolate_->builtins()->builtin(Builtins::kReturn_DebugBreak); | 689 isolate_->builtins()->builtin(Builtins::kReturn_DebugBreak); |
692 ASSERT(debug_break_return_->IsCode()); | 690 ASSERT(debug_break_return_->IsCode()); |
693 // Get code to handle debug break in debug break slots. | 691 // Get code to handle debug break in debug break slots. |
694 debug_break_slot_ = | 692 debug_break_slot_ = |
695 isolate_->builtins()->builtin(Builtins::kSlot_DebugBreak); | 693 isolate_->builtins()->builtin(Builtins::kSlot_DebugBreak); |
696 ASSERT(debug_break_slot_->IsCode()); | 694 ASSERT(debug_break_slot_->IsCode()); |
697 } | 695 } |
698 } | 696 } |
699 | 697 |
700 | 698 |
701 void Debug::HandleWeakDebugInfo(v8::Isolate* isolate, | 699 void Debug::HandleWeakDebugInfo(v8::Isolate* isolate, |
702 v8::Persistent<v8::Value> obj, | 700 v8::Persistent<v8::Value>* obj, |
703 void* data) { | 701 void* data) { |
704 Debug* debug = reinterpret_cast<Isolate*>(isolate)->debug(); | 702 Debug* debug = reinterpret_cast<Isolate*>(isolate)->debug(); |
705 DebugInfoListNode* node = reinterpret_cast<DebugInfoListNode*>(data); | 703 DebugInfoListNode* node = reinterpret_cast<DebugInfoListNode*>(data); |
706 // We need to clear all breakpoints associated with the function to restore | 704 // We need to clear all breakpoints associated with the function to restore |
707 // original code and avoid patching the code twice later because | 705 // original code and avoid patching the code twice later because |
708 // the function will live in the heap until next gc, and can be found by | 706 // the function will live in the heap until next gc, and can be found by |
709 // Debug::FindSharedFunctionInfoInScript. | 707 // Debug::FindSharedFunctionInfoInScript. |
710 BreakLocationIterator it(node->debug_info(), ALL_BREAK_LOCATIONS); | 708 BreakLocationIterator it(node->debug_info(), ALL_BREAK_LOCATIONS); |
711 it.ClearAllDebugBreak(); | 709 it.ClearAllDebugBreak(); |
712 debug->RemoveDebugInfo(node->debug_info()); | 710 debug->RemoveDebugInfo(node->debug_info()); |
713 #ifdef DEBUG | 711 #ifdef DEBUG |
714 node = debug->debug_info_list_; | 712 node = debug->debug_info_list_; |
715 while (node != NULL) { | 713 while (node != NULL) { |
716 ASSERT(node != reinterpret_cast<DebugInfoListNode*>(data)); | 714 ASSERT(node != reinterpret_cast<DebugInfoListNode*>(data)); |
717 node = node->next(); | 715 node = node->next(); |
718 } | 716 } |
719 #endif | 717 #endif |
720 } | 718 } |
721 | 719 |
722 | 720 |
723 DebugInfoListNode::DebugInfoListNode(DebugInfo* debug_info): next_(NULL) { | 721 DebugInfoListNode::DebugInfoListNode(DebugInfo* debug_info): next_(NULL) { |
724 GlobalHandles* global_handles = Isolate::Current()->global_handles(); | 722 GlobalHandles* global_handles = Isolate::Current()->global_handles(); |
725 // Globalize the request debug info object and make it weak. | 723 // Globalize the request debug info object and make it weak. |
726 debug_info_ = Handle<DebugInfo>::cast( | 724 debug_info_ = Handle<DebugInfo>::cast( |
727 (global_handles->Create(debug_info))); | 725 (global_handles->Create(debug_info))); |
728 global_handles->MakeWeak(reinterpret_cast<Object**>(debug_info_.location()), | 726 global_handles->MakeWeak(reinterpret_cast<Object**>(debug_info_.location()), |
729 this, | 727 this, |
730 NULL, | |
731 Debug::HandleWeakDebugInfo); | 728 Debug::HandleWeakDebugInfo); |
732 } | 729 } |
733 | 730 |
734 | 731 |
735 DebugInfoListNode::~DebugInfoListNode() { | 732 DebugInfoListNode::~DebugInfoListNode() { |
736 Isolate::Current()->global_handles()->Destroy( | 733 Isolate::Current()->global_handles()->Destroy( |
737 reinterpret_cast<Object**>(debug_info_.location())); | 734 reinterpret_cast<Object**>(debug_info_.location())); |
738 } | 735 } |
739 | 736 |
740 | 737 |
(...skipping 3057 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3798 { | 3795 { |
3799 Locker locker(reinterpret_cast<v8::Isolate*>(isolate_)); | 3796 Locker locker(reinterpret_cast<v8::Isolate*>(isolate_)); |
3800 isolate_->debugger()->CallMessageDispatchHandler(); | 3797 isolate_->debugger()->CallMessageDispatchHandler(); |
3801 } | 3798 } |
3802 } | 3799 } |
3803 } | 3800 } |
3804 | 3801 |
3805 #endif // ENABLE_DEBUGGER_SUPPORT | 3802 #endif // ENABLE_DEBUGGER_SUPPORT |
3806 | 3803 |
3807 } } // namespace v8::internal | 3804 } } // namespace v8::internal |
OLD | NEW |