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/clustered_snapshot.h" | 10 #include "vm/clustered_snapshot.h" |
(...skipping 1176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1187 | 1187 |
1188 // Create a test library and Load up a test script in it. | 1188 // Create a test library and Load up a test script in it. |
1189 TestCase::LoadTestScript(kScriptChars, NULL); | 1189 TestCase::LoadTestScript(kScriptChars, NULL); |
1190 EXPECT_VALID(Api::CheckAndFinalizePendingClasses(thread)); | 1190 EXPECT_VALID(Api::CheckAndFinalizePendingClasses(thread)); |
1191 timer1.Stop(); | 1191 timer1.Stop(); |
1192 OS::PrintErr("Without Snapshot: %" Pd64 "us\n", timer1.TotalElapsedTime()); | 1192 OS::PrintErr("Without Snapshot: %" Pd64 "us\n", timer1.TotalElapsedTime()); |
1193 | 1193 |
1194 // Write snapshot with object content. | 1194 // Write snapshot with object content. |
1195 { | 1195 { |
1196 FullSnapshotWriter writer( | 1196 FullSnapshotWriter writer( |
1197 Snapshot::kCore, NULL, &isolate_snapshot_data_buffer, | 1197 Snapshot::kFull, NULL, &isolate_snapshot_data_buffer, |
1198 &malloc_allocator, NULL, NULL /* image_writer */); | 1198 &malloc_allocator, NULL, NULL /* image_writer */); |
1199 writer.WriteFullSnapshot(); | 1199 writer.WriteFullSnapshot(); |
1200 } | 1200 } |
1201 } | 1201 } |
1202 | 1202 |
1203 // Now Create another isolate using the snapshot and execute a method | 1203 // Now Create another isolate using the snapshot and execute a method |
1204 // from the script. | 1204 // from the script. |
1205 Timer timer2(true, "Snapshot_test"); | 1205 Timer timer2(true, "Snapshot_test"); |
1206 timer2.Start(); | 1206 timer2.Start(); |
1207 TestCase::CreateTestIsolateFromSnapshot(isolate_snapshot_data_buffer); | 1207 TestCase::CreateTestIsolateFromSnapshot(isolate_snapshot_data_buffer); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1244 | 1244 |
1245 // Create a test library and Load up a test script in it. | 1245 // Create a test library and Load up a test script in it. |
1246 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); | 1246 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); |
1247 EXPECT_VALID(Api::CheckAndFinalizePendingClasses(thread)); | 1247 EXPECT_VALID(Api::CheckAndFinalizePendingClasses(thread)); |
1248 timer1.Stop(); | 1248 timer1.Stop(); |
1249 OS::PrintErr("Without Snapshot: %" Pd64 "us\n", timer1.TotalElapsedTime()); | 1249 OS::PrintErr("Without Snapshot: %" Pd64 "us\n", timer1.TotalElapsedTime()); |
1250 | 1250 |
1251 // Write snapshot with object content. | 1251 // Write snapshot with object content. |
1252 { | 1252 { |
1253 FullSnapshotWriter writer( | 1253 FullSnapshotWriter writer( |
1254 Snapshot::kCore, NULL, &isolate_snapshot_data_buffer, | 1254 Snapshot::kFull, NULL, &isolate_snapshot_data_buffer, |
1255 &malloc_allocator, NULL, NULL /* image_writer */); | 1255 &malloc_allocator, NULL, NULL /* image_writer */); |
1256 writer.WriteFullSnapshot(); | 1256 writer.WriteFullSnapshot(); |
1257 } | 1257 } |
1258 | 1258 |
1259 // Invoke a function which returns an object. | 1259 // Invoke a function which returns an object. |
1260 Dart_Handle cls = Dart_GetClass(lib, NewString("FieldsTest")); | 1260 Dart_Handle cls = Dart_GetClass(lib, NewString("FieldsTest")); |
1261 Dart_Handle result = Dart_Invoke(cls, NewString("testMain"), 0, NULL); | 1261 Dart_Handle result = Dart_Invoke(cls, NewString("testMain"), 0, NULL); |
1262 EXPECT_VALID(result); | 1262 EXPECT_VALID(result); |
1263 } | 1263 } |
1264 | 1264 |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1668 | 1668 |
1669 { | 1669 { |
1670 // Use a script snapshot where a full snapshot is expected. | 1670 // Use a script snapshot where a full snapshot is expected. |
1671 char* error = NULL; | 1671 char* error = NULL; |
1672 Dart_Isolate isolate = Dart_CreateIsolate( | 1672 Dart_Isolate isolate = Dart_CreateIsolate( |
1673 "script-uri", "main", script_snapshot, NULL, NULL, NULL, &error); | 1673 "script-uri", "main", script_snapshot, NULL, NULL, NULL, &error); |
1674 EXPECT(isolate == NULL); | 1674 EXPECT(isolate == NULL); |
1675 EXPECT(error != NULL); | 1675 EXPECT(error != NULL); |
1676 EXPECT_SUBSTRING( | 1676 EXPECT_SUBSTRING( |
1677 "Incompatible snapshot kinds:" | 1677 "Incompatible snapshot kinds:" |
1678 " vm 'core', isolate 'script'", | 1678 " vm 'full', isolate 'script'", |
1679 error); | 1679 error); |
1680 free(error); | 1680 free(error); |
1681 } | 1681 } |
1682 | 1682 |
1683 { | 1683 { |
1684 TestCase::CreateTestIsolateFromSnapshot(full_snapshot); | 1684 TestCase::CreateTestIsolateFromSnapshot(full_snapshot); |
1685 Dart_EnterScope(); // Start a Dart API scope for invoking API functions. | 1685 Dart_EnterScope(); // Start a Dart API scope for invoking API functions. |
1686 | 1686 |
1687 // Use a full snapshot where a script snapshot is expected. | 1687 // Use a full snapshot where a script snapshot is expected. |
1688 Dart_Handle result = Dart_LoadScriptFromSnapshot(full_snapshot, size); | 1688 Dart_Handle result = Dart_LoadScriptFromSnapshot(full_snapshot, size); |
(...skipping 1323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3012 StackZone zone(Thread::Current()); | 3012 StackZone zone(Thread::Current()); |
3013 uint8_t* buffer; | 3013 uint8_t* buffer; |
3014 MessageWriter writer(&buffer, &zone_allocator, &zone_deallocator, true); | 3014 MessageWriter writer(&buffer, &zone_allocator, &zone_deallocator, true); |
3015 writer.WriteInlinedObjectHeader(kOmittedObjectId); | 3015 writer.WriteInlinedObjectHeader(kOmittedObjectId); |
3016 // For performance, we'd like single-byte headers when ids are omitted. | 3016 // For performance, we'd like single-byte headers when ids are omitted. |
3017 // If this starts failing, consider renumbering the snapshot ids. | 3017 // If this starts failing, consider renumbering the snapshot ids. |
3018 EXPECT_EQ(1, writer.BytesWritten()); | 3018 EXPECT_EQ(1, writer.BytesWritten()); |
3019 } | 3019 } |
3020 | 3020 |
3021 } // namespace dart | 3021 } // namespace dart |
OLD | NEW |