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 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
828 | 828 |
829 class TestSnapshotWriter : public SnapshotWriter { | 829 class TestSnapshotWriter : public SnapshotWriter { |
830 public: | 830 public: |
831 static const intptr_t kInitialSize = 64 * KB; | 831 static const intptr_t kInitialSize = 64 * KB; |
832 TestSnapshotWriter(uint8_t** buffer, ReAlloc alloc) | 832 TestSnapshotWriter(uint8_t** buffer, ReAlloc alloc) |
833 : SnapshotWriter(Snapshot::kScript, | 833 : SnapshotWriter(Snapshot::kScript, |
834 buffer, | 834 buffer, |
835 alloc, | 835 alloc, |
836 kInitialSize, | 836 kInitialSize, |
837 &forward_list_, | 837 &forward_list_, |
| 838 NULL, /* test_writer */ |
838 true, /* can_send_any_object */ | 839 true, /* can_send_any_object */ |
839 false /* snapshot_code */), | 840 false, /* snapshot_code */ |
| 841 true /* vm_isolate_is_symbolic */), |
840 forward_list_(kMaxPredefinedObjectIds) { | 842 forward_list_(kMaxPredefinedObjectIds) { |
841 ASSERT(buffer != NULL); | 843 ASSERT(buffer != NULL); |
842 ASSERT(alloc != NULL); | 844 ASSERT(alloc != NULL); |
843 } | 845 } |
844 ~TestSnapshotWriter() { } | 846 ~TestSnapshotWriter() { } |
845 | 847 |
846 // Writes just a script object | 848 // Writes just a script object |
847 void WriteScript(const Script& script) { | 849 void WriteScript(const Script& script) { |
848 WriteObject(script.raw()); | 850 WriteObject(script.raw()); |
849 UnmarkAll(); | 851 UnmarkAll(); |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1173 // Create a test library and Load up a test script in it. | 1175 // Create a test library and Load up a test script in it. |
1174 TestCase::LoadTestScript(kScriptChars, NULL); | 1176 TestCase::LoadTestScript(kScriptChars, NULL); |
1175 EXPECT_VALID(Api::CheckAndFinalizePendingClasses(isolate)); | 1177 EXPECT_VALID(Api::CheckAndFinalizePendingClasses(isolate)); |
1176 timer1.Stop(); | 1178 timer1.Stop(); |
1177 OS::PrintErr("Without Snapshot: %" Pd64 "us\n", timer1.TotalElapsedTime()); | 1179 OS::PrintErr("Without Snapshot: %" Pd64 "us\n", timer1.TotalElapsedTime()); |
1178 | 1180 |
1179 // Write snapshot with object content. | 1181 // Write snapshot with object content. |
1180 { | 1182 { |
1181 FullSnapshotWriter writer(NULL, | 1183 FullSnapshotWriter writer(NULL, |
1182 &isolate_snapshot_buffer, | 1184 &isolate_snapshot_buffer, |
| 1185 NULL, /* instructions_snapshot_buffer */ |
1183 &malloc_allocator, | 1186 &malloc_allocator, |
1184 false /* snapshot_code */); | 1187 false, /* snapshot_code */ |
| 1188 true); |
1185 writer.WriteFullSnapshot(); | 1189 writer.WriteFullSnapshot(); |
1186 } | 1190 } |
1187 } | 1191 } |
1188 | 1192 |
1189 // Now Create another isolate using the snapshot and execute a method | 1193 // Now Create another isolate using the snapshot and execute a method |
1190 // from the script. | 1194 // from the script. |
1191 Timer timer2(true, "Snapshot_test"); | 1195 Timer timer2(true, "Snapshot_test"); |
1192 timer2.Start(); | 1196 timer2.Start(); |
1193 TestCase::CreateTestIsolateFromSnapshot(isolate_snapshot_buffer); | 1197 TestCase::CreateTestIsolateFromSnapshot(isolate_snapshot_buffer); |
1194 { | 1198 { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1232 // 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. |
1233 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); | 1237 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); |
1234 EXPECT_VALID(Api::CheckAndFinalizePendingClasses(isolate)); | 1238 EXPECT_VALID(Api::CheckAndFinalizePendingClasses(isolate)); |
1235 timer1.Stop(); | 1239 timer1.Stop(); |
1236 OS::PrintErr("Without Snapshot: %" Pd64 "us\n", timer1.TotalElapsedTime()); | 1240 OS::PrintErr("Without Snapshot: %" Pd64 "us\n", timer1.TotalElapsedTime()); |
1237 | 1241 |
1238 // Write snapshot with object content. | 1242 // Write snapshot with object content. |
1239 { | 1243 { |
1240 FullSnapshotWriter writer(NULL, | 1244 FullSnapshotWriter writer(NULL, |
1241 &isolate_snapshot_buffer, | 1245 &isolate_snapshot_buffer, |
| 1246 NULL, /* instructions_snapshot_buffer */ |
1242 &malloc_allocator, | 1247 &malloc_allocator, |
1243 false /* snapshot_code */); | 1248 false, /* snapshot_code */ |
| 1249 true /* vm_isolate_is_symbolic */); |
1244 writer.WriteFullSnapshot(); | 1250 writer.WriteFullSnapshot(); |
1245 } | 1251 } |
1246 | 1252 |
1247 // Invoke a function which returns an object. | 1253 // Invoke a function which returns an object. |
1248 Dart_Handle cls = Dart_GetClass(lib, NewString("FieldsTest")); | 1254 Dart_Handle cls = Dart_GetClass(lib, NewString("FieldsTest")); |
1249 Dart_Handle result = Dart_Invoke(cls, NewString("testMain"), 0, NULL); | 1255 Dart_Handle result = Dart_Invoke(cls, NewString("testMain"), 0, NULL); |
1250 EXPECT_VALID(result); | 1256 EXPECT_VALID(result); |
1251 } | 1257 } |
1252 | 1258 |
1253 // Now Create another isolate using the snapshot and execute a method | 1259 // Now Create another isolate using the snapshot and execute a method |
(...skipping 1735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2989 StackZone zone(Thread::Current()); | 2995 StackZone zone(Thread::Current()); |
2990 uint8_t* buffer; | 2996 uint8_t* buffer; |
2991 MessageWriter writer(&buffer, &zone_allocator, true); | 2997 MessageWriter writer(&buffer, &zone_allocator, true); |
2992 writer.WriteInlinedObjectHeader(kOmittedObjectId); | 2998 writer.WriteInlinedObjectHeader(kOmittedObjectId); |
2993 // For performance, we'd like single-byte headers when ids are omitted. | 2999 // For performance, we'd like single-byte headers when ids are omitted. |
2994 // If this starts failing, consider renumbering the snapshot ids. | 3000 // If this starts failing, consider renumbering the snapshot ids. |
2995 EXPECT_EQ(1, writer.BytesWritten()); | 3001 EXPECT_EQ(1, writer.BytesWritten()); |
2996 } | 3002 } |
2997 | 3003 |
2998 } // namespace dart | 3004 } // namespace dart |
OLD | NEW |