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