| 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 "platform/globals.h" | 5 #include "platform/globals.h" |
| 6 | 6 |
| 7 #include "include/dart_debugger_api.h" | 7 #include "include/dart_debugger_api.h" |
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "vm/bigint_operations.h" | 9 #include "vm/bigint_operations.h" |
| 10 #include "vm/class_finalizer.h" | 10 #include "vm/class_finalizer.h" |
| (...skipping 1021 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1032 timer1.Start(); | 1032 timer1.Start(); |
| 1033 { | 1033 { |
| 1034 TestIsolateScope __test_isolate__; | 1034 TestIsolateScope __test_isolate__; |
| 1035 | 1035 |
| 1036 Isolate* isolate = Isolate::Current(); | 1036 Isolate* isolate = Isolate::Current(); |
| 1037 StackZone zone(isolate); | 1037 StackZone zone(isolate); |
| 1038 HandleScope scope(isolate); | 1038 HandleScope scope(isolate); |
| 1039 | 1039 |
| 1040 // Create a test library and Load up a test script in it. | 1040 // Create a test library and Load up a test script in it. |
| 1041 TestCase::LoadTestScript(kScriptChars, NULL); | 1041 TestCase::LoadTestScript(kScriptChars, NULL); |
| 1042 EXPECT_VALID(Api::CheckIsolateState(isolate)); | 1042 EXPECT_VALID(Api::CheckAndFinalizePendingClasses(isolate)); |
| 1043 timer1.Stop(); | 1043 timer1.Stop(); |
| 1044 OS::PrintErr("Without Snapshot: %" Pd64 "us\n", timer1.TotalElapsedTime()); | 1044 OS::PrintErr("Without Snapshot: %" Pd64 "us\n", timer1.TotalElapsedTime()); |
| 1045 | 1045 |
| 1046 // Write snapshot with object content. | 1046 // Write snapshot with object content. |
| 1047 FullSnapshotWriter writer(&buffer, &malloc_allocator); | 1047 FullSnapshotWriter writer(&buffer, &malloc_allocator); |
| 1048 writer.WriteFullSnapshot(); | 1048 writer.WriteFullSnapshot(); |
| 1049 } | 1049 } |
| 1050 | 1050 |
| 1051 // Now Create another isolate using the snapshot and execute a method | 1051 // Now Create another isolate using the snapshot and execute a method |
| 1052 // from the script. | 1052 // from the script. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1086 timer1.Start(); | 1086 timer1.Start(); |
| 1087 { | 1087 { |
| 1088 TestIsolateScope __test_isolate__; | 1088 TestIsolateScope __test_isolate__; |
| 1089 | 1089 |
| 1090 Isolate* isolate = Isolate::Current(); | 1090 Isolate* isolate = Isolate::Current(); |
| 1091 StackZone zone(isolate); | 1091 StackZone zone(isolate); |
| 1092 HandleScope scope(isolate); | 1092 HandleScope scope(isolate); |
| 1093 | 1093 |
| 1094 // Create a test library and Load up a test script in it. | 1094 // Create a test library and Load up a test script in it. |
| 1095 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); | 1095 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); |
| 1096 EXPECT_VALID(Api::CheckIsolateState(isolate)); | 1096 EXPECT_VALID(Api::CheckAndFinalizePendingClasses(isolate)); |
| 1097 timer1.Stop(); | 1097 timer1.Stop(); |
| 1098 OS::PrintErr("Without Snapshot: %" Pd64 "us\n", timer1.TotalElapsedTime()); | 1098 OS::PrintErr("Without Snapshot: %" Pd64 "us\n", timer1.TotalElapsedTime()); |
| 1099 | 1099 |
| 1100 // Write snapshot with object content. | 1100 // Write snapshot with object content. |
| 1101 FullSnapshotWriter writer(&buffer, &malloc_allocator); | 1101 FullSnapshotWriter writer(&buffer, &malloc_allocator); |
| 1102 writer.WriteFullSnapshot(); | 1102 writer.WriteFullSnapshot(); |
| 1103 | 1103 |
| 1104 // Invoke a function which returns an object. | 1104 // Invoke a function which returns an object. |
| 1105 Dart_Handle cls = Dart_GetClass(lib, NewString("FieldsTest")); | 1105 Dart_Handle cls = Dart_GetClass(lib, NewString("FieldsTest")); |
| 1106 Dart_Handle result = Dart_Invoke(cls, NewString("testMain"), 0, NULL); | 1106 Dart_Handle result = Dart_Invoke(cls, NewString("testMain"), 0, NULL); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1207 Dart_Handle import_lib = Dart_LoadLibrary(NewString("dart_import_lib"), | 1207 Dart_Handle import_lib = Dart_LoadLibrary(NewString("dart_import_lib"), |
| 1208 NewString(kLibScriptChars)); | 1208 NewString(kLibScriptChars)); |
| 1209 EXPECT_VALID(import_lib); | 1209 EXPECT_VALID(import_lib); |
| 1210 | 1210 |
| 1211 // Create a test library and Load up a test script in it. | 1211 // Create a test library and Load up a test script in it. |
| 1212 TestCase::LoadTestScript(kScriptChars, NULL); | 1212 TestCase::LoadTestScript(kScriptChars, NULL); |
| 1213 | 1213 |
| 1214 EXPECT_VALID(Dart_LibraryImportLibrary(TestCase::lib(), | 1214 EXPECT_VALID(Dart_LibraryImportLibrary(TestCase::lib(), |
| 1215 import_lib, | 1215 import_lib, |
| 1216 Dart_Null())); | 1216 Dart_Null())); |
| 1217 EXPECT_VALID(Api::CheckIsolateState(Isolate::Current())); | 1217 EXPECT_VALID(Api::CheckAndFinalizePendingClasses(Isolate::Current())); |
| 1218 | 1218 |
| 1219 // Get list of library URLs loaded and save the count. | 1219 // Get list of library URLs loaded and save the count. |
| 1220 Dart_Handle libs = Dart_GetLibraryIds(); | 1220 Dart_Handle libs = Dart_GetLibraryIds(); |
| 1221 EXPECT(Dart_IsList(libs)); | 1221 EXPECT(Dart_IsList(libs)); |
| 1222 Dart_ListLength(libs, &expected_num_libs); | 1222 Dart_ListLength(libs, &expected_num_libs); |
| 1223 | 1223 |
| 1224 // Write out the script snapshot. | 1224 // Write out the script snapshot. |
| 1225 result = Dart_CreateScriptSnapshot(&buffer, &size); | 1225 result = Dart_CreateScriptSnapshot(&buffer, &size); |
| 1226 EXPECT_VALID(result); | 1226 EXPECT_VALID(result); |
| 1227 script_snapshot = reinterpret_cast<uint8_t*>(malloc(size)); | 1227 script_snapshot = reinterpret_cast<uint8_t*>(malloc(size)); |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1377 Dart_Handle import_lib = Dart_LoadLibrary(NewString("dart_import_lib"), | 1377 Dart_Handle import_lib = Dart_LoadLibrary(NewString("dart_import_lib"), |
| 1378 NewString(kLibScriptChars)); | 1378 NewString(kLibScriptChars)); |
| 1379 EXPECT_VALID(import_lib); | 1379 EXPECT_VALID(import_lib); |
| 1380 | 1380 |
| 1381 // Create a test library and Load up a test script in it. | 1381 // Create a test library and Load up a test script in it. |
| 1382 TestCase::LoadTestScript(kScriptChars, NULL); | 1382 TestCase::LoadTestScript(kScriptChars, NULL); |
| 1383 | 1383 |
| 1384 EXPECT_VALID(Dart_LibraryImportLibrary(TestCase::lib(), | 1384 EXPECT_VALID(Dart_LibraryImportLibrary(TestCase::lib(), |
| 1385 import_lib, | 1385 import_lib, |
| 1386 Dart_Null())); | 1386 Dart_Null())); |
| 1387 EXPECT_VALID(Api::CheckIsolateState(Isolate::Current())); | 1387 EXPECT_VALID(Api::CheckAndFinalizePendingClasses(Isolate::Current())); |
| 1388 | 1388 |
| 1389 // Write out the script snapshot. | 1389 // Write out the script snapshot. |
| 1390 result = Dart_CreateScriptSnapshot(&buffer, &size); | 1390 result = Dart_CreateScriptSnapshot(&buffer, &size); |
| 1391 EXPECT_VALID(result); | 1391 EXPECT_VALID(result); |
| 1392 script_snapshot = reinterpret_cast<uint8_t*>(malloc(size)); | 1392 script_snapshot = reinterpret_cast<uint8_t*>(malloc(size)); |
| 1393 memmove(script_snapshot, buffer, size); | 1393 memmove(script_snapshot, buffer, size); |
| 1394 Dart_ExitScope(); | 1394 Dart_ExitScope(); |
| 1395 Dart_ShutdownIsolate(); | 1395 Dart_ShutdownIsolate(); |
| 1396 } | 1396 } |
| 1397 | 1397 |
| (...skipping 1324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2722 StackZone zone(Isolate::Current()); | 2722 StackZone zone(Isolate::Current()); |
| 2723 uint8_t* buffer; | 2723 uint8_t* buffer; |
| 2724 MessageWriter writer(&buffer, &zone_allocator); | 2724 MessageWriter writer(&buffer, &zone_allocator); |
| 2725 writer.WriteInlinedObjectHeader(kOmittedObjectId); | 2725 writer.WriteInlinedObjectHeader(kOmittedObjectId); |
| 2726 // For performance, we'd like single-byte headers when ids are omitted. | 2726 // For performance, we'd like single-byte headers when ids are omitted. |
| 2727 // If this starts failing, consider renumbering the snapshot ids. | 2727 // If this starts failing, consider renumbering the snapshot ids. |
| 2728 EXPECT_EQ(1, writer.BytesWritten()); | 2728 EXPECT_EQ(1, writer.BytesWritten()); |
| 2729 } | 2729 } |
| 2730 | 2730 |
| 2731 } // namespace dart | 2731 } // namespace dart |
| OLD | NEW |