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

Side by Side Diff: src/arm/simulator-arm.cc

Issue 1132943007: Fixed various simulator-related space leaks. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fixed a leak in ARM64 disassembler. Created 5 years, 7 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/arm/simulator-arm.h ('k') | src/arm64/simulator-arm64.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 // 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 <stdarg.h> 5 #include <stdarg.h>
6 #include <stdlib.h> 6 #include <stdlib.h>
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "src/v8.h" 9 #include "src/v8.h"
10 10
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 // The lr and pc are initialized to a known bad value that will cause an 767 // The lr and pc are initialized to a known bad value that will cause an
768 // access violation if the simulator ever tries to execute it. 768 // access violation if the simulator ever tries to execute it.
769 registers_[pc] = bad_lr; 769 registers_[pc] = bad_lr;
770 registers_[lr] = bad_lr; 770 registers_[lr] = bad_lr;
771 InitializeCoverage(); 771 InitializeCoverage();
772 772
773 last_debugger_input_ = NULL; 773 last_debugger_input_ = NULL;
774 } 774 }
775 775
776 776
777 Simulator::~Simulator() { 777 Simulator::~Simulator() { free(stack_); }
778 }
779 778
780 779
781 // When the generated code calls an external reference we need to catch that in 780 // When the generated code calls an external reference we need to catch that in
782 // the simulator. The external reference will be a function compiled for the 781 // the simulator. The external reference will be a function compiled for the
783 // host architecture. We need to call that function instead of trying to 782 // host architecture. We need to call that function instead of trying to
784 // execute it with the simulator. We do that by redirecting the external 783 // execute it with the simulator. We do that by redirecting the external
785 // reference to a svc (Supervisor Call) instruction that is handled by 784 // reference to a svc (Supervisor Call) instruction that is handled by
786 // the simulator. We write the original destination of the jump just at a known 785 // the simulator. We write the original destination of the jump just at a known
787 // offset from the svc instruction so the simulator knows what to call. 786 // offset from the svc instruction so the simulator knows what to call.
788 class Redirection { 787 class Redirection {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 addr_of_swi - OFFSET_OF(Redirection, swi_instruction_); 826 addr_of_swi - OFFSET_OF(Redirection, swi_instruction_);
828 return reinterpret_cast<Redirection*>(addr_of_redirection); 827 return reinterpret_cast<Redirection*>(addr_of_redirection);
829 } 828 }
830 829
831 static void* ReverseRedirection(int32_t reg) { 830 static void* ReverseRedirection(int32_t reg) {
832 Redirection* redirection = FromSwiInstruction( 831 Redirection* redirection = FromSwiInstruction(
833 reinterpret_cast<Instruction*>(reinterpret_cast<void*>(reg))); 832 reinterpret_cast<Instruction*>(reinterpret_cast<void*>(reg)));
834 return redirection->external_function(); 833 return redirection->external_function();
835 } 834 }
836 835
836 static void DeleteChain(Redirection* redirection) {
837 while (redirection != nullptr) {
838 Redirection* next = redirection->next_;
839 delete redirection;
840 redirection = next;
841 }
842 }
843
837 private: 844 private:
838 void* external_function_; 845 void* external_function_;
839 uint32_t swi_instruction_; 846 uint32_t swi_instruction_;
840 ExternalReference::Type type_; 847 ExternalReference::Type type_;
841 Redirection* next_; 848 Redirection* next_;
842 }; 849 };
843 850
844 851
852 // static
853 void Simulator::TearDown(HashMap* i_cache, Redirection* first) {
854 Redirection::DeleteChain(first);
855 if (i_cache != nullptr) {
856 for (HashMap::Entry* entry = i_cache->Start(); entry != nullptr;
857 entry = i_cache->Next(entry)) {
858 delete static_cast<CachePage*>(entry->value);
859 }
860 delete i_cache;
861 }
862 }
863
864
845 void* Simulator::RedirectExternalReference(void* external_function, 865 void* Simulator::RedirectExternalReference(void* external_function,
846 ExternalReference::Type type) { 866 ExternalReference::Type type) {
847 Redirection* redirection = Redirection::Get(external_function, type); 867 Redirection* redirection = Redirection::Get(external_function, type);
848 return redirection->address_of_swi_instruction(); 868 return redirection->address_of_swi_instruction();
849 } 869 }
850 870
851 871
852 // Get the active Simulator for the current thread. 872 // Get the active Simulator for the current thread.
853 Simulator* Simulator::current(Isolate* isolate) { 873 Simulator* Simulator::current(Isolate* isolate) {
854 v8::internal::Isolate::PerIsolateThreadData* isolate_data = 874 v8::internal::Isolate::PerIsolateThreadData* isolate_data =
(...skipping 3274 matching lines...) Expand 10 before | Expand all | Expand 10 after
4129 uintptr_t address = *stack_slot; 4149 uintptr_t address = *stack_slot;
4130 set_register(sp, current_sp + sizeof(uintptr_t)); 4150 set_register(sp, current_sp + sizeof(uintptr_t));
4131 return address; 4151 return address;
4132 } 4152 }
4133 4153
4134 } } // namespace v8::internal 4154 } } // namespace v8::internal
4135 4155
4136 #endif // USE_SIMULATOR 4156 #endif // USE_SIMULATOR
4137 4157
4138 #endif // V8_TARGET_ARCH_ARM 4158 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « src/arm/simulator-arm.h ('k') | src/arm64/simulator-arm64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698