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/arm/simulator-arm.cc

Issue 1457223005: Remove a bunch of Isolate::Current() callsites from simulators (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 5 years, 1 month 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 #if V8_TARGET_ARCH_ARM 9 #if V8_TARGET_ARCH_ARM
10 10
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 words = 10; 383 words = 10;
384 } 384 }
385 } 385 }
386 end = cur + words; 386 end = cur + words;
387 387
388 while (cur < end) { 388 while (cur < end) {
389 PrintF(" 0x%08x: 0x%08x %10d", 389 PrintF(" 0x%08x: 0x%08x %10d",
390 reinterpret_cast<intptr_t>(cur), *cur, *cur); 390 reinterpret_cast<intptr_t>(cur), *cur, *cur);
391 HeapObject* obj = reinterpret_cast<HeapObject*>(*cur); 391 HeapObject* obj = reinterpret_cast<HeapObject*>(*cur);
392 int value = *cur; 392 int value = *cur;
393 Heap* current_heap = v8::internal::Isolate::Current()->heap(); 393 Heap* current_heap = sim_->isolate_->heap();
394 if (((value & 1) == 0) || current_heap->Contains(obj)) { 394 if (((value & 1) == 0) || current_heap->Contains(obj)) {
395 PrintF(" ("); 395 PrintF(" (");
396 if ((value & 1) == 0) { 396 if ((value & 1) == 0) {
397 PrintF("smi %d", value / 2); 397 PrintF("smi %d", value / 2);
398 } else { 398 } else {
399 obj->ShortPrint(); 399 obj->ShortPrint();
400 } 400 }
401 PrintF(")"); 401 PrintF(")");
402 } 402 }
403 PrintF("\n"); 403 PrintF("\n");
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 778
779 // When the generated code calls an external reference we need to catch that in 779 // When the generated code calls an external reference we need to catch that in
780 // the simulator. The external reference will be a function compiled for the 780 // the simulator. The external reference will be a function compiled for the
781 // host architecture. We need to call that function instead of trying to 781 // host architecture. We need to call that function instead of trying to
782 // execute it with the simulator. We do that by redirecting the external 782 // execute it with the simulator. We do that by redirecting the external
783 // reference to a svc (Supervisor Call) instruction that is handled by 783 // reference to a svc (Supervisor Call) instruction that is handled by
784 // the simulator. We write the original destination of the jump just at a known 784 // the simulator. We write the original destination of the jump just at a known
785 // offset from the svc instruction so the simulator knows what to call. 785 // offset from the svc instruction so the simulator knows what to call.
786 class Redirection { 786 class Redirection {
787 public: 787 public:
788 Redirection(void* external_function, ExternalReference::Type type) 788 Redirection(Isolate* isolate, void* external_function,
789 ExternalReference::Type type)
789 : external_function_(external_function), 790 : external_function_(external_function),
790 swi_instruction_(al | (0xf*B24) | kCallRtRedirected), 791 swi_instruction_(al | (0xf * B24) | kCallRtRedirected),
791 type_(type), 792 type_(type),
792 next_(NULL) { 793 next_(NULL) {
793 Isolate* isolate = Isolate::Current();
794 next_ = isolate->simulator_redirection(); 794 next_ = isolate->simulator_redirection();
795 Simulator::current(isolate)-> 795 Simulator::current(isolate)->
796 FlushICache(isolate->simulator_i_cache(), 796 FlushICache(isolate->simulator_i_cache(),
797 reinterpret_cast<void*>(&swi_instruction_), 797 reinterpret_cast<void*>(&swi_instruction_),
798 Instruction::kInstrSize); 798 Instruction::kInstrSize);
799 isolate->set_simulator_redirection(this); 799 isolate->set_simulator_redirection(this);
800 } 800 }
801 801
802 void* address_of_swi_instruction() { 802 void* address_of_swi_instruction() {
803 return reinterpret_cast<void*>(&swi_instruction_); 803 return reinterpret_cast<void*>(&swi_instruction_);
804 } 804 }
805 805
806 void* external_function() { return external_function_; } 806 void* external_function() { return external_function_; }
807 ExternalReference::Type type() { return type_; } 807 ExternalReference::Type type() { return type_; }
808 808
809 static Redirection* Get(void* external_function, 809 static Redirection* Get(Isolate* isolate, void* external_function,
810 ExternalReference::Type type) { 810 ExternalReference::Type type) {
811 Isolate* isolate = Isolate::Current();
812 Redirection* current = isolate->simulator_redirection(); 811 Redirection* current = isolate->simulator_redirection();
813 for (; current != NULL; current = current->next_) { 812 for (; current != NULL; current = current->next_) {
814 if (current->external_function_ == external_function) { 813 if (current->external_function_ == external_function) {
815 DCHECK_EQ(current->type(), type); 814 DCHECK_EQ(current->type(), type);
816 return current; 815 return current;
817 } 816 }
818 } 817 }
819 return new Redirection(external_function, type); 818 return new Redirection(isolate, external_function, type);
820 } 819 }
821 820
822 static Redirection* FromSwiInstruction(Instruction* swi_instruction) { 821 static Redirection* FromSwiInstruction(Instruction* swi_instruction) {
823 char* addr_of_swi = reinterpret_cast<char*>(swi_instruction); 822 char* addr_of_swi = reinterpret_cast<char*>(swi_instruction);
824 char* addr_of_redirection = 823 char* addr_of_redirection =
825 addr_of_swi - offsetof(Redirection, swi_instruction_); 824 addr_of_swi - offsetof(Redirection, swi_instruction_);
826 return reinterpret_cast<Redirection*>(addr_of_redirection); 825 return reinterpret_cast<Redirection*>(addr_of_redirection);
827 } 826 }
828 827
829 static void* ReverseRedirection(int32_t reg) { 828 static void* ReverseRedirection(int32_t reg) {
(...skipping 24 matching lines...) Expand all
854 if (i_cache != nullptr) { 853 if (i_cache != nullptr) {
855 for (HashMap::Entry* entry = i_cache->Start(); entry != nullptr; 854 for (HashMap::Entry* entry = i_cache->Start(); entry != nullptr;
856 entry = i_cache->Next(entry)) { 855 entry = i_cache->Next(entry)) {
857 delete static_cast<CachePage*>(entry->value); 856 delete static_cast<CachePage*>(entry->value);
858 } 857 }
859 delete i_cache; 858 delete i_cache;
860 } 859 }
861 } 860 }
862 861
863 862
864 void* Simulator::RedirectExternalReference(void* external_function, 863 void* Simulator::RedirectExternalReference(Isolate* isolate,
864 void* external_function,
865 ExternalReference::Type type) { 865 ExternalReference::Type type) {
866 Redirection* redirection = Redirection::Get(external_function, type); 866 Redirection* redirection = Redirection::Get(isolate, external_function, type);
867 return redirection->address_of_swi_instruction(); 867 return redirection->address_of_swi_instruction();
868 } 868 }
869 869
870 870
871 // Get the active Simulator for the current thread. 871 // Get the active Simulator for the current thread.
872 Simulator* Simulator::current(Isolate* isolate) { 872 Simulator* Simulator::current(Isolate* isolate) {
873 v8::internal::Isolate::PerIsolateThreadData* isolate_data = 873 v8::internal::Isolate::PerIsolateThreadData* isolate_data =
874 isolate->FindOrAllocatePerThreadDataForThisThread(); 874 isolate->FindOrAllocatePerThreadDataForThisThread();
875 DCHECK(isolate_data != NULL); 875 DCHECK(isolate_data != NULL);
876 876
(...skipping 3281 matching lines...) Expand 10 before | Expand all | Expand 10 after
4158 set_register(sp, current_sp + sizeof(uintptr_t)); 4158 set_register(sp, current_sp + sizeof(uintptr_t));
4159 return address; 4159 return address;
4160 } 4160 }
4161 4161
4162 } // namespace internal 4162 } // namespace internal
4163 } // namespace v8 4163 } // namespace v8
4164 4164
4165 #endif // USE_SIMULATOR 4165 #endif // USE_SIMULATOR
4166 4166
4167 #endif // V8_TARGET_ARCH_ARM 4167 #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