| 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 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 922 Dart_Handle result; | 922 Dart_Handle result; |
| 923 | 923 |
| 924 uint8_t* buffer; | 924 uint8_t* buffer; |
| 925 | 925 |
| 926 // Start an Isolate, load a script and create a full snapshot. | 926 // Start an Isolate, load a script and create a full snapshot. |
| 927 Timer timer1(true, "Snapshot_test"); | 927 Timer timer1(true, "Snapshot_test"); |
| 928 timer1.Start(); | 928 timer1.Start(); |
| 929 { | 929 { |
| 930 TestIsolateScope __test_isolate__; | 930 TestIsolateScope __test_isolate__; |
| 931 | 931 |
| 932 Isolate* isolate = Isolate::Current(); |
| 933 StackZone zone(isolate); |
| 934 HandleScope scope(isolate); |
| 935 |
| 932 // Create a test library and Load up a test script in it. | 936 // Create a test library and Load up a test script in it. |
| 933 TestCase::LoadTestScript(kScriptChars, NULL); | 937 TestCase::LoadTestScript(kScriptChars, NULL); |
| 938 EXPECT_VALID(Api::CheckIsolateState(isolate)); |
| 934 timer1.Stop(); | 939 timer1.Stop(); |
| 935 OS::PrintErr("Without Snapshot: %"Pd64"us\n", timer1.TotalElapsedTime()); | 940 OS::PrintErr("Without Snapshot: %"Pd64"us\n", timer1.TotalElapsedTime()); |
| 936 | 941 |
| 937 // Write snapshot with object content. | 942 // Write snapshot with object content. |
| 938 Isolate* isolate = Isolate::Current(); | |
| 939 StackZone zone(isolate); | |
| 940 HandleScope scope(isolate); | |
| 941 FullSnapshotWriter writer(&buffer, &malloc_allocator); | 943 FullSnapshotWriter writer(&buffer, &malloc_allocator); |
| 942 writer.WriteFullSnapshot(); | 944 writer.WriteFullSnapshot(); |
| 943 } | 945 } |
| 944 | 946 |
| 945 // Now Create another isolate using the snapshot and execute a method | 947 // Now Create another isolate using the snapshot and execute a method |
| 946 // from the script. | 948 // from the script. |
| 947 Timer timer2(true, "Snapshot_test"); | 949 Timer timer2(true, "Snapshot_test"); |
| 948 timer2.Start(); | 950 timer2.Start(); |
| 949 TestCase::CreateTestIsolateFromSnapshot(buffer); | 951 TestCase::CreateTestIsolateFromSnapshot(buffer); |
| 950 { | 952 { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 980 timer1.Start(); | 982 timer1.Start(); |
| 981 { | 983 { |
| 982 TestIsolateScope __test_isolate__; | 984 TestIsolateScope __test_isolate__; |
| 983 | 985 |
| 984 Isolate* isolate = Isolate::Current(); | 986 Isolate* isolate = Isolate::Current(); |
| 985 StackZone zone(isolate); | 987 StackZone zone(isolate); |
| 986 HandleScope scope(isolate); | 988 HandleScope scope(isolate); |
| 987 | 989 |
| 988 // Create a test library and Load up a test script in it. | 990 // Create a test library and Load up a test script in it. |
| 989 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); | 991 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); |
| 990 ClassFinalizer::FinalizePendingClasses(); | 992 EXPECT_VALID(Api::CheckIsolateState(isolate)); |
| 991 timer1.Stop(); | 993 timer1.Stop(); |
| 992 OS::PrintErr("Without Snapshot: %"Pd64"us\n", timer1.TotalElapsedTime()); | 994 OS::PrintErr("Without Snapshot: %"Pd64"us\n", timer1.TotalElapsedTime()); |
| 993 | 995 |
| 994 // Write snapshot with object content. | 996 // Write snapshot with object content. |
| 995 FullSnapshotWriter writer(&buffer, &malloc_allocator); | 997 FullSnapshotWriter writer(&buffer, &malloc_allocator); |
| 996 writer.WriteFullSnapshot(); | 998 writer.WriteFullSnapshot(); |
| 997 | 999 |
| 998 // Invoke a function which returns an object. | 1000 // Invoke a function which returns an object. |
| 999 Dart_Handle cls = Dart_GetClass(lib, NewString("FieldsTest")); | 1001 Dart_Handle cls = Dart_GetClass(lib, NewString("FieldsTest")); |
| 1000 Dart_Handle result = Dart_Invoke(cls, NewString("testMain"), 0, NULL); | 1002 Dart_Handle result = Dart_Invoke(cls, NewString("testMain"), 0, NULL); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1097 Dart_Handle import_lib = Dart_LoadLibrary(NewString("dart_import_lib"), | 1099 Dart_Handle import_lib = Dart_LoadLibrary(NewString("dart_import_lib"), |
| 1098 NewString(kLibScriptChars)); | 1100 NewString(kLibScriptChars)); |
| 1099 EXPECT_VALID(import_lib); | 1101 EXPECT_VALID(import_lib); |
| 1100 | 1102 |
| 1101 // Create a test library and Load up a test script in it. | 1103 // Create a test library and Load up a test script in it. |
| 1102 TestCase::LoadTestScript(kScriptChars, NULL); | 1104 TestCase::LoadTestScript(kScriptChars, NULL); |
| 1103 | 1105 |
| 1104 EXPECT_VALID(Dart_LibraryImportLibrary(TestCase::lib(), | 1106 EXPECT_VALID(Dart_LibraryImportLibrary(TestCase::lib(), |
| 1105 import_lib, | 1107 import_lib, |
| 1106 Dart_Null())); | 1108 Dart_Null())); |
| 1109 EXPECT_VALID(Api::CheckIsolateState(Isolate::Current())); |
| 1107 | 1110 |
| 1108 // Get list of library URLs loaded and save the count. | 1111 // Get list of library URLs loaded and save the count. |
| 1109 Dart_Handle libs = Dart_GetLibraryURLs(); | 1112 Dart_Handle libs = Dart_GetLibraryURLs(); |
| 1110 EXPECT(Dart_IsList(libs)); | 1113 EXPECT(Dart_IsList(libs)); |
| 1111 Dart_ListLength(libs, &expected_num_libs); | 1114 Dart_ListLength(libs, &expected_num_libs); |
| 1112 | 1115 |
| 1113 // Write out the script snapshot. | 1116 // Write out the script snapshot. |
| 1114 result = Dart_CreateScriptSnapshot(&buffer, &size); | 1117 result = Dart_CreateScriptSnapshot(&buffer, &size); |
| 1115 EXPECT_VALID(result); | 1118 EXPECT_VALID(result); |
| 1116 script_snapshot = reinterpret_cast<uint8_t*>(malloc(size)); | 1119 script_snapshot = reinterpret_cast<uint8_t*>(malloc(size)); |
| (...skipping 1079 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2196 EXPECT(Dart_ErrorHasException(result)); | 2199 EXPECT(Dart_ErrorHasException(result)); |
| 2197 EXPECT_SUBSTRING("Exception: nulltruefalse123456æøå3.14[]100123456789\n", | 2200 EXPECT_SUBSTRING("Exception: nulltruefalse123456æøå3.14[]100123456789\n", |
| 2198 Dart_GetError(result)); | 2201 Dart_GetError(result)); |
| 2199 | 2202 |
| 2200 Dart_ExitScope(); | 2203 Dart_ExitScope(); |
| 2201 } | 2204 } |
| 2202 | 2205 |
| 2203 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). | 2206 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). |
| 2204 | 2207 |
| 2205 } // namespace dart | 2208 } // namespace dart |
| OLD | NEW |