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

Side by Side Diff: src/ppc/simulator-ppc.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/ppc/simulator-ppc.h ('k') | src/regexp/regexp-macro-assembler.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 #if V8_TARGET_ARCH_PPC 9 #if V8_TARGET_ARCH_PPC
10 10
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 words = 10; 438 words = 10;
439 } 439 }
440 } 440 }
441 end = cur + words; 441 end = cur + words;
442 442
443 while (cur < end) { 443 while (cur < end) {
444 PrintF(" 0x%08" V8PRIxPTR ": 0x%08" V8PRIxPTR " %10" V8PRIdPTR, 444 PrintF(" 0x%08" V8PRIxPTR ": 0x%08" V8PRIxPTR " %10" V8PRIdPTR,
445 reinterpret_cast<intptr_t>(cur), *cur, *cur); 445 reinterpret_cast<intptr_t>(cur), *cur, *cur);
446 HeapObject* obj = reinterpret_cast<HeapObject*>(*cur); 446 HeapObject* obj = reinterpret_cast<HeapObject*>(*cur);
447 intptr_t value = *cur; 447 intptr_t value = *cur;
448 Heap* current_heap = v8::internal::Isolate::Current()->heap(); 448 Heap* current_heap = sim_->isolate_->heap();
449 if (((value & 1) == 0) || current_heap->Contains(obj)) { 449 if (((value & 1) == 0) || current_heap->Contains(obj)) {
450 PrintF(" ("); 450 PrintF(" (");
451 if ((value & 1) == 0) { 451 if ((value & 1) == 0) {
452 PrintF("smi %d", PlatformSmiTagging::SmiToInt(obj)); 452 PrintF("smi %d", PlatformSmiTagging::SmiToInt(obj));
453 } else { 453 } else {
454 obj->ShortPrint(); 454 obj->ShortPrint();
455 } 455 }
456 PrintF(")"); 456 PrintF(")");
457 } 457 }
458 PrintF("\n"); 458 PrintF("\n");
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 837
838 // When the generated code calls an external reference we need to catch that in 838 // When the generated code calls an external reference we need to catch that in
839 // the simulator. The external reference will be a function compiled for the 839 // the simulator. The external reference will be a function compiled for the
840 // host architecture. We need to call that function instead of trying to 840 // host architecture. We need to call that function instead of trying to
841 // execute it with the simulator. We do that by redirecting the external 841 // execute it with the simulator. We do that by redirecting the external
842 // reference to a svc (Supervisor Call) instruction that is handled by 842 // reference to a svc (Supervisor Call) instruction that is handled by
843 // the simulator. We write the original destination of the jump just at a known 843 // the simulator. We write the original destination of the jump just at a known
844 // offset from the svc instruction so the simulator knows what to call. 844 // offset from the svc instruction so the simulator knows what to call.
845 class Redirection { 845 class Redirection {
846 public: 846 public:
847 Redirection(void* external_function, ExternalReference::Type type) 847 Redirection(Isolate* isolate, void* external_function,
848 ExternalReference::Type type)
848 : external_function_(external_function), 849 : external_function_(external_function),
849 swi_instruction_(rtCallRedirInstr | kCallRtRedirected), 850 swi_instruction_(rtCallRedirInstr | kCallRtRedirected),
850 type_(type), 851 type_(type),
851 next_(NULL) { 852 next_(NULL) {
852 Isolate* isolate = Isolate::Current();
853 next_ = isolate->simulator_redirection(); 853 next_ = isolate->simulator_redirection();
854 Simulator::current(isolate)->FlushICache( 854 Simulator::current(isolate)->FlushICache(
855 isolate->simulator_i_cache(), 855 isolate->simulator_i_cache(),
856 reinterpret_cast<void*>(&swi_instruction_), Instruction::kInstrSize); 856 reinterpret_cast<void*>(&swi_instruction_), Instruction::kInstrSize);
857 isolate->set_simulator_redirection(this); 857 isolate->set_simulator_redirection(this);
858 } 858 }
859 859
860 void* address_of_swi_instruction() { 860 void* address_of_swi_instruction() {
861 return reinterpret_cast<void*>(&swi_instruction_); 861 return reinterpret_cast<void*>(&swi_instruction_);
862 } 862 }
863 863
864 void* external_function() { return external_function_; } 864 void* external_function() { return external_function_; }
865 ExternalReference::Type type() { return type_; } 865 ExternalReference::Type type() { return type_; }
866 866
867 static Redirection* Get(void* external_function, 867 static Redirection* Get(Isolate* isolate, void* external_function,
868 ExternalReference::Type type) { 868 ExternalReference::Type type) {
869 Isolate* isolate = Isolate::Current();
870 Redirection* current = isolate->simulator_redirection(); 869 Redirection* current = isolate->simulator_redirection();
871 for (; current != NULL; current = current->next_) { 870 for (; current != NULL; current = current->next_) {
872 if (current->external_function_ == external_function) { 871 if (current->external_function_ == external_function) {
873 DCHECK_EQ(current->type(), type); 872 DCHECK_EQ(current->type(), type);
874 return current; 873 return current;
875 } 874 }
876 } 875 }
877 return new Redirection(external_function, type); 876 return new Redirection(isolate, external_function, type);
878 } 877 }
879 878
880 static Redirection* FromSwiInstruction(Instruction* swi_instruction) { 879 static Redirection* FromSwiInstruction(Instruction* swi_instruction) {
881 char* addr_of_swi = reinterpret_cast<char*>(swi_instruction); 880 char* addr_of_swi = reinterpret_cast<char*>(swi_instruction);
882 char* addr_of_redirection = 881 char* addr_of_redirection =
883 addr_of_swi - offsetof(Redirection, swi_instruction_); 882 addr_of_swi - offsetof(Redirection, swi_instruction_);
884 return reinterpret_cast<Redirection*>(addr_of_redirection); 883 return reinterpret_cast<Redirection*>(addr_of_redirection);
885 } 884 }
886 885
887 static void* ReverseRedirection(intptr_t reg) { 886 static void* ReverseRedirection(intptr_t reg) {
(...skipping 24 matching lines...) Expand all
912 if (i_cache != nullptr) { 911 if (i_cache != nullptr) {
913 for (HashMap::Entry* entry = i_cache->Start(); entry != nullptr; 912 for (HashMap::Entry* entry = i_cache->Start(); entry != nullptr;
914 entry = i_cache->Next(entry)) { 913 entry = i_cache->Next(entry)) {
915 delete static_cast<CachePage*>(entry->value); 914 delete static_cast<CachePage*>(entry->value);
916 } 915 }
917 delete i_cache; 916 delete i_cache;
918 } 917 }
919 } 918 }
920 919
921 920
922 void* Simulator::RedirectExternalReference(void* external_function, 921 void* Simulator::RedirectExternalReference(Isolate* isolate,
922 void* external_function,
923 ExternalReference::Type type) { 923 ExternalReference::Type type) {
924 Redirection* redirection = Redirection::Get(external_function, type); 924 Redirection* redirection = Redirection::Get(isolate, external_function, type);
925 return redirection->address_of_swi_instruction(); 925 return redirection->address_of_swi_instruction();
926 } 926 }
927 927
928 928
929 // Get the active Simulator for the current thread. 929 // Get the active Simulator for the current thread.
930 Simulator* Simulator::current(Isolate* isolate) { 930 Simulator* Simulator::current(Isolate* isolate) {
931 v8::internal::Isolate::PerIsolateThreadData* isolate_data = 931 v8::internal::Isolate::PerIsolateThreadData* isolate_data =
932 isolate->FindOrAllocatePerThreadDataForThisThread(); 932 isolate->FindOrAllocatePerThreadDataForThisThread();
933 DCHECK(isolate_data != NULL); 933 DCHECK(isolate_data != NULL);
934 934
(...skipping 3022 matching lines...) Expand 10 before | Expand all | Expand 10 after
3957 uintptr_t* stack_slot = reinterpret_cast<uintptr_t*>(current_sp); 3957 uintptr_t* stack_slot = reinterpret_cast<uintptr_t*>(current_sp);
3958 uintptr_t address = *stack_slot; 3958 uintptr_t address = *stack_slot;
3959 set_register(sp, current_sp + sizeof(uintptr_t)); 3959 set_register(sp, current_sp + sizeof(uintptr_t));
3960 return address; 3960 return address;
3961 } 3961 }
3962 } // namespace internal 3962 } // namespace internal
3963 } // namespace v8 3963 } // namespace v8
3964 3964
3965 #endif // USE_SIMULATOR 3965 #endif // USE_SIMULATOR
3966 #endif // V8_TARGET_ARCH_PPC 3966 #endif // V8_TARGET_ARCH_PPC
OLDNEW
« no previous file with comments | « src/ppc/simulator-ppc.h ('k') | src/regexp/regexp-macro-assembler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698