OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
731 cache_page->CachedData(offset), | 731 cache_page->CachedData(offset), |
732 Instruction::kInstrSize) == 0); | 732 Instruction::kInstrSize) == 0); |
733 } else { | 733 } else { |
734 // Cache miss. Load memory into the cache. | 734 // Cache miss. Load memory into the cache. |
735 memcpy(cached_line, line, CachePage::kLineLength); | 735 memcpy(cached_line, line, CachePage::kLineLength); |
736 *cache_valid_byte = CachePage::LINE_VALID; | 736 *cache_valid_byte = CachePage::LINE_VALID; |
737 } | 737 } |
738 } | 738 } |
739 | 739 |
740 | 740 |
741 void Simulator::Initialize() { | 741 void Simulator::Initialize(Isolate* isolate) { |
742 if (Isolate::Current()->simulator_initialized()) return; | 742 if (isolate->simulator_initialized()) return; |
743 Isolate::Current()->set_simulator_initialized(true); | 743 isolate->set_simulator_initialized(true); |
744 ::v8::internal::ExternalReference::set_redirector(&RedirectExternalReference); | 744 ::v8::internal::ExternalReference::set_redirector(isolate, |
| 745 &RedirectExternalReference); |
745 } | 746 } |
746 | 747 |
747 | 748 |
748 Simulator::Simulator() : isolate_(Isolate::Current()) { | 749 Simulator::Simulator(Isolate* isolate) : isolate_(isolate) { |
749 i_cache_ = isolate_->simulator_i_cache(); | 750 i_cache_ = isolate_->simulator_i_cache(); |
750 if (i_cache_ == NULL) { | 751 if (i_cache_ == NULL) { |
751 i_cache_ = new v8::internal::HashMap(&ICacheMatch); | 752 i_cache_ = new v8::internal::HashMap(&ICacheMatch); |
752 isolate_->set_simulator_i_cache(i_cache_); | 753 isolate_->set_simulator_i_cache(i_cache_); |
753 } | 754 } |
754 Initialize(); | 755 Initialize(isolate); |
755 // Setup simulator support first. Some of this information is needed to | 756 // Setup simulator support first. Some of this information is needed to |
756 // setup the architecture state. | 757 // setup the architecture state. |
757 stack_size_ = 1 * 1024*1024; // allocate 1MB for stack | 758 stack_size_ = 1 * 1024*1024; // allocate 1MB for stack |
758 stack_ = reinterpret_cast<char*>(malloc(stack_size_)); | 759 stack_ = reinterpret_cast<char*>(malloc(stack_size_)); |
759 pc_modified_ = false; | 760 pc_modified_ = false; |
760 icount_ = 0; | 761 icount_ = 0; |
761 break_count_ = 0; | 762 break_count_ = 0; |
762 break_pc_ = NULL; | 763 break_pc_ = NULL; |
763 break_instr_ = 0; | 764 break_instr_ = 0; |
764 | 765 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
845 void* Simulator::RedirectExternalReference(void* external_function, | 846 void* Simulator::RedirectExternalReference(void* external_function, |
846 ExternalReference::Type type) { | 847 ExternalReference::Type type) { |
847 Redirection* redirection = Redirection::Get(external_function, type); | 848 Redirection* redirection = Redirection::Get(external_function, type); |
848 return redirection->address_of_swi_instruction(); | 849 return redirection->address_of_swi_instruction(); |
849 } | 850 } |
850 | 851 |
851 | 852 |
852 // Get the active Simulator for the current thread. | 853 // Get the active Simulator for the current thread. |
853 Simulator* Simulator::current(Isolate* isolate) { | 854 Simulator* Simulator::current(Isolate* isolate) { |
854 v8::internal::Isolate::PerIsolateThreadData* isolate_data = | 855 v8::internal::Isolate::PerIsolateThreadData* isolate_data = |
855 Isolate::CurrentPerIsolateThreadData(); | 856 isolate->FindOrAllocatePerThreadDataForThisThread(); |
856 if (isolate_data == NULL) { | 857 ASSERT(isolate_data != NULL); |
857 Isolate::EnterDefaultIsolate(); | |
858 isolate_data = Isolate::CurrentPerIsolateThreadData(); | |
859 } | |
860 ASSERT(isolate_data != NULL); | 858 ASSERT(isolate_data != NULL); |
861 | 859 |
862 Simulator* sim = isolate_data->simulator(); | 860 Simulator* sim = isolate_data->simulator(); |
863 if (sim == NULL) { | 861 if (sim == NULL) { |
864 // TODO(146): delete the simulator object when a thread/isolate goes away. | 862 // TODO(146): delete the simulator object when a thread/isolate goes away. |
865 sim = new Simulator(); | 863 sim = new Simulator(isolate); |
866 isolate_data->set_simulator(sim); | 864 isolate_data->set_simulator(sim); |
867 } | 865 } |
868 return sim; | 866 return sim; |
869 } | 867 } |
870 | 868 |
871 | 869 |
872 // Sets the register in the architecture state. It will also deal with updating | 870 // Sets the register in the architecture state. It will also deal with updating |
873 // Simulator internal state for special registers such as PC. | 871 // Simulator internal state for special registers such as PC. |
874 void Simulator::set_register(int reg, int32_t value) { | 872 void Simulator::set_register(int reg, int32_t value) { |
875 ASSERT((reg >= 0) && (reg < kNumSimuRegisters)); | 873 ASSERT((reg >= 0) && (reg < kNumSimuRegisters)); |
(...skipping 1553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2429 } | 2427 } |
2430 | 2428 |
2431 | 2429 |
2432 #undef UNSUPPORTED | 2430 #undef UNSUPPORTED |
2433 | 2431 |
2434 } } // namespace v8::internal | 2432 } } // namespace v8::internal |
2435 | 2433 |
2436 #endif // USE_SIMULATOR | 2434 #endif // USE_SIMULATOR |
2437 | 2435 |
2438 #endif // V8_TARGET_ARCH_MIPS | 2436 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |