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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 // 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 |
170 // top bits of the corresponding X register. | 170 // top bits of the corresponding X register. |
171 memset(value_, 0, kSizeInBytes); | 171 if (size == kXRegSize) { |
Rodolph Perfetta
2014/03/20 11:33:57
STATIC_ASSERT(kXRegSize == kDRegSize);
This is mo
Fritz
2014/03/20 19:37:01
Done.
| |
172 memcpy(value_, &new_value, size); | 172 memcpy(value_, &new_value, kXRegSize); |
173 } else if (size == kWRegSize) { | |
174 memset(value_, 0, kSizeInBytes); | |
175 memcpy(value_, &new_value, kWRegSize); | |
176 } else { | |
177 UNREACHABLE(); | |
178 } | |
173 } | 179 } |
174 | 180 |
175 // Copy 'size' bytes of the register to the result, and zero-extend to fill | 181 // Copy 'size' bytes of the register to the result, and zero-extend to fill |
176 // the result. | 182 // the result. |
177 template<typename T> | 183 template<typename T> |
178 T Get(unsigned size = sizeof(T)) const { | 184 T Get(unsigned size = sizeof(T)) const { |
179 ASSERT(size <= kSizeInBytes); | 185 ASSERT(size <= kSizeInBytes); |
180 T result; | 186 T result; |
181 memset(&result, 0, sizeof(result)); | 187 memset(&result, 0, sizeof(result)); |
Sven Panne
2014/03/20 10:22:38
I think this could be moved into the 2nd case, jus
Fritz
2014/03/20 19:37:01
Done.
| |
182 memcpy(&result, value_, size); | 188 if (size == kXRegSize) { |
189 memcpy(&result, value_, kXRegSize); | |
190 } else if (size == kWRegSize) { | |
191 memcpy(&result, value_, kWRegSize); | |
192 } else { | |
193 UNREACHABLE(); | |
194 } | |
183 return result; | 195 return result; |
184 } | 196 } |
185 | 197 |
186 protected: | 198 protected: |
187 uint8_t value_[kSizeInBytes]; | 199 uint8_t value_[kSizeInBytes]; |
188 }; | 200 }; |
189 typedef SimRegisterBase<kXRegSize> SimRegister; // r0-r31 | 201 typedef SimRegisterBase<kXRegSize> SimRegister; // r0-r31 |
190 typedef SimRegisterBase<kDRegSize> SimFPRegister; // v0-v31 | 202 typedef SimRegisterBase<kDRegSize> SimFPRegister; // v0-v31 |
191 | 203 |
192 | 204 |
(...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
899 static void UnregisterCTryCatch() { | 911 static void UnregisterCTryCatch() { |
900 Simulator::current(Isolate::Current())->PopAddress(); | 912 Simulator::current(Isolate::Current())->PopAddress(); |
901 } | 913 } |
902 }; | 914 }; |
903 | 915 |
904 #endif // !defined(USE_SIMULATOR) | 916 #endif // !defined(USE_SIMULATOR) |
905 | 917 |
906 } } // namespace v8::internal | 918 } } // namespace v8::internal |
907 | 919 |
908 #endif // V8_A64_SIMULATOR_A64_H_ | 920 #endif // V8_A64_SIMULATOR_A64_H_ |
OLD | NEW |