| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef RUNTIME_VM_UNIT_TEST_H_ | 5 #ifndef RUNTIME_VM_UNIT_TEST_H_ |
| 6 #define RUNTIME_VM_UNIT_TEST_H_ | 6 #define RUNTIME_VM_UNIT_TEST_H_ |
| 7 | 7 |
| 8 #include "include/dart_native_api.h" | 8 #include "include/dart_native_api.h" |
| 9 | 9 |
| 10 #include "platform/globals.h" | 10 #include "platform/globals.h" |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 static void CodeGenTestRun##name1(const Function& function) { \ | 155 static void CodeGenTestRun##name1(const Function& function) { \ |
| 156 Object& result = Object::Handle(); \ | 156 Object& result = Object::Handle(); \ |
| 157 result = DartEntry::InvokeFunction(function, Object::empty_array()); \ | 157 result = DartEntry::InvokeFunction(function, Object::empty_array()); \ |
| 158 EXPECT(!result.IsError()); \ | 158 EXPECT(!result.IsError()); \ |
| 159 Instance& actual = Instance::Handle(); \ | 159 Instance& actual = Instance::Handle(); \ |
| 160 actual ^= result.raw(); \ | 160 actual ^= result.raw(); \ |
| 161 EXPECT(actual.CanonicalizeEquals(Instance::Handle(expected))); \ | 161 EXPECT(actual.CanonicalizeEquals(Instance::Handle(expected))); \ |
| 162 } | 162 } |
| 163 | 163 |
| 164 | 164 |
| 165 #if defined(TARGET_ARCH_ARM) || defined(TARGET_ARCH_MIPS) || \ | 165 #if defined(TARGET_ARCH_ARM) || defined(TARGET_ARCH_ARM64) |
| 166 defined(TARGET_ARCH_ARM64) | 166 #if defined(HOST_ARCH_ARM) || defined(HOST_ARCH_ARM64) |
| 167 #if defined(HOST_ARCH_ARM) || defined(HOST_ARCH_MIPS) || \ | 167 // Running on actual ARM hardware, execute code natively. |
| 168 defined(HOST_ARCH_ARM64) | |
| 169 // Running on actual ARM or MIPS hardware, execute code natively. | |
| 170 #define EXECUTE_TEST_CODE_INT32(name, entry) reinterpret_cast<name>(entry)() | 168 #define EXECUTE_TEST_CODE_INT32(name, entry) reinterpret_cast<name>(entry)() |
| 171 #define EXECUTE_TEST_CODE_INT64(name, entry) reinterpret_cast<name>(entry)() | 169 #define EXECUTE_TEST_CODE_INT64(name, entry) reinterpret_cast<name>(entry)() |
| 172 #define EXECUTE_TEST_CODE_INT64_LL(name, entry, long_arg0, long_arg1) \ | 170 #define EXECUTE_TEST_CODE_INT64_LL(name, entry, long_arg0, long_arg1) \ |
| 173 reinterpret_cast<name>(entry)(long_arg0, long_arg1) | 171 reinterpret_cast<name>(entry)(long_arg0, long_arg1) |
| 174 #define EXECUTE_TEST_CODE_FLOAT(name, entry) reinterpret_cast<name>(entry)() | 172 #define EXECUTE_TEST_CODE_FLOAT(name, entry) reinterpret_cast<name>(entry)() |
| 175 #define EXECUTE_TEST_CODE_DOUBLE(name, entry) reinterpret_cast<name>(entry)() | 173 #define EXECUTE_TEST_CODE_DOUBLE(name, entry) reinterpret_cast<name>(entry)() |
| 176 #define EXECUTE_TEST_CODE_INT32_F(name, entry, float_arg) \ | 174 #define EXECUTE_TEST_CODE_INT32_F(name, entry, float_arg) \ |
| 177 reinterpret_cast<name>(entry)(float_arg) | 175 reinterpret_cast<name>(entry)(float_arg) |
| 178 #define EXECUTE_TEST_CODE_INT32_D(name, entry, double_arg) \ | 176 #define EXECUTE_TEST_CODE_INT32_D(name, entry, double_arg) \ |
| 179 reinterpret_cast<name>(entry)(double_arg) | 177 reinterpret_cast<name>(entry)(double_arg) |
| 180 #define EXECUTE_TEST_CODE_INTPTR_INTPTR(name, entry, pointer_arg) \ | 178 #define EXECUTE_TEST_CODE_INTPTR_INTPTR(name, entry, pointer_arg) \ |
| 181 reinterpret_cast<name>(entry)(pointer_arg) | 179 reinterpret_cast<name>(entry)(pointer_arg) |
| 182 #define EXECUTE_TEST_CODE_INT32_INTPTR(name, entry, pointer_arg) \ | 180 #define EXECUTE_TEST_CODE_INT32_INTPTR(name, entry, pointer_arg) \ |
| 183 reinterpret_cast<name>(entry)(pointer_arg) | 181 reinterpret_cast<name>(entry)(pointer_arg) |
| 184 #else | 182 #else |
| 185 // Not running on ARM or MIPS hardware, call simulator to execute code. | 183 // Not running on ARM hardware, call simulator to execute code. |
| 186 #if defined(ARCH_IS_64_BIT) | 184 #if defined(ARCH_IS_64_BIT) |
| 187 #define EXECUTE_TEST_CODE_INT64(name, entry) \ | 185 #define EXECUTE_TEST_CODE_INT64(name, entry) \ |
| 188 static_cast<int64_t>( \ | 186 static_cast<int64_t>( \ |
| 189 Simulator::Current()->Call(bit_cast<int64_t, uword>(entry), 0, 0, 0, 0)) | 187 Simulator::Current()->Call(bit_cast<int64_t, uword>(entry), 0, 0, 0, 0)) |
| 190 #define EXECUTE_TEST_CODE_DOUBLE(name, entry) \ | 188 #define EXECUTE_TEST_CODE_DOUBLE(name, entry) \ |
| 191 bit_cast<double, int64_t>(Simulator::Current()->Call( \ | 189 bit_cast<double, int64_t>(Simulator::Current()->Call( \ |
| 192 bit_cast<int64_t, uword>(entry), 0, 0, 0, 0, true)) | 190 bit_cast<int64_t, uword>(entry), 0, 0, 0, 0, true)) |
| 193 #define EXECUTE_TEST_CODE_INTPTR_INTPTR(name, entry, pointer_arg) \ | 191 #define EXECUTE_TEST_CODE_INTPTR_INTPTR(name, entry, pointer_arg) \ |
| 194 static_cast<intptr_t>(Simulator::Current()->Call( \ | 192 static_cast<intptr_t>(Simulator::Current()->Call( \ |
| 195 bit_cast<int64_t, uword>(entry), \ | 193 bit_cast<int64_t, uword>(entry), \ |
| (...skipping 29 matching lines...) Expand all Loading... |
| 225 #define EXECUTE_TEST_CODE_INT32_F(name, entry, float_arg) \ | 223 #define EXECUTE_TEST_CODE_INT32_F(name, entry, float_arg) \ |
| 226 static_cast<int32_t>(Simulator::Current()->Call( \ | 224 static_cast<int32_t>(Simulator::Current()->Call( \ |
| 227 bit_cast<int32_t, uword>(entry), bit_cast<int32_t, float>(float_arg), 0, \ | 225 bit_cast<int32_t, uword>(entry), bit_cast<int32_t, float>(float_arg), 0, \ |
| 228 0, 0, false, true)) | 226 0, 0, false, true)) |
| 229 #define EXECUTE_TEST_CODE_INT32_D(name, entry, double_arg) \ | 227 #define EXECUTE_TEST_CODE_INT32_D(name, entry, double_arg) \ |
| 230 static_cast<int32_t>(Simulator::Current()->Call( \ | 228 static_cast<int32_t>(Simulator::Current()->Call( \ |
| 231 bit_cast<int32_t, uword>(entry), \ | 229 bit_cast<int32_t, uword>(entry), \ |
| 232 Utils::Low32Bits(bit_cast<int64_t, double>(double_arg)), \ | 230 Utils::Low32Bits(bit_cast<int64_t, double>(double_arg)), \ |
| 233 Utils::High32Bits(bit_cast<int64_t, double>(double_arg)), 0, 0, false, \ | 231 Utils::High32Bits(bit_cast<int64_t, double>(double_arg)), 0, 0, false, \ |
| 234 true)) | 232 true)) |
| 235 #endif // defined(HOST_ARCH_ARM) || defined(HOST_ARCH_MIPS) | 233 #endif // defined(HOST_ARCH_ARM) |
| 236 #endif // defined(TARGET_ARCH_{ARM, ARM64, MIPS}) | 234 #endif // defined(TARGET_ARCH_{ARM, ARM64}) |
| 237 | 235 |
| 238 | 236 |
| 239 inline Dart_Handle NewString(const char* str) { | 237 inline Dart_Handle NewString(const char* str) { |
| 240 return Dart_NewStringFromCString(str); | 238 return Dart_NewStringFromCString(str); |
| 241 } | 239 } |
| 242 | 240 |
| 243 | 241 |
| 244 namespace dart { | 242 namespace dart { |
| 245 | 243 |
| 246 // Forward declarations. | 244 // Forward declarations. |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 ~SetFlagScope() { *flag_ = original_value_; } | 641 ~SetFlagScope() { *flag_ = original_value_; } |
| 644 | 642 |
| 645 private: | 643 private: |
| 646 T* flag_; | 644 T* flag_; |
| 647 T original_value_; | 645 T original_value_; |
| 648 }; | 646 }; |
| 649 | 647 |
| 650 } // namespace dart | 648 } // namespace dart |
| 651 | 649 |
| 652 #endif // RUNTIME_VM_UNIT_TEST_H_ | 650 #endif // RUNTIME_VM_UNIT_TEST_H_ |
| OLD | NEW |