OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 | 159 |
160 | 160 |
161 // Represent a register (r0-r31, v0-v31). | 161 // Represent a register (r0-r31, v0-v31). |
162 template<int kSizeInBytes> | 162 template<int kSizeInBytes> |
163 class SimRegisterBase { | 163 class SimRegisterBase { |
164 public: | 164 public: |
165 template<typename T> | 165 template<typename T> |
166 void Set(T new_value, unsigned size = sizeof(T)) { | 166 void Set(T new_value, unsigned size = sizeof(T)) { |
167 ASSERT(size <= kSizeInBytes); | 167 ASSERT(size <= kSizeInBytes); |
168 ASSERT(size <= sizeof(new_value)); | 168 ASSERT(size <= sizeof(new_value)); |
169 STATIC_ASSERT(kXRegSize == kDRegSize); | |
170 STATIC_ASSERT(kWRegSize == kSRegSize); | |
171 // All AArch64 registers are zero-extending; Writing a W register clears the | 169 // All AArch64 registers are zero-extending; Writing a W register clears the |
172 // top bits of the corresponding X register. | 170 // top bits of the corresponding X register. |
173 if (size == kXRegSize) { | 171 memset(value_, 0, kSizeInBytes); |
174 memcpy(value_, &new_value, kXRegSize); | 172 memcpy(value_, &new_value, size); |
175 } else if (size == kWRegSize) { | |
176 memset(value_, 0, kSizeInBytes); | |
177 memcpy(value_, &new_value, kWRegSize); | |
178 } else { | |
179 UNREACHABLE(); | |
180 } | |
181 } | 173 } |
182 | 174 |
183 // Copy 'size' bytes of the register to the result, and zero-extend to fill | 175 // Copy 'size' bytes of the register to the result, and zero-extend to fill |
184 // the result. | 176 // the result. |
185 template<typename T> | 177 template<typename T> |
186 T Get(unsigned size = sizeof(T)) const { | 178 T Get(unsigned size = sizeof(T)) const { |
187 ASSERT(size <= kSizeInBytes); | 179 ASSERT(size <= kSizeInBytes); |
188 T result; | 180 T result; |
189 if (size == kXRegSize) { | 181 memset(&result, 0, sizeof(result)); |
190 memcpy(&result, value_, kXRegSize); | 182 memcpy(&result, value_, size); |
191 } else if (size == kWRegSize) { | |
192 memset(&result, 0, sizeof(result)); | |
193 memcpy(&result, value_, kWRegSize); | |
194 } else { | |
195 UNREACHABLE(); | |
196 } | |
197 return result; | 183 return result; |
198 } | 184 } |
199 | 185 |
200 protected: | 186 protected: |
201 uint8_t value_[kSizeInBytes]; | 187 uint8_t value_[kSizeInBytes]; |
202 }; | 188 }; |
203 typedef SimRegisterBase<kXRegSize> SimRegister; // r0-r31 | 189 typedef SimRegisterBase<kXRegSize> SimRegister; // r0-r31 |
204 typedef SimRegisterBase<kDRegSize> SimFPRegister; // v0-v31 | 190 typedef SimRegisterBase<kDRegSize> SimFPRegister; // v0-v31 |
205 | 191 |
206 | 192 |
(...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
913 static void UnregisterCTryCatch() { | 899 static void UnregisterCTryCatch() { |
914 Simulator::current(Isolate::Current())->PopAddress(); | 900 Simulator::current(Isolate::Current())->PopAddress(); |
915 } | 901 } |
916 }; | 902 }; |
917 | 903 |
918 #endif // !defined(USE_SIMULATOR) | 904 #endif // !defined(USE_SIMULATOR) |
919 | 905 |
920 } } // namespace v8::internal | 906 } } // namespace v8::internal |
921 | 907 |
922 #endif // V8_A64_SIMULATOR_A64_H_ | 908 #endif // V8_A64_SIMULATOR_A64_H_ |
OLD | NEW |