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 879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
890 | 890 |
891 class TestSnapshotWriter : public SnapshotWriter { | 891 class TestSnapshotWriter : public SnapshotWriter { |
892 public: | 892 public: |
893 static const intptr_t kInitialSize = 64 * KB; | 893 static const intptr_t kInitialSize = 64 * KB; |
894 TestSnapshotWriter(uint8_t** buffer, ReAlloc alloc) | 894 TestSnapshotWriter(uint8_t** buffer, ReAlloc alloc) |
895 : SnapshotWriter(Snapshot::kScript, | 895 : SnapshotWriter(Snapshot::kScript, |
896 buffer, | 896 buffer, |
897 alloc, | 897 alloc, |
898 kInitialSize, | 898 kInitialSize, |
899 &forward_list_, | 899 &forward_list_, |
| 900 NULL, /* test_writer */ |
900 true, /* can_send_any_object */ | 901 true, /* can_send_any_object */ |
901 false /* snapshot_code */), | 902 false, /* snapshot_code */ |
| 903 true /* vm_isolate_is_symbolic */), |
902 forward_list_(kMaxPredefinedObjectIds) { | 904 forward_list_(kMaxPredefinedObjectIds) { |
903 ASSERT(buffer != NULL); | 905 ASSERT(buffer != NULL); |
904 ASSERT(alloc != NULL); | 906 ASSERT(alloc != NULL); |
905 } | 907 } |
906 ~TestSnapshotWriter() { } | 908 ~TestSnapshotWriter() { } |
907 | 909 |
908 // Writes just a script object | 910 // Writes just a script object |
909 void WriteScript(const Script& script) { | 911 void WriteScript(const Script& script) { |
910 WriteObject(script.raw()); | 912 WriteObject(script.raw()); |
911 UnmarkAll(); | 913 UnmarkAll(); |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1238 // Create a test library and Load up a test script in it. | 1240 // Create a test library and Load up a test script in it. |
1239 TestCase::LoadTestScript(kScriptChars, NULL); | 1241 TestCase::LoadTestScript(kScriptChars, NULL); |
1240 EXPECT_VALID(Api::CheckAndFinalizePendingClasses(isolate)); | 1242 EXPECT_VALID(Api::CheckAndFinalizePendingClasses(isolate)); |
1241 timer1.Stop(); | 1243 timer1.Stop(); |
1242 OS::PrintErr("Without Snapshot: %" Pd64 "us\n", timer1.TotalElapsedTime()); | 1244 OS::PrintErr("Without Snapshot: %" Pd64 "us\n", timer1.TotalElapsedTime()); |
1243 | 1245 |
1244 // Write snapshot with object content. | 1246 // Write snapshot with object content. |
1245 { | 1247 { |
1246 FullSnapshotWriter writer(NULL, | 1248 FullSnapshotWriter writer(NULL, |
1247 &isolate_snapshot_buffer, | 1249 &isolate_snapshot_buffer, |
| 1250 NULL, /* instructions_snapshot_buffer */ |
1248 &malloc_allocator, | 1251 &malloc_allocator, |
1249 false /* snapshot_code */); | 1252 false, /* snapshot_code */ |
| 1253 true); |
1250 writer.WriteFullSnapshot(); | 1254 writer.WriteFullSnapshot(); |
1251 } | 1255 } |
1252 } | 1256 } |
1253 | 1257 |
1254 // Now Create another isolate using the snapshot and execute a method | 1258 // Now Create another isolate using the snapshot and execute a method |
1255 // from the script. | 1259 // from the script. |
1256 Timer timer2(true, "Snapshot_test"); | 1260 Timer timer2(true, "Snapshot_test"); |
1257 timer2.Start(); | 1261 timer2.Start(); |
1258 TestCase::CreateTestIsolateFromSnapshot(isolate_snapshot_buffer); | 1262 TestCase::CreateTestIsolateFromSnapshot(isolate_snapshot_buffer); |
1259 { | 1263 { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1297 // Create a test library and Load up a test script in it. | 1301 // Create a test library and Load up a test script in it. |
1298 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); | 1302 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); |
1299 EXPECT_VALID(Api::CheckAndFinalizePendingClasses(isolate)); | 1303 EXPECT_VALID(Api::CheckAndFinalizePendingClasses(isolate)); |
1300 timer1.Stop(); | 1304 timer1.Stop(); |
1301 OS::PrintErr("Without Snapshot: %" Pd64 "us\n", timer1.TotalElapsedTime()); | 1305 OS::PrintErr("Without Snapshot: %" Pd64 "us\n", timer1.TotalElapsedTime()); |
1302 | 1306 |
1303 // Write snapshot with object content. | 1307 // Write snapshot with object content. |
1304 { | 1308 { |
1305 FullSnapshotWriter writer(NULL, | 1309 FullSnapshotWriter writer(NULL, |
1306 &isolate_snapshot_buffer, | 1310 &isolate_snapshot_buffer, |
| 1311 NULL, /* instructions_snapshot_buffer */ |
1307 &malloc_allocator, | 1312 &malloc_allocator, |
1308 false /* snapshot_code */); | 1313 false, /* snapshot_code */ |
| 1314 true /* vm_isolate_is_symbolic */); |
1309 writer.WriteFullSnapshot(); | 1315 writer.WriteFullSnapshot(); |
1310 } | 1316 } |
1311 | 1317 |
1312 // Invoke a function which returns an object. | 1318 // Invoke a function which returns an object. |
1313 Dart_Handle cls = Dart_GetClass(lib, NewString("FieldsTest")); | 1319 Dart_Handle cls = Dart_GetClass(lib, NewString("FieldsTest")); |
1314 Dart_Handle result = Dart_Invoke(cls, NewString("testMain"), 0, NULL); | 1320 Dart_Handle result = Dart_Invoke(cls, NewString("testMain"), 0, NULL); |
1315 EXPECT_VALID(result); | 1321 EXPECT_VALID(result); |
1316 } | 1322 } |
1317 | 1323 |
1318 // Now Create another isolate using the snapshot and execute a method | 1324 // Now Create another isolate using the snapshot and execute a method |
(...skipping 1735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3054 StackZone zone(Thread::Current()); | 3060 StackZone zone(Thread::Current()); |
3055 uint8_t* buffer; | 3061 uint8_t* buffer; |
3056 MessageWriter writer(&buffer, &zone_allocator, true); | 3062 MessageWriter writer(&buffer, &zone_allocator, true); |
3057 writer.WriteInlinedObjectHeader(kOmittedObjectId); | 3063 writer.WriteInlinedObjectHeader(kOmittedObjectId); |
3058 // For performance, we'd like single-byte headers when ids are omitted. | 3064 // For performance, we'd like single-byte headers when ids are omitted. |
3059 // If this starts failing, consider renumbering the snapshot ids. | 3065 // If this starts failing, consider renumbering the snapshot ids. |
3060 EXPECT_EQ(1, writer.BytesWritten()); | 3066 EXPECT_EQ(1, writer.BytesWritten()); |
3061 } | 3067 } |
3062 | 3068 |
3063 } // namespace dart | 3069 } // namespace dart |
OLD | NEW |