| OLD | NEW |
| 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_MIPS | 10 #if V8_TARGET_ARCH_MIPS |
| (...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 } | 582 } |
| 583 } | 583 } |
| 584 end = cur + words; | 584 end = cur + words; |
| 585 } | 585 } |
| 586 | 586 |
| 587 while (cur < end) { | 587 while (cur < end) { |
| 588 PrintF(" 0x%08x: 0x%08x %10d", | 588 PrintF(" 0x%08x: 0x%08x %10d", |
| 589 reinterpret_cast<intptr_t>(cur), *cur, *cur); | 589 reinterpret_cast<intptr_t>(cur), *cur, *cur); |
| 590 HeapObject* obj = reinterpret_cast<HeapObject*>(*cur); | 590 HeapObject* obj = reinterpret_cast<HeapObject*>(*cur); |
| 591 int value = *cur; | 591 int value = *cur; |
| 592 Heap* current_heap = v8::internal::Isolate::Current()->heap(); | 592 Heap* current_heap = sim_->isolate_->heap(); |
| 593 if (((value & 1) == 0) || current_heap->Contains(obj)) { | 593 if (((value & 1) == 0) || current_heap->Contains(obj)) { |
| 594 PrintF(" ("); | 594 PrintF(" ("); |
| 595 if ((value & 1) == 0) { | 595 if ((value & 1) == 0) { |
| 596 PrintF("smi %d", value / 2); | 596 PrintF("smi %d", value / 2); |
| 597 } else { | 597 } else { |
| 598 obj->ShortPrint(); | 598 obj->ShortPrint(); |
| 599 } | 599 } |
| 600 PrintF(")"); | 600 PrintF(")"); |
| 601 } | 601 } |
| 602 PrintF("\n"); | 602 PrintF("\n"); |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 988 | 988 |
| 989 // When the generated code calls an external reference we need to catch that in | 989 // When the generated code calls an external reference we need to catch that in |
| 990 // the simulator. The external reference will be a function compiled for the | 990 // the simulator. The external reference will be a function compiled for the |
| 991 // host architecture. We need to call that function instead of trying to | 991 // host architecture. We need to call that function instead of trying to |
| 992 // execute it with the simulator. We do that by redirecting the external | 992 // execute it with the simulator. We do that by redirecting the external |
| 993 // reference to a swi (software-interrupt) instruction that is handled by | 993 // reference to a swi (software-interrupt) instruction that is handled by |
| 994 // the simulator. We write the original destination of the jump just at a known | 994 // the simulator. We write the original destination of the jump just at a known |
| 995 // offset from the swi instruction so the simulator knows what to call. | 995 // offset from the swi instruction so the simulator knows what to call. |
| 996 class Redirection { | 996 class Redirection { |
| 997 public: | 997 public: |
| 998 Redirection(void* external_function, ExternalReference::Type type) | 998 Redirection(Isolate* isolate, void* external_function, |
| 999 ExternalReference::Type type) |
| 999 : external_function_(external_function), | 1000 : external_function_(external_function), |
| 1000 swi_instruction_(rtCallRedirInstr), | 1001 swi_instruction_(rtCallRedirInstr), |
| 1001 type_(type), | 1002 type_(type), |
| 1002 next_(NULL) { | 1003 next_(NULL) { |
| 1003 Isolate* isolate = Isolate::Current(); | |
| 1004 next_ = isolate->simulator_redirection(); | 1004 next_ = isolate->simulator_redirection(); |
| 1005 Simulator::current(isolate)-> | 1005 Simulator::current(isolate)-> |
| 1006 FlushICache(isolate->simulator_i_cache(), | 1006 FlushICache(isolate->simulator_i_cache(), |
| 1007 reinterpret_cast<void*>(&swi_instruction_), | 1007 reinterpret_cast<void*>(&swi_instruction_), |
| 1008 Instruction::kInstrSize); | 1008 Instruction::kInstrSize); |
| 1009 isolate->set_simulator_redirection(this); | 1009 isolate->set_simulator_redirection(this); |
| 1010 } | 1010 } |
| 1011 | 1011 |
| 1012 void* address_of_swi_instruction() { | 1012 void* address_of_swi_instruction() { |
| 1013 return reinterpret_cast<void*>(&swi_instruction_); | 1013 return reinterpret_cast<void*>(&swi_instruction_); |
| 1014 } | 1014 } |
| 1015 | 1015 |
| 1016 void* external_function() { return external_function_; } | 1016 void* external_function() { return external_function_; } |
| 1017 ExternalReference::Type type() { return type_; } | 1017 ExternalReference::Type type() { return type_; } |
| 1018 | 1018 |
| 1019 static Redirection* Get(void* external_function, | 1019 static Redirection* Get(Isolate* isolate, void* external_function, |
| 1020 ExternalReference::Type type) { | 1020 ExternalReference::Type type) { |
| 1021 Isolate* isolate = Isolate::Current(); | |
| 1022 Redirection* current = isolate->simulator_redirection(); | 1021 Redirection* current = isolate->simulator_redirection(); |
| 1023 for (; current != NULL; current = current->next_) { | 1022 for (; current != NULL; current = current->next_) { |
| 1024 if (current->external_function_ == external_function) return current; | 1023 if (current->external_function_ == external_function) return current; |
| 1025 } | 1024 } |
| 1026 return new Redirection(external_function, type); | 1025 return new Redirection(isolate, external_function, type); |
| 1027 } | 1026 } |
| 1028 | 1027 |
| 1029 static Redirection* FromSwiInstruction(Instruction* swi_instruction) { | 1028 static Redirection* FromSwiInstruction(Instruction* swi_instruction) { |
| 1030 char* addr_of_swi = reinterpret_cast<char*>(swi_instruction); | 1029 char* addr_of_swi = reinterpret_cast<char*>(swi_instruction); |
| 1031 char* addr_of_redirection = | 1030 char* addr_of_redirection = |
| 1032 addr_of_swi - offsetof(Redirection, swi_instruction_); | 1031 addr_of_swi - offsetof(Redirection, swi_instruction_); |
| 1033 return reinterpret_cast<Redirection*>(addr_of_redirection); | 1032 return reinterpret_cast<Redirection*>(addr_of_redirection); |
| 1034 } | 1033 } |
| 1035 | 1034 |
| 1036 static void* ReverseRedirection(int32_t reg) { | 1035 static void* ReverseRedirection(int32_t reg) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1061 if (i_cache != nullptr) { | 1060 if (i_cache != nullptr) { |
| 1062 for (HashMap::Entry* entry = i_cache->Start(); entry != nullptr; | 1061 for (HashMap::Entry* entry = i_cache->Start(); entry != nullptr; |
| 1063 entry = i_cache->Next(entry)) { | 1062 entry = i_cache->Next(entry)) { |
| 1064 delete static_cast<CachePage*>(entry->value); | 1063 delete static_cast<CachePage*>(entry->value); |
| 1065 } | 1064 } |
| 1066 delete i_cache; | 1065 delete i_cache; |
| 1067 } | 1066 } |
| 1068 } | 1067 } |
| 1069 | 1068 |
| 1070 | 1069 |
| 1071 void* Simulator::RedirectExternalReference(void* external_function, | 1070 void* Simulator::RedirectExternalReference(Isolate* isolate, |
| 1071 void* external_function, |
| 1072 ExternalReference::Type type) { | 1072 ExternalReference::Type type) { |
| 1073 Redirection* redirection = Redirection::Get(external_function, type); | 1073 Redirection* redirection = Redirection::Get(isolate, external_function, type); |
| 1074 return redirection->address_of_swi_instruction(); | 1074 return redirection->address_of_swi_instruction(); |
| 1075 } | 1075 } |
| 1076 | 1076 |
| 1077 | 1077 |
| 1078 // Get the active Simulator for the current thread. | 1078 // Get the active Simulator for the current thread. |
| 1079 Simulator* Simulator::current(Isolate* isolate) { | 1079 Simulator* Simulator::current(Isolate* isolate) { |
| 1080 v8::internal::Isolate::PerIsolateThreadData* isolate_data = | 1080 v8::internal::Isolate::PerIsolateThreadData* isolate_data = |
| 1081 isolate->FindOrAllocatePerThreadDataForThisThread(); | 1081 isolate->FindOrAllocatePerThreadDataForThisThread(); |
| 1082 DCHECK(isolate_data != NULL); | 1082 DCHECK(isolate_data != NULL); |
| 1083 DCHECK(isolate_data != NULL); | 1083 DCHECK(isolate_data != NULL); |
| (...skipping 3347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4431 | 4431 |
| 4432 | 4432 |
| 4433 #undef UNSUPPORTED | 4433 #undef UNSUPPORTED |
| 4434 | 4434 |
| 4435 } // namespace internal | 4435 } // namespace internal |
| 4436 } // namespace v8 | 4436 } // namespace v8 |
| 4437 | 4437 |
| 4438 #endif // USE_SIMULATOR | 4438 #endif // USE_SIMULATOR |
| 4439 | 4439 |
| 4440 #endif // V8_TARGET_ARCH_MIPS | 4440 #endif // V8_TARGET_ARCH_MIPS |
| OLD | NEW |