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

Side by Side Diff: src/mips64/simulator-mips64.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/mips64/simulator-mips64.h ('k') | src/ppc/simulator-ppc.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 <limits.h> 5 #include <limits.h>
6 #include <stdarg.h> 6 #include <stdarg.h>
7 #include <stdlib.h> 7 #include <stdlib.h>
8 #include <cmath> 8 #include <cmath>
9 9
10 #if V8_TARGET_ARCH_MIPS64 10 #if V8_TARGET_ARCH_MIPS64
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 words = 10; 512 words = 10;
513 } 513 }
514 } 514 }
515 end = cur + words; 515 end = cur + words;
516 516
517 while (cur < end) { 517 while (cur < end) {
518 PrintF(" 0x%012lx: 0x%016lx %14ld", 518 PrintF(" 0x%012lx: 0x%016lx %14ld",
519 reinterpret_cast<intptr_t>(cur), *cur, *cur); 519 reinterpret_cast<intptr_t>(cur), *cur, *cur);
520 HeapObject* obj = reinterpret_cast<HeapObject*>(*cur); 520 HeapObject* obj = reinterpret_cast<HeapObject*>(*cur);
521 int64_t value = *cur; 521 int64_t value = *cur;
522 Heap* current_heap = v8::internal::Isolate::Current()->heap(); 522 Heap* current_heap = sim_->isolate_->heap();
523 if (((value & 1) == 0) || current_heap->Contains(obj)) { 523 if (((value & 1) == 0) || current_heap->Contains(obj)) {
524 PrintF(" ("); 524 PrintF(" (");
525 if ((value & 1) == 0) { 525 if ((value & 1) == 0) {
526 PrintF("smi %d", static_cast<int>(value >> 32)); 526 PrintF("smi %d", static_cast<int>(value >> 32));
527 } else { 527 } else {
528 obj->ShortPrint(); 528 obj->ShortPrint();
529 } 529 }
530 PrintF(")"); 530 PrintF(")");
531 } 531 }
532 PrintF("\n"); 532 PrintF("\n");
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 919
920 // When the generated code calls an external reference we need to catch that in 920 // When the generated code calls an external reference we need to catch that in
921 // the simulator. The external reference will be a function compiled for the 921 // the simulator. The external reference will be a function compiled for the
922 // host architecture. We need to call that function instead of trying to 922 // host architecture. We need to call that function instead of trying to
923 // execute it with the simulator. We do that by redirecting the external 923 // execute it with the simulator. We do that by redirecting the external
924 // reference to a swi (software-interrupt) instruction that is handled by 924 // reference to a swi (software-interrupt) instruction that is handled by
925 // the simulator. We write the original destination of the jump just at a known 925 // the simulator. We write the original destination of the jump just at a known
926 // offset from the swi instruction so the simulator knows what to call. 926 // offset from the swi instruction so the simulator knows what to call.
927 class Redirection { 927 class Redirection {
928 public: 928 public:
929 Redirection(void* external_function, ExternalReference::Type type) 929 Redirection(Isolate* isolate, void* external_function,
930 ExternalReference::Type type)
930 : external_function_(external_function), 931 : external_function_(external_function),
931 swi_instruction_(rtCallRedirInstr), 932 swi_instruction_(rtCallRedirInstr),
932 type_(type), 933 type_(type),
933 next_(NULL) { 934 next_(NULL) {
934 Isolate* isolate = Isolate::Current();
935 next_ = isolate->simulator_redirection(); 935 next_ = isolate->simulator_redirection();
936 Simulator::current(isolate)-> 936 Simulator::current(isolate)->
937 FlushICache(isolate->simulator_i_cache(), 937 FlushICache(isolate->simulator_i_cache(),
938 reinterpret_cast<void*>(&swi_instruction_), 938 reinterpret_cast<void*>(&swi_instruction_),
939 Instruction::kInstrSize); 939 Instruction::kInstrSize);
940 isolate->set_simulator_redirection(this); 940 isolate->set_simulator_redirection(this);
941 } 941 }
942 942
943 void* address_of_swi_instruction() { 943 void* address_of_swi_instruction() {
944 return reinterpret_cast<void*>(&swi_instruction_); 944 return reinterpret_cast<void*>(&swi_instruction_);
945 } 945 }
946 946
947 void* external_function() { return external_function_; } 947 void* external_function() { return external_function_; }
948 ExternalReference::Type type() { return type_; } 948 ExternalReference::Type type() { return type_; }
949 949
950 static Redirection* Get(void* external_function, 950 static Redirection* Get(Isolate* isolate, void* external_function,
951 ExternalReference::Type type) { 951 ExternalReference::Type type) {
952 Isolate* isolate = Isolate::Current();
953 Redirection* current = isolate->simulator_redirection(); 952 Redirection* current = isolate->simulator_redirection();
954 for (; current != NULL; current = current->next_) { 953 for (; current != NULL; current = current->next_) {
955 if (current->external_function_ == external_function) return current; 954 if (current->external_function_ == external_function) return current;
956 } 955 }
957 return new Redirection(external_function, type); 956 return new Redirection(isolate, external_function, type);
958 } 957 }
959 958
960 static Redirection* FromSwiInstruction(Instruction* swi_instruction) { 959 static Redirection* FromSwiInstruction(Instruction* swi_instruction) {
961 char* addr_of_swi = reinterpret_cast<char*>(swi_instruction); 960 char* addr_of_swi = reinterpret_cast<char*>(swi_instruction);
962 char* addr_of_redirection = 961 char* addr_of_redirection =
963 addr_of_swi - offsetof(Redirection, swi_instruction_); 962 addr_of_swi - offsetof(Redirection, swi_instruction_);
964 return reinterpret_cast<Redirection*>(addr_of_redirection); 963 return reinterpret_cast<Redirection*>(addr_of_redirection);
965 } 964 }
966 965
967 static void* ReverseRedirection(int64_t reg) { 966 static void* ReverseRedirection(int64_t reg) {
(...skipping 24 matching lines...) Expand all
992 if (i_cache != nullptr) { 991 if (i_cache != nullptr) {
993 for (HashMap::Entry* entry = i_cache->Start(); entry != nullptr; 992 for (HashMap::Entry* entry = i_cache->Start(); entry != nullptr;
994 entry = i_cache->Next(entry)) { 993 entry = i_cache->Next(entry)) {
995 delete static_cast<CachePage*>(entry->value); 994 delete static_cast<CachePage*>(entry->value);
996 } 995 }
997 delete i_cache; 996 delete i_cache;
998 } 997 }
999 } 998 }
1000 999
1001 1000
1002 void* Simulator::RedirectExternalReference(void* external_function, 1001 void* Simulator::RedirectExternalReference(Isolate* isolate,
1002 void* external_function,
1003 ExternalReference::Type type) { 1003 ExternalReference::Type type) {
1004 Redirection* redirection = Redirection::Get(external_function, type); 1004 Redirection* redirection = Redirection::Get(isolate, external_function, type);
1005 return redirection->address_of_swi_instruction(); 1005 return redirection->address_of_swi_instruction();
1006 } 1006 }
1007 1007
1008 1008
1009 // Get the active Simulator for the current thread. 1009 // Get the active Simulator for the current thread.
1010 Simulator* Simulator::current(Isolate* isolate) { 1010 Simulator* Simulator::current(Isolate* isolate) {
1011 v8::internal::Isolate::PerIsolateThreadData* isolate_data = 1011 v8::internal::Isolate::PerIsolateThreadData* isolate_data =
1012 isolate->FindOrAllocatePerThreadDataForThisThread(); 1012 isolate->FindOrAllocatePerThreadDataForThisThread();
1013 DCHECK(isolate_data != NULL); 1013 DCHECK(isolate_data != NULL);
1014 DCHECK(isolate_data != NULL); 1014 DCHECK(isolate_data != NULL);
(...skipping 3553 matching lines...) Expand 10 before | Expand all | Expand 10 after
4568 } 4568 }
4569 4569
4570 4570
4571 #undef UNSUPPORTED 4571 #undef UNSUPPORTED
4572 } // namespace internal 4572 } // namespace internal
4573 } // namespace v8 4573 } // namespace v8
4574 4574
4575 #endif // USE_SIMULATOR 4575 #endif // USE_SIMULATOR
4576 4576
4577 #endif // V8_TARGET_ARCH_MIPS64 4577 #endif // V8_TARGET_ARCH_MIPS64
OLDNEW
« no previous file with comments | « src/mips64/simulator-mips64.h ('k') | src/ppc/simulator-ppc.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698