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

Side by Side Diff: src/ppc/simulator-ppc.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/ppc/simulator-ppc.h ('k') | test/cctest/test-disasm-arm64.cc » ('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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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 812 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 // The sp is initialized to point to the bottom (high address) of the 823 // The sp is initialized to point to the bottom (high address) of the
824 // allocated stack area. To be safe in potential stack underflows we leave 824 // allocated stack area. To be safe in potential stack underflows we leave
825 // some buffer below. 825 // some buffer below.
826 registers_[sp] = reinterpret_cast<intptr_t>(stack_) + stack_size - 64; 826 registers_[sp] = reinterpret_cast<intptr_t>(stack_) + stack_size - 64;
827 InitializeCoverage(); 827 InitializeCoverage();
828 828
829 last_debugger_input_ = NULL; 829 last_debugger_input_ = NULL;
830 } 830 }
831 831
832 832
833 Simulator::~Simulator() {} 833 Simulator::~Simulator() { free(stack_); }
834 834
835 835
836 // When the generated code calls an external reference we need to catch that in 836 // When the generated code calls an external reference we need to catch that in
837 // the simulator. The external reference will be a function compiled for the 837 // the simulator. The external reference will be a function compiled for the
838 // host architecture. We need to call that function instead of trying to 838 // host architecture. We need to call that function instead of trying to
839 // execute it with the simulator. We do that by redirecting the external 839 // execute it with the simulator. We do that by redirecting the external
840 // reference to a svc (Supervisor Call) instruction that is handled by 840 // reference to a svc (Supervisor Call) instruction that is handled by
841 // the simulator. We write the original destination of the jump just at a known 841 // the simulator. We write the original destination of the jump just at a known
842 // offset from the svc instruction so the simulator knows what to call. 842 // offset from the svc instruction so the simulator knows what to call.
843 class Redirection { 843 class Redirection {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 addr_of_swi - OFFSET_OF(Redirection, swi_instruction_); 881 addr_of_swi - OFFSET_OF(Redirection, swi_instruction_);
882 return reinterpret_cast<Redirection*>(addr_of_redirection); 882 return reinterpret_cast<Redirection*>(addr_of_redirection);
883 } 883 }
884 884
885 static void* ReverseRedirection(intptr_t reg) { 885 static void* ReverseRedirection(intptr_t reg) {
886 Redirection* redirection = FromSwiInstruction( 886 Redirection* redirection = FromSwiInstruction(
887 reinterpret_cast<Instruction*>(reinterpret_cast<void*>(reg))); 887 reinterpret_cast<Instruction*>(reinterpret_cast<void*>(reg)));
888 return redirection->external_function(); 888 return redirection->external_function();
889 } 889 }
890 890
891 static void DeleteChain(Redirection* redirection) {
892 while (redirection != nullptr) {
893 Redirection* next = redirection->next_;
894 delete redirection;
895 redirection = next;
896 }
897 }
898
891 private: 899 private:
892 void* external_function_; 900 void* external_function_;
893 uint32_t swi_instruction_; 901 uint32_t swi_instruction_;
894 ExternalReference::Type type_; 902 ExternalReference::Type type_;
895 Redirection* next_; 903 Redirection* next_;
896 }; 904 };
897 905
898 906
907 // static
908 void Simulator::TearDown(HashMap* i_cache, Redirection* first) {
909 Redirection::DeleteChain(first);
910 if (i_cache != nullptr) {
911 for (HashMap::Entry* entry = i_cache->Start(); entry != nullptr;
912 entry = i_cache->Next(entry)) {
913 delete static_cast<CachePage*>(entry->value);
914 }
915 delete i_cache;
916 }
917 }
918
919
899 void* Simulator::RedirectExternalReference(void* external_function, 920 void* Simulator::RedirectExternalReference(void* external_function,
900 ExternalReference::Type type) { 921 ExternalReference::Type type) {
901 Redirection* redirection = Redirection::Get(external_function, type); 922 Redirection* redirection = Redirection::Get(external_function, type);
902 return redirection->address_of_swi_instruction(); 923 return redirection->address_of_swi_instruction();
903 } 924 }
904 925
905 926
906 // Get the active Simulator for the current thread. 927 // Get the active Simulator for the current thread.
907 Simulator* Simulator::current(Isolate* isolate) { 928 Simulator* Simulator::current(Isolate* isolate) {
908 v8::internal::Isolate::PerIsolateThreadData* isolate_data = 929 v8::internal::Isolate::PerIsolateThreadData* isolate_data =
(...skipping 2966 matching lines...) Expand 10 before | Expand all | Expand 10 after
3875 uintptr_t* stack_slot = reinterpret_cast<uintptr_t*>(current_sp); 3896 uintptr_t* stack_slot = reinterpret_cast<uintptr_t*>(current_sp);
3876 uintptr_t address = *stack_slot; 3897 uintptr_t address = *stack_slot;
3877 set_register(sp, current_sp + sizeof(uintptr_t)); 3898 set_register(sp, current_sp + sizeof(uintptr_t));
3878 return address; 3899 return address;
3879 } 3900 }
3880 } 3901 }
3881 } // namespace v8::internal 3902 } // namespace v8::internal
3882 3903
3883 #endif // USE_SIMULATOR 3904 #endif // USE_SIMULATOR
3884 #endif // V8_TARGET_ARCH_PPC 3905 #endif // V8_TARGET_ARCH_PPC
OLDNEW
« no previous file with comments | « src/ppc/simulator-ppc.h ('k') | test/cctest/test-disasm-arm64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698