OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
712 cache_page->CachedData(offset), | 712 cache_page->CachedData(offset), |
713 Instruction::kInstrSize) == 0); | 713 Instruction::kInstrSize) == 0); |
714 } else { | 714 } else { |
715 // Cache miss. Load memory into the cache. | 715 // Cache miss. Load memory into the cache. |
716 memcpy(cached_line, line, CachePage::kLineLength); | 716 memcpy(cached_line, line, CachePage::kLineLength); |
717 *cache_valid_byte = CachePage::LINE_VALID; | 717 *cache_valid_byte = CachePage::LINE_VALID; |
718 } | 718 } |
719 } | 719 } |
720 | 720 |
721 | 721 |
722 void Simulator::Initialize() { | 722 void Simulator::Initialize(Isolate* isolate) { |
723 if (Isolate::Current()->simulator_initialized()) return; | 723 if (isolate->simulator_initialized()) return; |
724 Isolate::Current()->set_simulator_initialized(true); | 724 isolate->set_simulator_initialized(true); |
725 ::v8::internal::ExternalReference::set_redirector(&RedirectExternalReference); | 725 ::v8::internal::ExternalReference::set_redirector(isolate, |
| 726 &RedirectExternalReference); |
726 } | 727 } |
727 | 728 |
728 | 729 |
729 Simulator::Simulator() : isolate_(Isolate::Current()) { | 730 Simulator::Simulator(Isolate* isolate) : isolate_(isolate) { |
730 i_cache_ = isolate_->simulator_i_cache(); | 731 i_cache_ = isolate_->simulator_i_cache(); |
731 if (i_cache_ == NULL) { | 732 if (i_cache_ == NULL) { |
732 i_cache_ = new v8::internal::HashMap(&ICacheMatch); | 733 i_cache_ = new v8::internal::HashMap(&ICacheMatch); |
733 isolate_->set_simulator_i_cache(i_cache_); | 734 isolate_->set_simulator_i_cache(i_cache_); |
734 } | 735 } |
735 Initialize(); | 736 Initialize(isolate); |
736 // Setup simulator support first. Some of this information is needed to | 737 // Setup simulator support first. Some of this information is needed to |
737 // setup the architecture state. | 738 // setup the architecture state. |
738 size_t stack_size = 1 * 1024*1024; // allocate 1MB for stack | 739 size_t stack_size = 1 * 1024*1024; // allocate 1MB for stack |
739 stack_ = reinterpret_cast<char*>(malloc(stack_size)); | 740 stack_ = reinterpret_cast<char*>(malloc(stack_size)); |
740 pc_modified_ = false; | 741 pc_modified_ = false; |
741 icount_ = 0; | 742 icount_ = 0; |
742 break_pc_ = NULL; | 743 break_pc_ = NULL; |
743 break_instr_ = 0; | 744 break_instr_ = 0; |
744 | 745 |
745 // Setup architecture state. | 746 // Setup architecture state. |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
841 void* Simulator::RedirectExternalReference(void* external_function, | 842 void* Simulator::RedirectExternalReference(void* external_function, |
842 ExternalReference::Type type) { | 843 ExternalReference::Type type) { |
843 Redirection* redirection = Redirection::Get(external_function, type); | 844 Redirection* redirection = Redirection::Get(external_function, type); |
844 return redirection->address_of_swi_instruction(); | 845 return redirection->address_of_swi_instruction(); |
845 } | 846 } |
846 | 847 |
847 | 848 |
848 // Get the active Simulator for the current thread. | 849 // Get the active Simulator for the current thread. |
849 Simulator* Simulator::current(Isolate* isolate) { | 850 Simulator* Simulator::current(Isolate* isolate) { |
850 v8::internal::Isolate::PerIsolateThreadData* isolate_data = | 851 v8::internal::Isolate::PerIsolateThreadData* isolate_data = |
851 Isolate::CurrentPerIsolateThreadData(); | 852 isolate->FindOrAllocatePerThreadDataForThisThread(); |
852 if (isolate_data == NULL) { | |
853 Isolate::EnterDefaultIsolate(); | |
854 isolate_data = Isolate::CurrentPerIsolateThreadData(); | |
855 } | |
856 ASSERT(isolate_data != NULL); | 853 ASSERT(isolate_data != NULL); |
857 | 854 |
858 Simulator* sim = isolate_data->simulator(); | 855 Simulator* sim = isolate_data->simulator(); |
859 if (sim == NULL) { | 856 if (sim == NULL) { |
860 // TODO(146): delete the simulator object when a thread/isolate goes away. | 857 // TODO(146): delete the simulator object when a thread/isolate goes away. |
861 sim = new Simulator(); | 858 sim = new Simulator(isolate); |
862 isolate_data->set_simulator(sim); | 859 isolate_data->set_simulator(sim); |
863 } | 860 } |
864 return sim; | 861 return sim; |
865 } | 862 } |
866 | 863 |
867 | 864 |
868 // Sets the register in the architecture state. It will also deal with updating | 865 // Sets the register in the architecture state. It will also deal with updating |
869 // Simulator internal state for special registers such as PC. | 866 // Simulator internal state for special registers such as PC. |
870 void Simulator::set_register(int reg, int32_t value) { | 867 void Simulator::set_register(int reg, int32_t value) { |
871 ASSERT((reg >= 0) && (reg < num_registers)); | 868 ASSERT((reg >= 0) && (reg < num_registers)); |
(...skipping 2546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3418 uintptr_t address = *stack_slot; | 3415 uintptr_t address = *stack_slot; |
3419 set_register(sp, current_sp + sizeof(uintptr_t)); | 3416 set_register(sp, current_sp + sizeof(uintptr_t)); |
3420 return address; | 3417 return address; |
3421 } | 3418 } |
3422 | 3419 |
3423 } } // namespace v8::internal | 3420 } } // namespace v8::internal |
3424 | 3421 |
3425 #endif // USE_SIMULATOR | 3422 #endif // USE_SIMULATOR |
3426 | 3423 |
3427 #endif // V8_TARGET_ARCH_ARM | 3424 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |