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 782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
793 | 793 |
794 // Start an Isolate, load a script and create a full snapshot. | 794 // Start an Isolate, load a script and create a full snapshot. |
795 Timer timer1(true, "Snapshot_test"); | 795 Timer timer1(true, "Snapshot_test"); |
796 timer1.Start(); | 796 timer1.Start(); |
797 { | 797 { |
798 TestIsolateScope __test_isolate__; | 798 TestIsolateScope __test_isolate__; |
799 | 799 |
800 // Create a test library and Load up a test script in it. | 800 // Create a test library and Load up a test script in it. |
801 TestCase::LoadTestScript(kScriptChars, NULL); | 801 TestCase::LoadTestScript(kScriptChars, NULL); |
802 timer1.Stop(); | 802 timer1.Stop(); |
803 OS::PrintErr("Without Snapshot: %dus\n", timer1.TotalElapsedTime()); | 803 OS::PrintErr("Without Snapshot: %"Pd64"us\n", timer1.TotalElapsedTime()); |
804 | 804 |
805 // Write snapshot with object content. | 805 // Write snapshot with object content. |
806 Isolate* isolate = Isolate::Current(); | 806 Isolate* isolate = Isolate::Current(); |
807 Zone zone(isolate); | 807 Zone zone(isolate); |
808 HandleScope scope(isolate); | 808 HandleScope scope(isolate); |
809 FullSnapshotWriter writer(&buffer, &malloc_allocator); | 809 FullSnapshotWriter writer(&buffer, &malloc_allocator); |
810 writer.WriteFullSnapshot(); | 810 writer.WriteFullSnapshot(); |
811 } | 811 } |
812 | 812 |
813 // Now Create another isolate using the snapshot and execute a method | 813 // Now Create another isolate using the snapshot and execute a method |
814 // from the script. | 814 // from the script. |
815 Timer timer2(true, "Snapshot_test"); | 815 Timer timer2(true, "Snapshot_test"); |
816 timer2.Start(); | 816 timer2.Start(); |
817 TestCase::CreateTestIsolateFromSnapshot(buffer); | 817 TestCase::CreateTestIsolateFromSnapshot(buffer); |
818 { | 818 { |
819 Dart_EnterScope(); // Start a Dart API scope for invoking API functions. | 819 Dart_EnterScope(); // Start a Dart API scope for invoking API functions. |
820 timer2.Stop(); | 820 timer2.Stop(); |
821 OS::PrintErr("From Snapshot: %dus\n", timer2.TotalElapsedTime()); | 821 OS::PrintErr("From Snapshot: %"Pd64"us\n", timer2.TotalElapsedTime()); |
822 | 822 |
823 // Invoke a function which returns an object. | 823 // Invoke a function which returns an object. |
824 Dart_Handle cls = | 824 Dart_Handle cls = |
825 Dart_GetClass(TestCase::lib(), Dart_NewString("FieldsTest")); | 825 Dart_GetClass(TestCase::lib(), Dart_NewString("FieldsTest")); |
826 result = Dart_Invoke(cls, Dart_NewString("testMain"), 0, NULL); | 826 result = Dart_Invoke(cls, Dart_NewString("testMain"), 0, NULL); |
827 EXPECT_VALID(result); | 827 EXPECT_VALID(result); |
828 Dart_ExitScope(); | 828 Dart_ExitScope(); |
829 } | 829 } |
830 Dart_ShutdownIsolate(); | 830 Dart_ShutdownIsolate(); |
831 free(buffer); | 831 free(buffer); |
(...skipping 18 matching lines...) Expand all Loading... |
850 TestIsolateScope __test_isolate__; | 850 TestIsolateScope __test_isolate__; |
851 | 851 |
852 Isolate* isolate = Isolate::Current(); | 852 Isolate* isolate = Isolate::Current(); |
853 Zone zone(isolate); | 853 Zone zone(isolate); |
854 HandleScope scope(isolate); | 854 HandleScope scope(isolate); |
855 | 855 |
856 // Create a test library and Load up a test script in it. | 856 // Create a test library and Load up a test script in it. |
857 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); | 857 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); |
858 ClassFinalizer::FinalizePendingClasses(); | 858 ClassFinalizer::FinalizePendingClasses(); |
859 timer1.Stop(); | 859 timer1.Stop(); |
860 OS::PrintErr("Without Snapshot: %dus\n", timer1.TotalElapsedTime()); | 860 OS::PrintErr("Without Snapshot: %"Pd64"us\n", timer1.TotalElapsedTime()); |
861 | 861 |
862 // Write snapshot with object content. | 862 // Write snapshot with object content. |
863 FullSnapshotWriter writer(&buffer, &malloc_allocator); | 863 FullSnapshotWriter writer(&buffer, &malloc_allocator); |
864 writer.WriteFullSnapshot(); | 864 writer.WriteFullSnapshot(); |
865 | 865 |
866 // Invoke a function which returns an object. | 866 // Invoke a function which returns an object. |
867 Dart_Handle cls = Dart_GetClass(lib, Dart_NewString("FieldsTest")); | 867 Dart_Handle cls = Dart_GetClass(lib, Dart_NewString("FieldsTest")); |
868 Dart_Handle result = Dart_Invoke(cls, Dart_NewString("testMain"), 0, NULL); | 868 Dart_Handle result = Dart_Invoke(cls, Dart_NewString("testMain"), 0, NULL); |
869 EXPECT_VALID(result); | 869 EXPECT_VALID(result); |
870 } | 870 } |
871 | 871 |
872 // Now Create another isolate using the snapshot and execute a method | 872 // Now Create another isolate using the snapshot and execute a method |
873 // from the script. | 873 // from the script. |
874 Timer timer2(true, "Snapshot_test"); | 874 Timer timer2(true, "Snapshot_test"); |
875 timer2.Start(); | 875 timer2.Start(); |
876 TestCase::CreateTestIsolateFromSnapshot(buffer); | 876 TestCase::CreateTestIsolateFromSnapshot(buffer); |
877 { | 877 { |
878 Dart_EnterScope(); // Start a Dart API scope for invoking API functions. | 878 Dart_EnterScope(); // Start a Dart API scope for invoking API functions. |
879 timer2.Stop(); | 879 timer2.Stop(); |
880 OS::PrintErr("From Snapshot: %dus\n", timer2.TotalElapsedTime()); | 880 OS::PrintErr("From Snapshot: %"Pd64"us\n", timer2.TotalElapsedTime()); |
881 | 881 |
882 // Invoke a function which returns an object. | 882 // Invoke a function which returns an object. |
883 Dart_Handle cls = Dart_GetClass(TestCase::lib(), | 883 Dart_Handle cls = Dart_GetClass(TestCase::lib(), |
884 Dart_NewString("FieldsTest")); | 884 Dart_NewString("FieldsTest")); |
885 Dart_Handle result = Dart_Invoke(cls, Dart_NewString("testMain"), 0, NULL); | 885 Dart_Handle result = Dart_Invoke(cls, Dart_NewString("testMain"), 0, NULL); |
886 if (Dart_IsError(result)) { | 886 if (Dart_IsError(result)) { |
887 // Print the error. It is probably an unhandled exception. | 887 // Print the error. It is probably an unhandled exception. |
888 fprintf(stderr, "%s\n", Dart_GetError(result)); | 888 fprintf(stderr, "%s\n", Dart_GetError(result)); |
889 } | 889 } |
890 EXPECT_VALID(result); | 890 EXPECT_VALID(result); |
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1522 EXPECT(Dart_ErrorHasException(result)); | 1522 EXPECT(Dart_ErrorHasException(result)); |
1523 EXPECT_SUBSTRING("Exception: nulltruefalse1234563.14[]100123456789\n", | 1523 EXPECT_SUBSTRING("Exception: nulltruefalse1234563.14[]100123456789\n", |
1524 Dart_GetError(result)); | 1524 Dart_GetError(result)); |
1525 | 1525 |
1526 Dart_ExitScope(); | 1526 Dart_ExitScope(); |
1527 } | 1527 } |
1528 | 1528 |
1529 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). | 1529 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). |
1530 | 1530 |
1531 } // namespace dart | 1531 } // namespace dart |
OLD | NEW |