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 "vm/dart_api_impl.h" | 5 #include "vm/dart_api_impl.h" |
6 #include "bin/builtin.h" | 6 #include "bin/builtin.h" |
7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
8 #include "include/dart_mirrors_api.h" | 8 #include "include/dart_mirrors_api.h" |
9 #include "include/dart_native_api.h" | 9 #include "include/dart_native_api.h" |
10 #include "include/dart_tools_api.h" | 10 #include "include/dart_tools_api.h" |
(...skipping 9002 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9013 // We don't expect to be able to patch in this case as the function being | 9013 // We don't expect to be able to patch in this case as the function being |
9014 // patched has already executed. | 9014 // patched has already executed. |
9015 result = Dart_LibraryLoadPatch(lib, url, source); | 9015 result = Dart_LibraryLoadPatch(lib, url, source); |
9016 EXPECT_VALID(result); | 9016 EXPECT_VALID(result); |
9017 result = Dart_FinalizeLoading(false); | 9017 result = Dart_FinalizeLoading(false); |
9018 EXPECT_VALID(result); | 9018 EXPECT_VALID(result); |
9019 result = Dart_Invoke(lib, NewString("foozoo"), 0, NULL); | 9019 result = Dart_Invoke(lib, NewString("foozoo"), 0, NULL); |
9020 EXPECT(Dart_IsError(result)); | 9020 EXPECT(Dart_IsError(result)); |
9021 } | 9021 } |
9022 | 9022 |
| 9023 void NotifyIdleNative(Dart_NativeArguments args) { |
| 9024 Dart_NotifyIdle(Dart_TimelineGetMicros() + 10 * kMicrosecondsPerMillisecond); |
| 9025 } |
| 9026 |
| 9027 static Dart_NativeFunction NotifyIdle_native_lookup(Dart_Handle name, |
| 9028 int argument_count, |
| 9029 bool* auto_setup_scope) { |
| 9030 ASSERT(auto_setup_scope != NULL); |
| 9031 *auto_setup_scope = true; |
| 9032 return reinterpret_cast<Dart_NativeFunction>(&NotifyIdleNative); |
| 9033 } |
| 9034 |
| 9035 TEST_CASE(DartAPI_NotifyIdle) { |
| 9036 const char* kScriptChars = |
| 9037 "void notifyIdle() native 'Test_nativeFunc';\n" |
| 9038 "void main() {\n" |
| 9039 " var v;\n" |
| 9040 " for (var i = 0; i < 100; i++) {\n" |
| 9041 " var t = new List();\n" |
| 9042 " for (var j = 0; j < 10000; j++) {\n" |
| 9043 " t.add(new List(100));\n" |
| 9044 " }\n" |
| 9045 " v = t;\n" |
| 9046 " notifyIdle();\n" |
| 9047 " }\n" |
| 9048 "}\n"; |
| 9049 Dart_Handle lib = |
| 9050 TestCase::LoadTestScript(kScriptChars, &NotifyIdle_native_lookup); |
| 9051 Dart_Handle result; |
| 9052 |
| 9053 // Use Dart_PropagateError to propagate the error. |
| 9054 use_throw_exception = false; |
| 9055 use_set_return = false; |
| 9056 |
| 9057 result = Dart_Invoke(lib, NewString("main"), 0, NULL); |
| 9058 EXPECT_VALID(result); |
| 9059 } |
| 9060 |
9023 #endif // !PRODUCT | 9061 #endif // !PRODUCT |
9024 | 9062 |
9025 } // namespace dart | 9063 } // namespace dart |
OLD | NEW |