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 1168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1179 // Create a test library and Load up a test script in it. | 1179 // Create a test library and Load up a test script in it. |
1180 TestCase::LoadTestScript(kScriptChars, NULL); | 1180 TestCase::LoadTestScript(kScriptChars, NULL); |
1181 EXPECT_VALID(Api::CheckAndFinalizePendingClasses(thread)); | 1181 EXPECT_VALID(Api::CheckAndFinalizePendingClasses(thread)); |
1182 timer1.Stop(); | 1182 timer1.Stop(); |
1183 OS::PrintErr("Without Snapshot: %" Pd64 "us\n", timer1.TotalElapsedTime()); | 1183 OS::PrintErr("Without Snapshot: %" Pd64 "us\n", timer1.TotalElapsedTime()); |
1184 | 1184 |
1185 // Write snapshot with object content. | 1185 // Write snapshot with object content. |
1186 { | 1186 { |
1187 FullSnapshotWriter writer( | 1187 FullSnapshotWriter writer( |
1188 Snapshot::kCore, NULL, &isolate_snapshot_data_buffer, | 1188 Snapshot::kCore, NULL, &isolate_snapshot_data_buffer, |
1189 &malloc_allocator, NULL, NULL /* instructions_writer */); | 1189 &malloc_allocator, NULL, NULL /* image_writer */); |
1190 writer.WriteFullSnapshot(); | 1190 writer.WriteFullSnapshot(); |
1191 } | 1191 } |
1192 } | 1192 } |
1193 | 1193 |
1194 // Now Create another isolate using the snapshot and execute a method | 1194 // Now Create another isolate using the snapshot and execute a method |
1195 // from the script. | 1195 // from the script. |
1196 Timer timer2(true, "Snapshot_test"); | 1196 Timer timer2(true, "Snapshot_test"); |
1197 timer2.Start(); | 1197 timer2.Start(); |
1198 TestCase::CreateTestIsolateFromSnapshot(isolate_snapshot_data_buffer); | 1198 TestCase::CreateTestIsolateFromSnapshot(isolate_snapshot_data_buffer); |
1199 { | 1199 { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1236 // Create a test library and Load up a test script in it. | 1236 // Create a test library and Load up a test script in it. |
1237 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); | 1237 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); |
1238 EXPECT_VALID(Api::CheckAndFinalizePendingClasses(thread)); | 1238 EXPECT_VALID(Api::CheckAndFinalizePendingClasses(thread)); |
1239 timer1.Stop(); | 1239 timer1.Stop(); |
1240 OS::PrintErr("Without Snapshot: %" Pd64 "us\n", timer1.TotalElapsedTime()); | 1240 OS::PrintErr("Without Snapshot: %" Pd64 "us\n", timer1.TotalElapsedTime()); |
1241 | 1241 |
1242 // Write snapshot with object content. | 1242 // Write snapshot with object content. |
1243 { | 1243 { |
1244 FullSnapshotWriter writer( | 1244 FullSnapshotWriter writer( |
1245 Snapshot::kCore, NULL, &isolate_snapshot_data_buffer, | 1245 Snapshot::kCore, NULL, &isolate_snapshot_data_buffer, |
1246 &malloc_allocator, NULL, NULL /* instructions_writer */); | 1246 &malloc_allocator, NULL, NULL /* image_writer */); |
1247 writer.WriteFullSnapshot(); | 1247 writer.WriteFullSnapshot(); |
1248 } | 1248 } |
1249 | 1249 |
1250 // Invoke a function which returns an object. | 1250 // Invoke a function which returns an object. |
1251 Dart_Handle cls = Dart_GetClass(lib, NewString("FieldsTest")); | 1251 Dart_Handle cls = Dart_GetClass(lib, NewString("FieldsTest")); |
1252 Dart_Handle result = Dart_Invoke(cls, NewString("testMain"), 0, NULL); | 1252 Dart_Handle result = Dart_Invoke(cls, NewString("testMain"), 0, NULL); |
1253 EXPECT_VALID(result); | 1253 EXPECT_VALID(result); |
1254 } | 1254 } |
1255 | 1255 |
1256 // Now Create another isolate using the snapshot and execute a method | 1256 // Now Create another isolate using the snapshot and execute a method |
(...skipping 1746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3003 StackZone zone(Thread::Current()); | 3003 StackZone zone(Thread::Current()); |
3004 uint8_t* buffer; | 3004 uint8_t* buffer; |
3005 MessageWriter writer(&buffer, &zone_allocator, &zone_deallocator, true); | 3005 MessageWriter writer(&buffer, &zone_allocator, &zone_deallocator, true); |
3006 writer.WriteInlinedObjectHeader(kOmittedObjectId); | 3006 writer.WriteInlinedObjectHeader(kOmittedObjectId); |
3007 // For performance, we'd like single-byte headers when ids are omitted. | 3007 // For performance, we'd like single-byte headers when ids are omitted. |
3008 // If this starts failing, consider renumbering the snapshot ids. | 3008 // If this starts failing, consider renumbering the snapshot ids. |
3009 EXPECT_EQ(1, writer.BytesWritten()); | 3009 EXPECT_EQ(1, writer.BytesWritten()); |
3010 } | 3010 } |
3011 | 3011 |
3012 } // namespace dart | 3012 } // namespace dart |
OLD | NEW |