| 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_debugger_api.h" | 5 #include "include/dart_debugger_api.h" |
| 6 #include "platform/assert.h" | 6 #include "platform/assert.h" |
| 7 #include "vm/bigint_operations.h" | 7 #include "vm/bigint_operations.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_message.h" | 10 #include "vm/dart_api_message.h" |
| (...skipping 932 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 943 TestIsolateScope __test_isolate__; | 943 TestIsolateScope __test_isolate__; |
| 944 | 944 |
| 945 Isolate* isolate = Isolate::Current(); | 945 Isolate* isolate = Isolate::Current(); |
| 946 StackZone zone(isolate); | 946 StackZone zone(isolate); |
| 947 HandleScope scope(isolate); | 947 HandleScope scope(isolate); |
| 948 | 948 |
| 949 // Create a test library and Load up a test script in it. | 949 // Create a test library and Load up a test script in it. |
| 950 TestCase::LoadTestScript(kScriptChars, NULL); | 950 TestCase::LoadTestScript(kScriptChars, NULL); |
| 951 EXPECT_VALID(Api::CheckIsolateState(isolate)); | 951 EXPECT_VALID(Api::CheckIsolateState(isolate)); |
| 952 timer1.Stop(); | 952 timer1.Stop(); |
| 953 OS::PrintErr("Without Snapshot: %"Pd64"us\n", timer1.TotalElapsedTime()); | 953 OS::PrintErr("Without Snapshot: %" Pd64 "us\n", timer1.TotalElapsedTime()); |
| 954 | 954 |
| 955 // Write snapshot with object content. | 955 // Write snapshot with object content. |
| 956 FullSnapshotWriter writer(&buffer, &malloc_allocator); | 956 FullSnapshotWriter writer(&buffer, &malloc_allocator); |
| 957 writer.WriteFullSnapshot(); | 957 writer.WriteFullSnapshot(); |
| 958 } | 958 } |
| 959 | 959 |
| 960 // Now Create another isolate using the snapshot and execute a method | 960 // Now Create another isolate using the snapshot and execute a method |
| 961 // from the script. | 961 // from the script. |
| 962 Timer timer2(true, "Snapshot_test"); | 962 Timer timer2(true, "Snapshot_test"); |
| 963 timer2.Start(); | 963 timer2.Start(); |
| 964 TestCase::CreateTestIsolateFromSnapshot(buffer); | 964 TestCase::CreateTestIsolateFromSnapshot(buffer); |
| 965 { | 965 { |
| 966 Dart_EnterScope(); // Start a Dart API scope for invoking API functions. | 966 Dart_EnterScope(); // Start a Dart API scope for invoking API functions. |
| 967 timer2.Stop(); | 967 timer2.Stop(); |
| 968 OS::PrintErr("From Snapshot: %"Pd64"us\n", timer2.TotalElapsedTime()); | 968 OS::PrintErr("From Snapshot: %" Pd64 "us\n", timer2.TotalElapsedTime()); |
| 969 | 969 |
| 970 // Invoke a function which returns an object. | 970 // Invoke a function which returns an object. |
| 971 Dart_Handle cls = | 971 Dart_Handle cls = |
| 972 Dart_GetClass(TestCase::lib(), NewString("FieldsTest")); | 972 Dart_GetClass(TestCase::lib(), NewString("FieldsTest")); |
| 973 result = Dart_Invoke(cls, NewString("testMain"), 0, NULL); | 973 result = Dart_Invoke(cls, NewString("testMain"), 0, NULL); |
| 974 EXPECT_VALID(result); | 974 EXPECT_VALID(result); |
| 975 Dart_ExitScope(); | 975 Dart_ExitScope(); |
| 976 } | 976 } |
| 977 Dart_ShutdownIsolate(); | 977 Dart_ShutdownIsolate(); |
| 978 free(buffer); | 978 free(buffer); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 997 TestIsolateScope __test_isolate__; | 997 TestIsolateScope __test_isolate__; |
| 998 | 998 |
| 999 Isolate* isolate = Isolate::Current(); | 999 Isolate* isolate = Isolate::Current(); |
| 1000 StackZone zone(isolate); | 1000 StackZone zone(isolate); |
| 1001 HandleScope scope(isolate); | 1001 HandleScope scope(isolate); |
| 1002 | 1002 |
| 1003 // Create a test library and Load up a test script in it. | 1003 // Create a test library and Load up a test script in it. |
| 1004 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); | 1004 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); |
| 1005 EXPECT_VALID(Api::CheckIsolateState(isolate)); | 1005 EXPECT_VALID(Api::CheckIsolateState(isolate)); |
| 1006 timer1.Stop(); | 1006 timer1.Stop(); |
| 1007 OS::PrintErr("Without Snapshot: %"Pd64"us\n", timer1.TotalElapsedTime()); | 1007 OS::PrintErr("Without Snapshot: %" Pd64 "us\n", timer1.TotalElapsedTime()); |
| 1008 | 1008 |
| 1009 // Write snapshot with object content. | 1009 // Write snapshot with object content. |
| 1010 FullSnapshotWriter writer(&buffer, &malloc_allocator); | 1010 FullSnapshotWriter writer(&buffer, &malloc_allocator); |
| 1011 writer.WriteFullSnapshot(); | 1011 writer.WriteFullSnapshot(); |
| 1012 | 1012 |
| 1013 // Invoke a function which returns an object. | 1013 // Invoke a function which returns an object. |
| 1014 Dart_Handle cls = Dart_GetClass(lib, NewString("FieldsTest")); | 1014 Dart_Handle cls = Dart_GetClass(lib, NewString("FieldsTest")); |
| 1015 Dart_Handle result = Dart_Invoke(cls, NewString("testMain"), 0, NULL); | 1015 Dart_Handle result = Dart_Invoke(cls, NewString("testMain"), 0, NULL); |
| 1016 EXPECT_VALID(result); | 1016 EXPECT_VALID(result); |
| 1017 } | 1017 } |
| 1018 | 1018 |
| 1019 // Now Create another isolate using the snapshot and execute a method | 1019 // Now Create another isolate using the snapshot and execute a method |
| 1020 // from the script. | 1020 // from the script. |
| 1021 Timer timer2(true, "Snapshot_test"); | 1021 Timer timer2(true, "Snapshot_test"); |
| 1022 timer2.Start(); | 1022 timer2.Start(); |
| 1023 TestCase::CreateTestIsolateFromSnapshot(buffer); | 1023 TestCase::CreateTestIsolateFromSnapshot(buffer); |
| 1024 { | 1024 { |
| 1025 Dart_EnterScope(); // Start a Dart API scope for invoking API functions. | 1025 Dart_EnterScope(); // Start a Dart API scope for invoking API functions. |
| 1026 timer2.Stop(); | 1026 timer2.Stop(); |
| 1027 OS::PrintErr("From Snapshot: %"Pd64"us\n", timer2.TotalElapsedTime()); | 1027 OS::PrintErr("From Snapshot: %" Pd64 "us\n", timer2.TotalElapsedTime()); |
| 1028 | 1028 |
| 1029 // Invoke a function which returns an object. | 1029 // Invoke a function which returns an object. |
| 1030 Dart_Handle cls = Dart_GetClass(TestCase::lib(), | 1030 Dart_Handle cls = Dart_GetClass(TestCase::lib(), |
| 1031 NewString("FieldsTest")); | 1031 NewString("FieldsTest")); |
| 1032 Dart_Handle result = Dart_Invoke(cls, NewString("testMain"), 0, NULL); | 1032 Dart_Handle result = Dart_Invoke(cls, NewString("testMain"), 0, NULL); |
| 1033 if (Dart_IsError(result)) { | 1033 if (Dart_IsError(result)) { |
| 1034 // Print the error. It is probably an unhandled exception. | 1034 // Print the error. It is probably an unhandled exception. |
| 1035 fprintf(stderr, "%s\n", Dart_GetError(result)); | 1035 fprintf(stderr, "%s\n", Dart_GetError(result)); |
| 1036 } | 1036 } |
| 1037 EXPECT_VALID(result); | 1037 EXPECT_VALID(result); |
| (...skipping 1561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2599 result = Dart_RunLoop(); | 2599 result = Dart_RunLoop(); |
| 2600 EXPECT(Dart_IsError(result)); | 2600 EXPECT(Dart_IsError(result)); |
| 2601 EXPECT(Dart_ErrorHasException(result)); | 2601 EXPECT(Dart_ErrorHasException(result)); |
| 2602 EXPECT_SUBSTRING("Exception: nulltruefalse123456æøå3.14[]100123456789\n", | 2602 EXPECT_SUBSTRING("Exception: nulltruefalse123456æøå3.14[]100123456789\n", |
| 2603 Dart_GetError(result)); | 2603 Dart_GetError(result)); |
| 2604 | 2604 |
| 2605 Dart_ExitScope(); | 2605 Dart_ExitScope(); |
| 2606 } | 2606 } |
| 2607 | 2607 |
| 2608 } // namespace dart | 2608 } // namespace dart |
| OLD | NEW |