| 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 "bin/builtin.h" | 6 #include "bin/builtin.h" |
| 7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
| 8 #include "platform/json.h" | 8 #include "platform/json.h" |
| 9 #include "platform/utils.h" | 9 #include "platform/utils.h" |
| 10 #include "vm/class_finalizer.h" | 10 #include "vm/class_finalizer.h" |
| (...skipping 2614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2625 EXPECT_EQ(iso_1, Dart_CurrentIsolate()); | 2625 EXPECT_EQ(iso_1, Dart_CurrentIsolate()); |
| 2626 Dart_ShutdownIsolate(); | 2626 Dart_ShutdownIsolate(); |
| 2627 EXPECT(NULL == Dart_CurrentIsolate()); | 2627 EXPECT(NULL == Dart_CurrentIsolate()); |
| 2628 } | 2628 } |
| 2629 | 2629 |
| 2630 | 2630 |
| 2631 UNIT_TEST_CASE(CurrentIsolateData) { | 2631 UNIT_TEST_CASE(CurrentIsolateData) { |
| 2632 intptr_t mydata = 12345; | 2632 intptr_t mydata = 12345; |
| 2633 char* err; | 2633 char* err; |
| 2634 Dart_Isolate isolate = | 2634 Dart_Isolate isolate = |
| 2635 Dart_CreateIsolate(NULL, NULL, NULL, | 2635 Dart_CreateIsolate(NULL, NULL, bin::snapshot_buffer, |
| 2636 reinterpret_cast<void*>(mydata), | 2636 reinterpret_cast<void*>(mydata), |
| 2637 &err); | 2637 &err); |
| 2638 EXPECT(isolate != NULL); | 2638 EXPECT(isolate != NULL); |
| 2639 EXPECT_EQ(mydata, reinterpret_cast<intptr_t>(Dart_CurrentIsolateData())); | 2639 EXPECT_EQ(mydata, reinterpret_cast<intptr_t>(Dart_CurrentIsolateData())); |
| 2640 Dart_ShutdownIsolate(); | 2640 Dart_ShutdownIsolate(); |
| 2641 } | 2641 } |
| 2642 | 2642 |
| 2643 | 2643 |
| 2644 TEST_CASE(DebugName) { | 2644 TEST_CASE(DebugName) { |
| 2645 Dart_Handle debug_name = Dart_DebugName(); | 2645 Dart_Handle debug_name = Dart_DebugName(); |
| (...skipping 4032 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6678 " Native.markMainEntered();\n" | 6678 " Native.markMainEntered();\n" |
| 6679 " while (true) {\n" // Infinite empty loop. | 6679 " while (true) {\n" // Infinite empty loop. |
| 6680 " }\n" | 6680 " }\n" |
| 6681 "}\n"; | 6681 "}\n"; |
| 6682 | 6682 |
| 6683 // Tell the other thread that shared_isolate is created. | 6683 // Tell the other thread that shared_isolate is created. |
| 6684 Dart_Handle lib; | 6684 Dart_Handle lib; |
| 6685 { | 6685 { |
| 6686 sync->Enter(); | 6686 sync->Enter(); |
| 6687 char* error = NULL; | 6687 char* error = NULL; |
| 6688 shared_isolate = Dart_CreateIsolate(NULL, NULL, NULL, NULL, &error); | 6688 shared_isolate = Dart_CreateIsolate(NULL, NULL, |
| 6689 bin::snapshot_buffer, |
| 6690 NULL, &error); |
| 6689 EXPECT(shared_isolate != NULL); | 6691 EXPECT(shared_isolate != NULL); |
| 6690 Dart_EnterScope(); | 6692 Dart_EnterScope(); |
| 6691 Dart_Handle url = NewString(TestCase::url()); | 6693 Dart_Handle url = NewString(TestCase::url()); |
| 6692 Dart_Handle source = NewString(kScriptChars); | 6694 Dart_Handle source = NewString(kScriptChars); |
| 6693 Dart_Handle result = Dart_SetLibraryTagHandler(TestCase::library_handler); | 6695 Dart_Handle result = Dart_SetLibraryTagHandler(TestCase::library_handler); |
| 6694 EXPECT_VALID(result); | 6696 EXPECT_VALID(result); |
| 6695 lib = Dart_LoadScript(url, source, 0, 0); | 6697 lib = Dart_LoadScript(url, source, 0, 0); |
| 6696 EXPECT_VALID(lib); | 6698 EXPECT_VALID(lib); |
| 6697 result = Dart_SetNativeResolver(lib, &IsolateInterruptTestNativeLookup); | 6699 result = Dart_SetNativeResolver(lib, &IsolateInterruptTestNativeLookup); |
| 6698 DART_CHECK_VALID(result); | 6700 DART_CHECK_VALID(result); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6802 UNIT_TEST_CASE(IsolateShutdown) { | 6804 UNIT_TEST_CASE(IsolateShutdown) { |
| 6803 Dart_IsolateShutdownCallback saved = Isolate::ShutdownCallback(); | 6805 Dart_IsolateShutdownCallback saved = Isolate::ShutdownCallback(); |
| 6804 Isolate::SetShutdownCallback(IsolateShutdownTestCallback); | 6806 Isolate::SetShutdownCallback(IsolateShutdownTestCallback); |
| 6805 | 6807 |
| 6806 saved_callback_data = NULL; | 6808 saved_callback_data = NULL; |
| 6807 | 6809 |
| 6808 void* my_data = reinterpret_cast<void*>(12345); | 6810 void* my_data = reinterpret_cast<void*>(12345); |
| 6809 | 6811 |
| 6810 // Create an isolate. | 6812 // Create an isolate. |
| 6811 char* err; | 6813 char* err; |
| 6812 Dart_Isolate isolate = Dart_CreateIsolate(NULL, NULL, NULL, my_data, &err); | 6814 Dart_Isolate isolate = Dart_CreateIsolate(NULL, NULL, |
| 6815 bin::snapshot_buffer, |
| 6816 my_data, &err); |
| 6813 if (isolate == NULL) { | 6817 if (isolate == NULL) { |
| 6814 OS::Print("Creation of isolate failed '%s'\n", err); | 6818 OS::Print("Creation of isolate failed '%s'\n", err); |
| 6815 free(err); | 6819 free(err); |
| 6816 } | 6820 } |
| 6817 EXPECT(isolate != NULL); | 6821 EXPECT(isolate != NULL); |
| 6818 | 6822 |
| 6819 // The shutdown callback has not been called. | 6823 // The shutdown callback has not been called. |
| 6820 EXPECT_EQ(0, reinterpret_cast<intptr_t>(saved_callback_data)); | 6824 EXPECT_EQ(0, reinterpret_cast<intptr_t>(saved_callback_data)); |
| 6821 | 6825 |
| 6822 // Shutdown the isolate. | 6826 // Shutdown the isolate. |
| (...skipping 1068 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7891 NewString("main"), | 7895 NewString("main"), |
| 7892 0, | 7896 0, |
| 7893 NULL); | 7897 NULL); |
| 7894 int64_t value = 0; | 7898 int64_t value = 0; |
| 7895 result = Dart_IntegerToInt64(result, &value); | 7899 result = Dart_IntegerToInt64(result, &value); |
| 7896 EXPECT_VALID(result); | 7900 EXPECT_VALID(result); |
| 7897 EXPECT_EQ(8, value); | 7901 EXPECT_EQ(8, value); |
| 7898 } | 7902 } |
| 7899 | 7903 |
| 7900 } // namespace dart | 7904 } // namespace dart |
| OLD | NEW |