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_native_api.h" | 8 #include "include/dart_native_api.h" |
9 | 9 |
10 #include "platform/globals.h" | 10 #include "platform/globals.h" |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 result = DartEntry::InvokeFunction(function, Object::empty_array()); \ | 150 result = DartEntry::InvokeFunction(function, Object::empty_array()); \ |
151 EXPECT(!result.IsError()); \ | 151 EXPECT(!result.IsError()); \ |
152 Instance& actual = Instance::Handle(); \ | 152 Instance& actual = Instance::Handle(); \ |
153 actual ^= result.raw(); \ | 153 actual ^= result.raw(); \ |
154 EXPECT(actual.CanonicalizeEquals(Instance::Handle(expected))); \ | 154 EXPECT(actual.CanonicalizeEquals(Instance::Handle(expected))); \ |
155 } | 155 } |
156 | 156 |
157 | 157 |
158 #if defined(TARGET_ARCH_ARM) || \ | 158 #if defined(TARGET_ARCH_ARM) || \ |
159 defined(TARGET_ARCH_MIPS) || \ | 159 defined(TARGET_ARCH_MIPS) || \ |
160 defined(TARGET_ARCH_ARM64) | 160 defined(TARGET_ARCH_ARM64) || \ |
| 161 defined(TARGET_ARCH_DBC) |
161 #if defined(HOST_ARCH_ARM) || \ | 162 #if defined(HOST_ARCH_ARM) || \ |
162 defined(HOST_ARCH_MIPS) || \ | 163 defined(HOST_ARCH_MIPS) || \ |
163 defined(HOST_ARCH_ARM64) | 164 defined(HOST_ARCH_ARM64) || \ |
| 165 !defined(TARGET_ARCH_DBC) |
164 // Running on actual ARM or MIPS hardware, execute code natively. | 166 // Running on actual ARM or MIPS hardware, execute code natively. |
165 #define EXECUTE_TEST_CODE_INT32(name, entry) reinterpret_cast<name>(entry)() | 167 #define EXECUTE_TEST_CODE_INT32(name, entry) reinterpret_cast<name>(entry)() |
166 #define EXECUTE_TEST_CODE_INT64(name, entry) reinterpret_cast<name>(entry)() | 168 #define EXECUTE_TEST_CODE_INT64(name, entry) reinterpret_cast<name>(entry)() |
167 #define EXECUTE_TEST_CODE_INT64_LL(name, entry, long_arg0, long_arg1) \ | 169 #define EXECUTE_TEST_CODE_INT64_LL(name, entry, long_arg0, long_arg1) \ |
168 reinterpret_cast<name>(entry)(long_arg0, long_arg1) | 170 reinterpret_cast<name>(entry)(long_arg0, long_arg1) |
169 #define EXECUTE_TEST_CODE_FLOAT(name, entry) reinterpret_cast<name>(entry)() | 171 #define EXECUTE_TEST_CODE_FLOAT(name, entry) reinterpret_cast<name>(entry)() |
170 #define EXECUTE_TEST_CODE_DOUBLE(name, entry) reinterpret_cast<name>(entry)() | 172 #define EXECUTE_TEST_CODE_DOUBLE(name, entry) reinterpret_cast<name>(entry)() |
171 #define EXECUTE_TEST_CODE_INT32_F(name, entry, float_arg) \ | 173 #define EXECUTE_TEST_CODE_INT32_F(name, entry, float_arg) \ |
172 reinterpret_cast<name>(entry)(float_arg) | 174 reinterpret_cast<name>(entry)(float_arg) |
173 #define EXECUTE_TEST_CODE_INT32_D(name, entry, double_arg) \ | 175 #define EXECUTE_TEST_CODE_INT32_D(name, entry, double_arg) \ |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 Assembler* assembler() const { return assembler_; } | 369 Assembler* assembler() const { return assembler_; } |
368 | 370 |
369 const Code& code() const { return code_; } | 371 const Code& code() const { return code_; } |
370 | 372 |
371 uword entry() const { return code_.EntryPoint(); } | 373 uword entry() const { return code_.EntryPoint(); } |
372 | 374 |
373 // Invoke/InvokeWithCodeAndThread is used to call assembler test functions | 375 // Invoke/InvokeWithCodeAndThread is used to call assembler test functions |
374 // using the ABI calling convention. | 376 // using the ABI calling convention. |
375 // ResultType is the return type of the assembler test function. | 377 // ResultType is the return type of the assembler test function. |
376 // ArgNType is the type of the Nth argument. | 378 // ArgNType is the type of the Nth argument. |
377 #if defined(USING_SIMULATOR) | 379 #if defined(USING_SIMULATOR) && !defined(TARGET_ARCH_DBC) |
378 | 380 |
379 #if defined(ARCH_IS_64_BIT) | 381 #if defined(ARCH_IS_64_BIT) |
380 // TODO(fschneider): Make InvokeWithCodeAndThread<> more general and work on | 382 // TODO(fschneider): Make InvokeWithCodeAndThread<> more general and work on |
381 // 32-bit. | 383 // 32-bit. |
382 // Since Simulator::Call always return a int64_t, bit_cast does not work | 384 // Since Simulator::Call always return a int64_t, bit_cast does not work |
383 // on 32-bit platforms when returning an int32_t. Since template functions | 385 // on 32-bit platforms when returning an int32_t. Since template functions |
384 // don't support partial specialization, we'd need to introduce a helper | 386 // don't support partial specialization, we'd need to introduce a helper |
385 // class to support 32-bit return types. | 387 // class to support 32-bit return types. |
386 template<typename ResultType> ResultType InvokeWithCodeAndThread() { | 388 template<typename ResultType> ResultType InvokeWithCodeAndThread() { |
387 const bool fp_return = is_double<ResultType>::value; | 389 const bool fp_return = is_double<ResultType>::value; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 } | 449 } |
448 | 450 |
449 template<typename ResultType, | 451 template<typename ResultType, |
450 typename Arg1Type, | 452 typename Arg1Type, |
451 typename Arg2Type, | 453 typename Arg2Type, |
452 typename Arg3Type> | 454 typename Arg3Type> |
453 ResultType Invoke(Arg1Type arg1, Arg2Type arg2, Arg3Type arg3) { | 455 ResultType Invoke(Arg1Type arg1, Arg2Type arg2, Arg3Type arg3) { |
454 typedef ResultType (*FunctionType) (Arg1Type, Arg2Type, Arg3Type); | 456 typedef ResultType (*FunctionType) (Arg1Type, Arg2Type, Arg3Type); |
455 return reinterpret_cast<FunctionType>(entry())(arg1, arg2, arg3); | 457 return reinterpret_cast<FunctionType>(entry())(arg1, arg2, arg3); |
456 } | 458 } |
457 #endif // USING_SIMULATOR | 459 #endif // defined(USING_SIMULATOR) && !defined(TARGET_ARCH_DBC) |
458 | 460 |
459 // Assemble test and set code_. | 461 // Assemble test and set code_. |
460 void Assemble(); | 462 void Assemble(); |
461 | 463 |
462 private: | 464 private: |
463 const char* name_; | 465 const char* name_; |
464 Assembler* assembler_; | 466 Assembler* assembler_; |
465 Code& code_; | 467 Code& code_; |
466 | 468 |
467 DISALLOW_COPY_AND_ASSIGN(AssemblerTest); | 469 DISALLOW_COPY_AND_ASSIGN(AssemblerTest); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 // Yields: | 561 // Yields: |
560 // | 562 // |
561 // out = "\"id\":\"\"" | 563 // out = "\"id\":\"\"" |
562 // | 564 // |
563 void ElideJSONSubstring(const char* prefix, const char* in, char* out); | 565 void ElideJSONSubstring(const char* prefix, const char* in, char* out); |
564 | 566 |
565 | 567 |
566 } // namespace dart | 568 } // namespace dart |
567 | 569 |
568 #endif // VM_UNIT_TEST_H_ | 570 #endif // VM_UNIT_TEST_H_ |
OLD | NEW |