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 VM_UNIT_TEST_H_ | 5 #ifndef VM_UNIT_TEST_H_ |
6 #define VM_UNIT_TEST_H_ | 6 #define VM_UNIT_TEST_H_ |
7 | 7 |
8 #include "include/dart_api.h" | 8 #include "include/dart_api.h" |
9 | 9 |
| 10 #include "platform/globals.h" |
| 11 |
10 #include "vm/ast.h" | 12 #include "vm/ast.h" |
11 #include "vm/dart.h" | 13 #include "vm/dart.h" |
12 #include "vm/globals.h" | 14 #include "vm/globals.h" |
13 #include "vm/heap.h" | 15 #include "vm/heap.h" |
14 #include "vm/isolate.h" | 16 #include "vm/isolate.h" |
15 #include "vm/longjump.h" | 17 #include "vm/longjump.h" |
16 #include "vm/object.h" | 18 #include "vm/object.h" |
17 #include "vm/object_store.h" | 19 #include "vm/object_store.h" |
18 #include "vm/simulator.h" | 20 #include "vm/simulator.h" |
19 #include "vm/zone.h" | 21 #include "vm/zone.h" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 static void CodeGenTestRun##name1(const Function& function) { \ | 125 static void CodeGenTestRun##name1(const Function& function) { \ |
124 Object& result = Object::Handle(); \ | 126 Object& result = Object::Handle(); \ |
125 result = DartEntry::InvokeFunction(function, Object::empty_array()); \ | 127 result = DartEntry::InvokeFunction(function, Object::empty_array()); \ |
126 EXPECT(!result.IsError()); \ | 128 EXPECT(!result.IsError()); \ |
127 Instance& actual = Instance::Handle(); \ | 129 Instance& actual = Instance::Handle(); \ |
128 actual ^= result.raw(); \ | 130 actual ^= result.raw(); \ |
129 EXPECT(actual.Equals(Instance::Handle(expected))); \ | 131 EXPECT(actual.Equals(Instance::Handle(expected))); \ |
130 } | 132 } |
131 | 133 |
132 | 134 |
133 #if defined(TARGET_ARCH_ARM) || defined(TARGET_ARCH_MIPS) | 135 #if defined(TARGET_ARCH_ARM) || \ |
134 #if defined(HOST_ARCH_ARM) || defined(HOST_ARCH_MIPS) | 136 defined(TARGET_ARCH_MIPS) || \ |
| 137 defined(TARGET_ARCH_ARM64) |
| 138 #if defined(HOST_ARCH_ARM) || \ |
| 139 defined(HOST_ARCH_MIPS) || \ |
| 140 defined(HOST_ARCH_ARM64) |
135 // Running on actual ARM or MIPS hardware, execute code natively. | 141 // Running on actual ARM or MIPS hardware, execute code natively. |
136 #define EXECUTE_TEST_CODE_INT32(name, entry) reinterpret_cast<name>(entry)() | 142 #define EXECUTE_TEST_CODE_INT32(name, entry) reinterpret_cast<name>(entry)() |
137 #define EXECUTE_TEST_CODE_INT64_LL(name, entry, long_arg0, long_arg1) \ | 143 #define EXECUTE_TEST_CODE_INT64_LL(name, entry, long_arg0, long_arg1) \ |
138 reinterpret_cast<name>(entry)(long_arg0, long_arg1) | 144 reinterpret_cast<name>(entry)(long_arg0, long_arg1) |
139 #define EXECUTE_TEST_CODE_FLOAT(name, entry) reinterpret_cast<name>(entry)() | 145 #define EXECUTE_TEST_CODE_FLOAT(name, entry) reinterpret_cast<name>(entry)() |
140 #define EXECUTE_TEST_CODE_DOUBLE(name, entry) reinterpret_cast<name>(entry)() | 146 #define EXECUTE_TEST_CODE_DOUBLE(name, entry) reinterpret_cast<name>(entry)() |
141 #define EXECUTE_TEST_CODE_INT32_F(name, entry, float_arg) \ | 147 #define EXECUTE_TEST_CODE_INT32_F(name, entry, float_arg) \ |
142 reinterpret_cast<name>(entry)(float_arg) | 148 reinterpret_cast<name>(entry)(float_arg) |
143 #define EXECUTE_TEST_CODE_INT32_D(name, entry, double_arg) \ | 149 #define EXECUTE_TEST_CODE_INT32_D(name, entry, double_arg) \ |
144 reinterpret_cast<name>(entry)(double_arg) | 150 reinterpret_cast<name>(entry)(double_arg) |
145 #else | 151 #else |
146 // Not running on ARM or MIPS hardware, call simulator to execute code. | 152 // Not running on ARM or MIPS hardware, call simulator to execute code. |
| 153 #if defined(ARCH_IS_64_BIT) |
| 154 // TODO(zra): Supply more macros for 64-bit as tests are added for ARM64. |
| 155 #define EXECUTE_TEST_CODE_INT32(name, entry) \ |
| 156 static_cast<int32_t>(Simulator::Current()->Call( \ |
| 157 bit_cast<int64_t, uword>(entry), 0, 0, 0, 0)) |
| 158 #else |
147 #define EXECUTE_TEST_CODE_INT32(name, entry) \ | 159 #define EXECUTE_TEST_CODE_INT32(name, entry) \ |
148 static_cast<int32_t>(Simulator::Current()->Call( \ | 160 static_cast<int32_t>(Simulator::Current()->Call( \ |
149 bit_cast<int32_t, uword>(entry), 0, 0, 0, 0)) | 161 bit_cast<int32_t, uword>(entry), 0, 0, 0, 0)) |
| 162 #endif |
150 #define EXECUTE_TEST_CODE_INT64_LL(name, entry, long_arg0, long_arg1) \ | 163 #define EXECUTE_TEST_CODE_INT64_LL(name, entry, long_arg0, long_arg1) \ |
151 static_cast<int64_t>(Simulator::Current()->Call( \ | 164 static_cast<int64_t>(Simulator::Current()->Call( \ |
152 bit_cast<int32_t, uword>(entry), \ | 165 bit_cast<int32_t, uword>(entry), \ |
153 Utils::Low32Bits(long_arg0), \ | 166 Utils::Low32Bits(long_arg0), \ |
154 Utils::High32Bits(long_arg0), \ | 167 Utils::High32Bits(long_arg0), \ |
155 Utils::Low32Bits(long_arg1), \ | 168 Utils::Low32Bits(long_arg1), \ |
156 Utils::High32Bits(long_arg1))) | 169 Utils::High32Bits(long_arg1))) |
157 #define EXECUTE_TEST_CODE_FLOAT(name, entry) \ | 170 #define EXECUTE_TEST_CODE_FLOAT(name, entry) \ |
158 bit_cast<float, int32_t>(Simulator::Current()->Call( \ | 171 bit_cast<float, int32_t>(Simulator::Current()->Call( \ |
159 bit_cast<int32_t, uword>(entry), 0, 0, 0, 0, true)) | 172 bit_cast<int32_t, uword>(entry), 0, 0, 0, 0, true)) |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 } \ | 395 } \ |
383 } else { \ | 396 } else { \ |
384 dart::Expect(__FILE__, __LINE__).Fail("expected True, but was '%s'\n", \ | 397 dart::Expect(__FILE__, __LINE__).Fail("expected True, but was '%s'\n", \ |
385 #handle); \ | 398 #handle); \ |
386 } \ | 399 } \ |
387 } while (0) | 400 } while (0) |
388 | 401 |
389 } // namespace dart | 402 } // namespace dart |
390 | 403 |
391 #endif // VM_UNIT_TEST_H_ | 404 #endif // VM_UNIT_TEST_H_ |
OLD | NEW |