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_tools_api.h" | 7 #include "include/dart_tools_api.h" |
8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
9 #include "vm/class_finalizer.h" | 9 #include "vm/class_finalizer.h" |
10 #include "vm/dart_api_impl.h" | 10 #include "vm/dart_api_impl.h" |
(...skipping 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1067 | 1067 |
1068 { | 1068 { |
1069 // Create an Isolate using the full snapshot, load a script and create | 1069 // Create an Isolate using the full snapshot, load a script and create |
1070 // a script snapshot of the script. | 1070 // a script snapshot of the script. |
1071 TestCase::CreateTestIsolateFromSnapshot(full_snapshot); | 1071 TestCase::CreateTestIsolateFromSnapshot(full_snapshot); |
1072 Dart_EnterScope(); // Start a Dart API scope for invoking API functions. | 1072 Dart_EnterScope(); // Start a Dart API scope for invoking API functions. |
1073 | 1073 |
1074 // Create a test library and Load up a test script in it. | 1074 // Create a test library and Load up a test script in it. |
1075 TestCase::LoadTestScript(kScriptChars, NULL); | 1075 TestCase::LoadTestScript(kScriptChars, NULL); |
1076 | 1076 |
1077 EXPECT_VALID(Api::CheckAndFinalizePendingClasses(Isolate::Current())); | 1077 EXPECT_VALID(Api::CheckAndFinalizePendingClasses(Thread::Current())); |
1078 | 1078 |
1079 // Write out the script snapshot. | 1079 // Write out the script snapshot. |
1080 result = Dart_CreateScriptSnapshot(&buffer, &size); | 1080 result = Dart_CreateScriptSnapshot(&buffer, &size); |
1081 EXPECT_VALID(result); | 1081 EXPECT_VALID(result); |
1082 script_snapshot = reinterpret_cast<uint8_t*>(malloc(size)); | 1082 script_snapshot = reinterpret_cast<uint8_t*>(malloc(size)); |
1083 memmove(script_snapshot, buffer, size); | 1083 memmove(script_snapshot, buffer, size); |
1084 Dart_ExitScope(); | 1084 Dart_ExitScope(); |
1085 Dart_ShutdownIsolate(); | 1085 Dart_ShutdownIsolate(); |
1086 } | 1086 } |
1087 | 1087 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1170 timer1.Start(); | 1170 timer1.Start(); |
1171 { | 1171 { |
1172 TestIsolateScope __test_isolate__; | 1172 TestIsolateScope __test_isolate__; |
1173 | 1173 |
1174 Thread* thread = Thread::Current(); | 1174 Thread* thread = Thread::Current(); |
1175 StackZone zone(thread); | 1175 StackZone zone(thread); |
1176 HandleScope scope(thread); | 1176 HandleScope scope(thread); |
1177 | 1177 |
1178 // Create a test library and Load up a test script in it. | 1178 // Create a test library and Load up a test script in it. |
1179 TestCase::LoadTestScript(kScriptChars, NULL); | 1179 TestCase::LoadTestScript(kScriptChars, NULL); |
1180 EXPECT_VALID(Api::CheckAndFinalizePendingClasses(thread->isolate())); | 1180 EXPECT_VALID(Api::CheckAndFinalizePendingClasses(thread)); |
1181 timer1.Stop(); | 1181 timer1.Stop(); |
1182 OS::PrintErr("Without Snapshot: %" Pd64 "us\n", timer1.TotalElapsedTime()); | 1182 OS::PrintErr("Without Snapshot: %" Pd64 "us\n", timer1.TotalElapsedTime()); |
1183 | 1183 |
1184 // Write snapshot with object content. | 1184 // Write snapshot with object content. |
1185 { | 1185 { |
1186 FullSnapshotWriter writer(NULL, | 1186 FullSnapshotWriter writer(NULL, |
1187 &isolate_snapshot_buffer, | 1187 &isolate_snapshot_buffer, |
1188 NULL, /* instructions_snapshot_buffer */ | 1188 NULL, /* instructions_snapshot_buffer */ |
1189 &malloc_allocator, | 1189 &malloc_allocator, |
1190 false, /* snapshot_code */ | 1190 false, /* snapshot_code */ |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1231 timer1.Start(); | 1231 timer1.Start(); |
1232 { | 1232 { |
1233 TestIsolateScope __test_isolate__; | 1233 TestIsolateScope __test_isolate__; |
1234 | 1234 |
1235 Thread* thread = Thread::Current(); | 1235 Thread* thread = Thread::Current(); |
1236 StackZone zone(thread); | 1236 StackZone zone(thread); |
1237 HandleScope scope(thread); | 1237 HandleScope scope(thread); |
1238 | 1238 |
1239 // Create a test library and Load up a test script in it. | 1239 // Create a test library and Load up a test script in it. |
1240 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); | 1240 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); |
1241 EXPECT_VALID(Api::CheckAndFinalizePendingClasses(thread->isolate())); | 1241 EXPECT_VALID(Api::CheckAndFinalizePendingClasses(thread)); |
1242 timer1.Stop(); | 1242 timer1.Stop(); |
1243 OS::PrintErr("Without Snapshot: %" Pd64 "us\n", timer1.TotalElapsedTime()); | 1243 OS::PrintErr("Without Snapshot: %" Pd64 "us\n", timer1.TotalElapsedTime()); |
1244 | 1244 |
1245 // Write snapshot with object content. | 1245 // Write snapshot with object content. |
1246 { | 1246 { |
1247 FullSnapshotWriter writer(NULL, | 1247 FullSnapshotWriter writer(NULL, |
1248 &isolate_snapshot_buffer, | 1248 &isolate_snapshot_buffer, |
1249 NULL, /* instructions_snapshot_buffer */ | 1249 NULL, /* instructions_snapshot_buffer */ |
1250 &malloc_allocator, | 1250 &malloc_allocator, |
1251 false, /* snapshot_code */ | 1251 false, /* snapshot_code */ |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1375 NewString(kLibScriptChars), | 1375 NewString(kLibScriptChars), |
1376 0, 0); | 1376 0, 0); |
1377 EXPECT_VALID(import_lib); | 1377 EXPECT_VALID(import_lib); |
1378 | 1378 |
1379 // Create a test library and Load up a test script in it. | 1379 // Create a test library and Load up a test script in it. |
1380 TestCase::LoadTestScript(kScriptChars, NULL); | 1380 TestCase::LoadTestScript(kScriptChars, NULL); |
1381 | 1381 |
1382 EXPECT_VALID(Dart_LibraryImportLibrary(TestCase::lib(), | 1382 EXPECT_VALID(Dart_LibraryImportLibrary(TestCase::lib(), |
1383 import_lib, | 1383 import_lib, |
1384 Dart_Null())); | 1384 Dart_Null())); |
1385 EXPECT_VALID(Api::CheckAndFinalizePendingClasses(Isolate::Current())); | 1385 EXPECT_VALID(Api::CheckAndFinalizePendingClasses(Thread::Current())); |
1386 | 1386 |
1387 // Get list of library URLs loaded and save the count. | 1387 // Get list of library URLs loaded and save the count. |
1388 Dart_Handle libs = Dart_GetLibraryIds(); | 1388 Dart_Handle libs = Dart_GetLibraryIds(); |
1389 EXPECT(Dart_IsList(libs)); | 1389 EXPECT(Dart_IsList(libs)); |
1390 Dart_ListLength(libs, &expected_num_libs); | 1390 Dart_ListLength(libs, &expected_num_libs); |
1391 | 1391 |
1392 // Write out the script snapshot. | 1392 // Write out the script snapshot. |
1393 result = Dart_CreateScriptSnapshot(&buffer, &size); | 1393 result = Dart_CreateScriptSnapshot(&buffer, &size); |
1394 EXPECT_VALID(result); | 1394 EXPECT_VALID(result); |
1395 script_snapshot = reinterpret_cast<uint8_t*>(malloc(size)); | 1395 script_snapshot = reinterpret_cast<uint8_t*>(malloc(size)); |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1611 NewString(kLibScriptChars), | 1611 NewString(kLibScriptChars), |
1612 0, 0); | 1612 0, 0); |
1613 EXPECT_VALID(import_lib); | 1613 EXPECT_VALID(import_lib); |
1614 | 1614 |
1615 // Create a test library and Load up a test script in it. | 1615 // Create a test library and Load up a test script in it. |
1616 TestCase::LoadTestScript(kScriptChars, NULL); | 1616 TestCase::LoadTestScript(kScriptChars, NULL); |
1617 | 1617 |
1618 EXPECT_VALID(Dart_LibraryImportLibrary(TestCase::lib(), | 1618 EXPECT_VALID(Dart_LibraryImportLibrary(TestCase::lib(), |
1619 import_lib, | 1619 import_lib, |
1620 Dart_Null())); | 1620 Dart_Null())); |
1621 EXPECT_VALID(Api::CheckAndFinalizePendingClasses(Isolate::Current())); | 1621 EXPECT_VALID(Api::CheckAndFinalizePendingClasses(Thread::Current())); |
1622 | 1622 |
1623 // Write out the script snapshot. | 1623 // Write out the script snapshot. |
1624 result = Dart_CreateScriptSnapshot(&buffer, &size); | 1624 result = Dart_CreateScriptSnapshot(&buffer, &size); |
1625 EXPECT_VALID(result); | 1625 EXPECT_VALID(result); |
1626 script_snapshot = reinterpret_cast<uint8_t*>(malloc(size)); | 1626 script_snapshot = reinterpret_cast<uint8_t*>(malloc(size)); |
1627 memmove(script_snapshot, buffer, size); | 1627 memmove(script_snapshot, buffer, size); |
1628 Dart_ExitScope(); | 1628 Dart_ExitScope(); |
1629 Dart_ShutdownIsolate(); | 1629 Dart_ShutdownIsolate(); |
1630 } | 1630 } |
1631 | 1631 |
(...skipping 1366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2998 StackZone zone(Thread::Current()); | 2998 StackZone zone(Thread::Current()); |
2999 uint8_t* buffer; | 2999 uint8_t* buffer; |
3000 MessageWriter writer(&buffer, &zone_allocator, true); | 3000 MessageWriter writer(&buffer, &zone_allocator, true); |
3001 writer.WriteInlinedObjectHeader(kOmittedObjectId); | 3001 writer.WriteInlinedObjectHeader(kOmittedObjectId); |
3002 // For performance, we'd like single-byte headers when ids are omitted. | 3002 // For performance, we'd like single-byte headers when ids are omitted. |
3003 // If this starts failing, consider renumbering the snapshot ids. | 3003 // If this starts failing, consider renumbering the snapshot ids. |
3004 EXPECT_EQ(1, writer.BytesWritten()); | 3004 EXPECT_EQ(1, writer.BytesWritten()); |
3005 } | 3005 } |
3006 | 3006 |
3007 } // namespace dart | 3007 } // namespace dart |
OLD | NEW |