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 "bin/builtin.h" | 5 #include "bin/builtin.h" |
6 #include "vm/compiler.h" | 6 #include "vm/compiler.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 3479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3490 EXPECT_EQ(iso_1, Dart_CurrentIsolate()); | 3490 EXPECT_EQ(iso_1, Dart_CurrentIsolate()); |
3491 Dart_ShutdownIsolate(); | 3491 Dart_ShutdownIsolate(); |
3492 EXPECT(NULL == Dart_CurrentIsolate()); | 3492 EXPECT(NULL == Dart_CurrentIsolate()); |
3493 } | 3493 } |
3494 | 3494 |
3495 | 3495 |
3496 UNIT_TEST_CASE(CurrentIsolateData) { | 3496 UNIT_TEST_CASE(CurrentIsolateData) { |
3497 intptr_t mydata = 12345; | 3497 intptr_t mydata = 12345; |
3498 char* err; | 3498 char* err; |
3499 Dart_Isolate isolate = | 3499 Dart_Isolate isolate = |
3500 Dart_CreateIsolate(NULL, NULL, bin::core_isolate_snapshot_buffer, NULL, | 3500 Dart_CreateIsolate(NULL, NULL, bin::core_isolate_snapshot_data, |
| 3501 bin::core_isolate_snapshot_instructions, NULL, |
3501 reinterpret_cast<void*>(mydata), &err); | 3502 reinterpret_cast<void*>(mydata), &err); |
3502 EXPECT(isolate != NULL); | 3503 EXPECT(isolate != NULL); |
3503 EXPECT_EQ(mydata, reinterpret_cast<intptr_t>(Dart_CurrentIsolateData())); | 3504 EXPECT_EQ(mydata, reinterpret_cast<intptr_t>(Dart_CurrentIsolateData())); |
3504 EXPECT_EQ(mydata, reinterpret_cast<intptr_t>(Dart_IsolateData(isolate))); | 3505 EXPECT_EQ(mydata, reinterpret_cast<intptr_t>(Dart_IsolateData(isolate))); |
3505 Dart_ShutdownIsolate(); | 3506 Dart_ShutdownIsolate(); |
3506 } | 3507 } |
3507 | 3508 |
3508 | 3509 |
3509 UNIT_TEST_CASE(IsolateSetCheckedMode) { | 3510 UNIT_TEST_CASE(IsolateSetCheckedMode) { |
3510 const char* kScriptChars = | 3511 const char* kScriptChars = |
(...skipping 10 matching lines...) Expand all Loading... |
3521 // Create an isolate with checked mode flags. | 3522 // Create an isolate with checked mode flags. |
3522 Dart_IsolateFlags api_flags; | 3523 Dart_IsolateFlags api_flags; |
3523 api_flags.version = DART_FLAGS_CURRENT_VERSION; | 3524 api_flags.version = DART_FLAGS_CURRENT_VERSION; |
3524 api_flags.enable_type_checks = true; | 3525 api_flags.enable_type_checks = true; |
3525 api_flags.enable_asserts = true; | 3526 api_flags.enable_asserts = true; |
3526 api_flags.enable_error_on_bad_type = true; | 3527 api_flags.enable_error_on_bad_type = true; |
3527 api_flags.enable_error_on_bad_override = true; | 3528 api_flags.enable_error_on_bad_override = true; |
3528 | 3529 |
3529 char* err; | 3530 char* err; |
3530 Dart_Isolate isolate = Dart_CreateIsolate( | 3531 Dart_Isolate isolate = Dart_CreateIsolate( |
3531 NULL, NULL, bin::core_isolate_snapshot_buffer, &api_flags, NULL, &err); | 3532 NULL, NULL, bin::core_isolate_snapshot_data, |
| 3533 bin::core_isolate_snapshot_instructions, &api_flags, NULL, &err); |
3532 if (isolate == NULL) { | 3534 if (isolate == NULL) { |
3533 OS::Print("Creation of isolate failed '%s'\n", err); | 3535 OS::Print("Creation of isolate failed '%s'\n", err); |
3534 free(err); | 3536 free(err); |
3535 } | 3537 } |
3536 EXPECT(isolate != NULL); | 3538 EXPECT(isolate != NULL); |
3537 | 3539 |
3538 { | 3540 { |
3539 Dart_EnterScope(); | 3541 Dart_EnterScope(); |
3540 Dart_Handle url = NewString(TestCase::url()); | 3542 Dart_Handle url = NewString(TestCase::url()); |
3541 Dart_Handle source = NewString(kScriptChars); | 3543 Dart_Handle source = NewString(kScriptChars); |
(...skipping 4024 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7566 " while (true) {\n" // Infinite empty loop. | 7568 " while (true) {\n" // Infinite empty loop. |
7567 " }\n" | 7569 " }\n" |
7568 "}\n"; | 7570 "}\n"; |
7569 | 7571 |
7570 // Tell the other thread that shared_isolate is created. | 7572 // Tell the other thread that shared_isolate is created. |
7571 Dart_Handle lib; | 7573 Dart_Handle lib; |
7572 { | 7574 { |
7573 MonitorLocker ml(sync); | 7575 MonitorLocker ml(sync); |
7574 char* error = NULL; | 7576 char* error = NULL; |
7575 shared_isolate = Dart_CreateIsolate( | 7577 shared_isolate = Dart_CreateIsolate( |
7576 NULL, NULL, bin::core_isolate_snapshot_buffer, NULL, NULL, &error); | 7578 NULL, NULL, bin::core_isolate_snapshot_data, |
| 7579 bin::core_isolate_snapshot_instructions, NULL, NULL, &error); |
7577 EXPECT(shared_isolate != NULL); | 7580 EXPECT(shared_isolate != NULL); |
7578 Dart_EnterScope(); | 7581 Dart_EnterScope(); |
7579 Dart_Handle url = NewString(TestCase::url()); | 7582 Dart_Handle url = NewString(TestCase::url()); |
7580 Dart_Handle source = NewString(kScriptChars); | 7583 Dart_Handle source = NewString(kScriptChars); |
7581 Dart_Handle result = Dart_SetLibraryTagHandler(TestCase::library_handler); | 7584 Dart_Handle result = Dart_SetLibraryTagHandler(TestCase::library_handler); |
7582 EXPECT_VALID(result); | 7585 EXPECT_VALID(result); |
7583 lib = Dart_LoadScript(url, Dart_Null(), source, 0, 0); | 7586 lib = Dart_LoadScript(url, Dart_Null(), source, 0, 0); |
7584 EXPECT_VALID(lib); | 7587 EXPECT_VALID(lib); |
7585 result = Dart_FinalizeLoading(false); | 7588 result = Dart_FinalizeLoading(false); |
7586 EXPECT_VALID(result); | 7589 EXPECT_VALID(result); |
(...skipping 30 matching lines...) Expand all Loading... |
7617 Dart_IsolateShutdownCallback saved = Isolate::ShutdownCallback(); | 7620 Dart_IsolateShutdownCallback saved = Isolate::ShutdownCallback(); |
7618 Isolate::SetShutdownCallback(IsolateShutdownTestCallback); | 7621 Isolate::SetShutdownCallback(IsolateShutdownTestCallback); |
7619 | 7622 |
7620 saved_callback_data = NULL; | 7623 saved_callback_data = NULL; |
7621 | 7624 |
7622 void* my_data = reinterpret_cast<void*>(12345); | 7625 void* my_data = reinterpret_cast<void*>(12345); |
7623 | 7626 |
7624 // Create an isolate. | 7627 // Create an isolate. |
7625 char* err; | 7628 char* err; |
7626 Dart_Isolate isolate = Dart_CreateIsolate( | 7629 Dart_Isolate isolate = Dart_CreateIsolate( |
7627 NULL, NULL, bin::core_isolate_snapshot_buffer, NULL, my_data, &err); | 7630 NULL, NULL, bin::core_isolate_snapshot_data, |
| 7631 bin::core_isolate_snapshot_instructions, NULL, my_data, &err); |
7628 if (isolate == NULL) { | 7632 if (isolate == NULL) { |
7629 OS::Print("Creation of isolate failed '%s'\n", err); | 7633 OS::Print("Creation of isolate failed '%s'\n", err); |
7630 free(err); | 7634 free(err); |
7631 } | 7635 } |
7632 EXPECT(isolate != NULL); | 7636 EXPECT(isolate != NULL); |
7633 | 7637 |
7634 // The shutdown callback has not been called. | 7638 // The shutdown callback has not been called. |
7635 EXPECT_EQ(0, reinterpret_cast<intptr_t>(saved_callback_data)); | 7639 EXPECT_EQ(0, reinterpret_cast<intptr_t>(saved_callback_data)); |
7636 | 7640 |
7637 // Shutdown the isolate. | 7641 // Shutdown the isolate. |
(...skipping 28 matching lines...) Expand all Loading... |
7666 " return a + b;\n" | 7670 " return a + b;\n" |
7667 "}\n" | 7671 "}\n" |
7668 "\n" | 7672 "\n" |
7669 "void main() {\n" | 7673 "void main() {\n" |
7670 " add(4, 5);\n" | 7674 " add(4, 5);\n" |
7671 "}\n"; | 7675 "}\n"; |
7672 | 7676 |
7673 // Create an isolate. | 7677 // Create an isolate. |
7674 char* err; | 7678 char* err; |
7675 Dart_Isolate isolate = Dart_CreateIsolate( | 7679 Dart_Isolate isolate = Dart_CreateIsolate( |
7676 NULL, NULL, bin::core_isolate_snapshot_buffer, NULL, NULL, &err); | 7680 NULL, NULL, bin::core_isolate_snapshot_data, |
| 7681 bin::core_isolate_snapshot_instructions, NULL, NULL, &err); |
7677 if (isolate == NULL) { | 7682 if (isolate == NULL) { |
7678 OS::Print("Creation of isolate failed '%s'\n", err); | 7683 OS::Print("Creation of isolate failed '%s'\n", err); |
7679 free(err); | 7684 free(err); |
7680 } | 7685 } |
7681 EXPECT(isolate != NULL); | 7686 EXPECT(isolate != NULL); |
7682 | 7687 |
7683 Isolate::SetShutdownCallback(IsolateShutdownRunDartCodeTestCallback); | 7688 Isolate::SetShutdownCallback(IsolateShutdownRunDartCodeTestCallback); |
7684 | 7689 |
7685 { | 7690 { |
7686 Dart_EnterScope(); | 7691 Dart_EnterScope(); |
(...skipping 2222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9909 EXPECT_VALID(result); | 9914 EXPECT_VALID(result); |
9910 result = Dart_FinalizeLoading(false); | 9915 result = Dart_FinalizeLoading(false); |
9911 EXPECT_VALID(result); | 9916 EXPECT_VALID(result); |
9912 result = Dart_Invoke(lib, NewString("foozoo"), 0, NULL); | 9917 result = Dart_Invoke(lib, NewString("foozoo"), 0, NULL); |
9913 EXPECT(Dart_IsError(result)); | 9918 EXPECT(Dart_IsError(result)); |
9914 } | 9919 } |
9915 | 9920 |
9916 #endif // !PRODUCT | 9921 #endif // !PRODUCT |
9917 | 9922 |
9918 } // namespace dart | 9923 } // namespace dart |
OLD | NEW |