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 818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
829 static const intptr_t kInitialSize = 64 * KB; | 829 static const intptr_t kInitialSize = 64 * KB; |
830 TestSnapshotWriter(uint8_t** buffer, ReAlloc alloc) | 830 TestSnapshotWriter(uint8_t** buffer, ReAlloc alloc) |
831 : SnapshotWriter(Thread::Current(), | 831 : SnapshotWriter(Thread::Current(), |
832 Snapshot::kScript, | 832 Snapshot::kScript, |
833 buffer, | 833 buffer, |
834 alloc, | 834 alloc, |
835 kInitialSize, | 835 kInitialSize, |
836 &forward_list_, | 836 &forward_list_, |
837 NULL, /* test_writer */ | 837 NULL, /* test_writer */ |
838 true, /* can_send_any_object */ | 838 true, /* can_send_any_object */ |
839 true /* vm_isolate_is_symbolic */), | 839 false /* writing_vm_isolate */), |
840 forward_list_(thread(), kMaxPredefinedObjectIds) { | 840 forward_list_(thread(), kMaxPredefinedObjectIds) { |
841 ASSERT(buffer != NULL); | 841 ASSERT(buffer != NULL); |
842 ASSERT(alloc != NULL); | 842 ASSERT(alloc != NULL); |
843 } | 843 } |
844 ~TestSnapshotWriter() { } | 844 ~TestSnapshotWriter() { } |
845 | 845 |
846 // Writes just a script object | 846 // Writes just a script object |
847 void WriteScript(const Script& script) { | 847 void WriteScript(const Script& script) { |
848 WriteObject(script.raw()); | 848 WriteObject(script.raw()); |
849 } | 849 } |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1180 EXPECT_VALID(Api::CheckAndFinalizePendingClasses(thread)); | 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(Snapshot::kCore, | 1186 FullSnapshotWriter writer(Snapshot::kCore, |
1187 NULL, | 1187 NULL, |
1188 &isolate_snapshot_buffer, | 1188 &isolate_snapshot_buffer, |
1189 &malloc_allocator, | 1189 &malloc_allocator, |
1190 NULL, /* instructions_writer */ | 1190 NULL /* instructions_writer */); |
1191 true); | |
1192 writer.WriteFullSnapshot(); | 1191 writer.WriteFullSnapshot(); |
1193 } | 1192 } |
1194 } | 1193 } |
1195 | 1194 |
1196 // Now Create another isolate using the snapshot and execute a method | 1195 // Now Create another isolate using the snapshot and execute a method |
1197 // from the script. | 1196 // from the script. |
1198 Timer timer2(true, "Snapshot_test"); | 1197 Timer timer2(true, "Snapshot_test"); |
1199 timer2.Start(); | 1198 timer2.Start(); |
1200 TestCase::CreateTestIsolateFromSnapshot(isolate_snapshot_buffer); | 1199 TestCase::CreateTestIsolateFromSnapshot(isolate_snapshot_buffer); |
1201 { | 1200 { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1241 EXPECT_VALID(Api::CheckAndFinalizePendingClasses(thread)); | 1240 EXPECT_VALID(Api::CheckAndFinalizePendingClasses(thread)); |
1242 timer1.Stop(); | 1241 timer1.Stop(); |
1243 OS::PrintErr("Without Snapshot: %" Pd64 "us\n", timer1.TotalElapsedTime()); | 1242 OS::PrintErr("Without Snapshot: %" Pd64 "us\n", timer1.TotalElapsedTime()); |
1244 | 1243 |
1245 // Write snapshot with object content. | 1244 // Write snapshot with object content. |
1246 { | 1245 { |
1247 FullSnapshotWriter writer(Snapshot::kCore, | 1246 FullSnapshotWriter writer(Snapshot::kCore, |
1248 NULL, | 1247 NULL, |
1249 &isolate_snapshot_buffer, | 1248 &isolate_snapshot_buffer, |
1250 &malloc_allocator, | 1249 &malloc_allocator, |
1251 NULL, /* instructions_writer */ | 1250 NULL /* instructions_writer */); |
1252 true /* vm_isolate_is_symbolic */); | |
1253 writer.WriteFullSnapshot(); | 1251 writer.WriteFullSnapshot(); |
1254 } | 1252 } |
1255 | 1253 |
1256 // Invoke a function which returns an object. | 1254 // Invoke a function which returns an object. |
1257 Dart_Handle cls = Dart_GetClass(lib, NewString("FieldsTest")); | 1255 Dart_Handle cls = Dart_GetClass(lib, NewString("FieldsTest")); |
1258 Dart_Handle result = Dart_Invoke(cls, NewString("testMain"), 0, NULL); | 1256 Dart_Handle result = Dart_Invoke(cls, NewString("testMain"), 0, NULL); |
1259 EXPECT_VALID(result); | 1257 EXPECT_VALID(result); |
1260 } | 1258 } |
1261 | 1259 |
1262 // Now Create another isolate using the snapshot and execute a method | 1260 // Now Create another isolate using the snapshot and execute a method |
(...skipping 1745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3008 StackZone zone(Thread::Current()); | 3006 StackZone zone(Thread::Current()); |
3009 uint8_t* buffer; | 3007 uint8_t* buffer; |
3010 MessageWriter writer(&buffer, &zone_allocator, true); | 3008 MessageWriter writer(&buffer, &zone_allocator, true); |
3011 writer.WriteInlinedObjectHeader(kOmittedObjectId); | 3009 writer.WriteInlinedObjectHeader(kOmittedObjectId); |
3012 // For performance, we'd like single-byte headers when ids are omitted. | 3010 // For performance, we'd like single-byte headers when ids are omitted. |
3013 // If this starts failing, consider renumbering the snapshot ids. | 3011 // If this starts failing, consider renumbering the snapshot ids. |
3014 EXPECT_EQ(1, writer.BytesWritten()); | 3012 EXPECT_EQ(1, writer.BytesWritten()); |
3015 } | 3013 } |
3016 | 3014 |
3017 } // namespace dart | 3015 } // namespace dart |
OLD | NEW |