| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 #include "include/dart_api.h" | 5 #include "include/dart_api.h" |
| 6 #include "platform/assert.h" | 6 #include "platform/assert.h" |
| 7 #include "platform/utils.h" | 7 #include "platform/utils.h" |
| 8 #include "vm/class_finalizer.h" | 8 #include "vm/class_finalizer.h" |
| 9 #include "vm/dart_api_impl.h" | 9 #include "vm/dart_api_impl.h" |
| 10 #include "vm/dart_api_state.h" | 10 #include "vm/dart_api_state.h" |
| (...skipping 4768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4779 Dart_Handle param1 = Dart_GetNativeArgument(args, 1); | 4779 Dart_Handle param1 = Dart_GetNativeArgument(args, 1); |
| 4780 EXPECT(!Dart_IsError(param1)); | 4780 EXPECT(!Dart_IsError(param1)); |
| 4781 EXPECT(Dart_IsInteger(param1)); | 4781 EXPECT(Dart_IsInteger(param1)); |
| 4782 bool fits = false; | 4782 bool fits = false; |
| 4783 Dart_Handle result = Dart_IntegerFitsIntoInt64(param1, &fits); | 4783 Dart_Handle result = Dart_IntegerFitsIntoInt64(param1, &fits); |
| 4784 EXPECT(!Dart_IsError(result) && fits); | 4784 EXPECT(!Dart_IsError(result) && fits); |
| 4785 int64_t value1; | 4785 int64_t value1; |
| 4786 result = Dart_IntegerToInt64(param1, &value1); | 4786 result = Dart_IntegerToInt64(param1, &value1); |
| 4787 EXPECT(!Dart_IsError(result)); | 4787 EXPECT(!Dart_IsError(result)); |
| 4788 EXPECT_LE(0, value1); | 4788 EXPECT_LE(0, value1); |
| 4789 EXPECT_LE(value1, 1000000); | 4789 EXPECT_LE(value1, 10000000); |
| 4790 | 4790 |
| 4791 // Get native field from receiver. | 4791 // Get native field from receiver. |
| 4792 intptr_t value2; | 4792 intptr_t value2; |
| 4793 result = Dart_GetNativeInstanceField(recv, 0, &value2); | 4793 result = Dart_GetNativeInstanceField(recv, 0, &value2); |
| 4794 EXPECT(!Dart_IsError(result)); | 4794 EXPECT(!Dart_IsError(result)); |
| 4795 EXPECT_EQ(7, value2); | 4795 EXPECT_EQ(7, value2); |
| 4796 | 4796 |
| 4797 // Return param + receiver.field. | 4797 // Return param + receiver.field. |
| 4798 Dart_SetReturnValue(args, Dart_NewInteger(value1 * value2)); | 4798 Dart_SetReturnValue(args, Dart_NewInteger(value1 * value2)); |
| 4799 Dart_ExitScope(); | 4799 Dart_ExitScope(); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4835 reinterpret_cast<Dart_NativeEntryResolver>(bm_uda_lookup)); | 4835 reinterpret_cast<Dart_NativeEntryResolver>(bm_uda_lookup)); |
| 4836 | 4836 |
| 4837 // Create a native wrapper class with native fields. | 4837 // Create a native wrapper class with native fields. |
| 4838 Dart_Handle result = Dart_CreateNativeWrapperClass( | 4838 Dart_Handle result = Dart_CreateNativeWrapperClass( |
| 4839 lib, | 4839 lib, |
| 4840 Dart_NewString("NativeFieldsWrapper"), | 4840 Dart_NewString("NativeFieldsWrapper"), |
| 4841 1); | 4841 1); |
| 4842 EXPECT_VALID(result); | 4842 EXPECT_VALID(result); |
| 4843 | 4843 |
| 4844 Dart_Handle args[1]; | 4844 Dart_Handle args[1]; |
| 4845 args[0] = Dart_NewInteger(100000); | 4845 args[0] = Dart_NewInteger(10000000); |
| 4846 result = Dart_Invoke(lib, | 4846 result = Dart_Invoke(lib, |
| 4847 Dart_NewString("benchmark"), | 4847 Dart_NewString("benchmark"), |
| 4848 1, | 4848 1, |
| 4849 args); | 4849 args); |
| 4850 EXPECT_VALID(result); | 4850 EXPECT_VALID(result); |
| 4851 EXPECT(Dart_IsDouble(result)); | 4851 EXPECT(Dart_IsDouble(result)); |
| 4852 double out; | 4852 double out; |
| 4853 result = Dart_DoubleValue(result, &out); | 4853 result = Dart_DoubleValue(result, &out); |
| 4854 fprintf(stderr, "Benchmark_UseDartApi: %f us per iteration\n", out); | 4854 fprintf(stderr, "Benchmark_UseDartApi: %f us per iteration\n", out); |
| 4855 } | 4855 } |
| 4856 | 4856 |
| 4857 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). | 4857 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). |
| 4858 | 4858 |
| 4859 } // namespace dart | 4859 } // namespace dart |
| OLD | NEW |