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

Side by Side Diff: src/arm/simulator-arm.cc

Issue 6960009: Version 3.3.5 (Closed) Base URL: https://v8.googlecode.com/svn/trunk
Patch Set: Created 9 years, 7 months 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 | Annotate | Revision Log
« no previous file with comments | « src/arm/simulator-arm.h ('k') | src/arm/stub-cache-arm.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 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
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
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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
1011 1008
1012 // For use in calls that take two double values, constructed either 1009 // For use in calls that take two double values, constructed either
1013 // from r0-r3 or d0 and d1. 1010 // from r0-r3 or d0 and d1.
1014 void Simulator::GetFpArgs(double* x, double* y) { 1011 void Simulator::GetFpArgs(double* x, double* y) {
1015 if (use_eabi_hardfloat()) { 1012 if (use_eabi_hardfloat()) {
1016 *x = vfp_register[0]; 1013 *x = vfp_register[0];
1017 *y = vfp_register[1]; 1014 *y = vfp_register[1];
1018 } else { 1015 } else {
1019 // We use a char buffer to get around the strict-aliasing rules which 1016 // We use a char buffer to get around the strict-aliasing rules which
1020 // otherwise allow the compiler to optimize away the copy. 1017 // otherwise allow the compiler to optimize away the copy.
1021 char buffer[2 * sizeof(registers_[0])]; 1018 char buffer[sizeof(*x)];
1022 // Registers 0 and 1 -> x. 1019 // Registers 0 and 1 -> x.
1023 memcpy(buffer, registers_, sizeof(buffer)); 1020 memcpy(buffer, registers_, sizeof(*x));
1024 memcpy(x, buffer, sizeof(buffer)); 1021 memcpy(x, buffer, sizeof(*x));
1025 // Registers 2 and 3 -> y. 1022 // Registers 2 and 3 -> y.
1026 memcpy(buffer, registers_ + 2, sizeof(buffer)); 1023 memcpy(buffer, registers_ + 2, sizeof(*y));
1027 memcpy(y, buffer, sizeof(buffer)); 1024 memcpy(y, buffer, sizeof(*y));
1028 } 1025 }
1029 } 1026 }
1030 1027
1031 // For use in calls that take one double value, constructed either 1028 // For use in calls that take one double value, constructed either
1032 // from r0 and r1 or d0. 1029 // from r0 and r1 or d0.
1033 void Simulator::GetFpArgs(double* x) { 1030 void Simulator::GetFpArgs(double* x) {
1034 if (use_eabi_hardfloat()) { 1031 if (use_eabi_hardfloat()) {
1035 *x = vfp_register[0]; 1032 *x = vfp_register[0];
1036 } else { 1033 } else {
1037 // We use a char buffer to get around the strict-aliasing rules which 1034 // We use a char buffer to get around the strict-aliasing rules which
1038 // otherwise allow the compiler to optimize away the copy. 1035 // otherwise allow the compiler to optimize away the copy.
1039 char buffer[2 * sizeof(registers_[0])]; 1036 char buffer[sizeof(*x)];
1040 // Registers 0 and 1 -> x. 1037 // Registers 0 and 1 -> x.
1041 memcpy(buffer, registers_, sizeof(buffer)); 1038 memcpy(buffer, registers_, sizeof(*x));
1042 memcpy(x, buffer, sizeof(buffer)); 1039 memcpy(x, buffer, sizeof(*x));
1043 } 1040 }
1044 } 1041 }
1045 1042
1046 1043
1047 // For use in calls that take two double values, constructed either 1044 // For use in calls that take one double value constructed either
1048 // from r0-r3 or d0 and d1. 1045 // from r0 and r1 or d0 and one integer value.
1049 void Simulator::GetFpArgs(double* x, int32_t* y) { 1046 void Simulator::GetFpArgs(double* x, int32_t* y) {
1050 if (use_eabi_hardfloat()) { 1047 if (use_eabi_hardfloat()) {
1051 *x = vfp_register[0]; 1048 *x = vfp_register[0];
1052 *y = registers_[1]; 1049 *y = registers_[1];
1053 } else { 1050 } else {
1054 // We use a char buffer to get around the strict-aliasing rules which 1051 // We use a char buffer to get around the strict-aliasing rules which
1055 // otherwise allow the compiler to optimize away the copy. 1052 // otherwise allow the compiler to optimize away the copy.
1056 char buffer[2 * sizeof(registers_[0])]; 1053 char buffer[sizeof(*x)];
1057 // Registers 0 and 1 -> x. 1054 // Registers 0 and 1 -> x.
1058 memcpy(buffer, registers_, sizeof(buffer)); 1055 memcpy(buffer, registers_, sizeof(*x));
1059 memcpy(x, buffer, sizeof(buffer)); 1056 memcpy(x, buffer, sizeof(*x));
1060 // Registers 2 and 3 -> y. 1057 // Register 2 -> y.
1061 memcpy(buffer, registers_ + 2, sizeof(buffer)); 1058 memcpy(buffer, registers_ + 2, sizeof(*y));
1062 memcpy(y, buffer, sizeof(buffer)); 1059 memcpy(y, buffer, sizeof(*y));
1063 } 1060 }
1064 } 1061 }
1065 1062
1066 1063
1067 // The return value is either in r0/r1 or d0. 1064 // The return value is either in r0/r1 or d0.
1068 void Simulator::SetFpResult(const double& result) { 1065 void Simulator::SetFpResult(const double& result) {
1069 if (use_eabi_hardfloat()) { 1066 if (use_eabi_hardfloat()) {
1070 char buffer[2 * sizeof(vfp_register[0])]; 1067 char buffer[2 * sizeof(vfp_register[0])];
1071 memcpy(buffer, &result, sizeof(buffer)); 1068 memcpy(buffer, &result, sizeof(buffer));
1072 // Copy result to d0. 1069 // Copy result to d0.
(...skipping 2345 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW
« no previous file with comments | « src/arm/simulator-arm.h ('k') | src/arm/stub-cache-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698