Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(253)

Side by Side Diff: runtime/vm/snapshot_test.cc

Issue 1944213002: Support for taking full snapshots from 'dart', not just 'dart_bootstrap'. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/snapshot.cc ('k') | runtime/vm/symbols.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
828 public: 828 public:
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 */),
840 forward_list_(thread(), kMaxPredefinedObjectIds) { 839 forward_list_(thread(), kMaxPredefinedObjectIds) {
841 ASSERT(buffer != NULL); 840 ASSERT(buffer != NULL);
842 ASSERT(alloc != NULL); 841 ASSERT(alloc != NULL);
843 } 842 }
844 ~TestSnapshotWriter() { } 843 ~TestSnapshotWriter() { }
845 844
846 // Writes just a script object 845 // Writes just a script object
847 void WriteScript(const Script& script) { 846 void WriteScript(const Script& script) {
848 WriteObject(script.raw()); 847 WriteObject(script.raw());
849 } 848 }
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
1189 EXPECT_VALID(Api::CheckAndFinalizePendingClasses(thread)); 1188 EXPECT_VALID(Api::CheckAndFinalizePendingClasses(thread));
1190 timer1.Stop(); 1189 timer1.Stop();
1191 OS::PrintErr("Without Snapshot: %" Pd64 "us\n", timer1.TotalElapsedTime()); 1190 OS::PrintErr("Without Snapshot: %" Pd64 "us\n", timer1.TotalElapsedTime());
1192 1191
1193 // Write snapshot with object content. 1192 // Write snapshot with object content.
1194 { 1193 {
1195 FullSnapshotWriter writer(Snapshot::kCore, 1194 FullSnapshotWriter writer(Snapshot::kCore,
1196 NULL, 1195 NULL,
1197 &isolate_snapshot_buffer, 1196 &isolate_snapshot_buffer,
1198 &malloc_allocator, 1197 &malloc_allocator,
1199 NULL, /* instructions_writer */ 1198 NULL /* instructions_writer */);
1200 true);
1201 writer.WriteFullSnapshot(); 1199 writer.WriteFullSnapshot();
1202 } 1200 }
1203 } 1201 }
1204 1202
1205 // Now Create another isolate using the snapshot and execute a method 1203 // Now Create another isolate using the snapshot and execute a method
1206 // from the script. 1204 // from the script.
1207 Timer timer2(true, "Snapshot_test"); 1205 Timer timer2(true, "Snapshot_test");
1208 timer2.Start(); 1206 timer2.Start();
1209 TestCase::CreateTestIsolateFromSnapshot(isolate_snapshot_buffer); 1207 TestCase::CreateTestIsolateFromSnapshot(isolate_snapshot_buffer);
1210 { 1208 {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1250 EXPECT_VALID(Api::CheckAndFinalizePendingClasses(thread)); 1248 EXPECT_VALID(Api::CheckAndFinalizePendingClasses(thread));
1251 timer1.Stop(); 1249 timer1.Stop();
1252 OS::PrintErr("Without Snapshot: %" Pd64 "us\n", timer1.TotalElapsedTime()); 1250 OS::PrintErr("Without Snapshot: %" Pd64 "us\n", timer1.TotalElapsedTime());
1253 1251
1254 // Write snapshot with object content. 1252 // Write snapshot with object content.
1255 { 1253 {
1256 FullSnapshotWriter writer(Snapshot::kCore, 1254 FullSnapshotWriter writer(Snapshot::kCore,
1257 NULL, 1255 NULL,
1258 &isolate_snapshot_buffer, 1256 &isolate_snapshot_buffer,
1259 &malloc_allocator, 1257 &malloc_allocator,
1260 NULL, /* instructions_writer */ 1258 NULL /* instructions_writer */);
1261 true /* vm_isolate_is_symbolic */);
1262 writer.WriteFullSnapshot(); 1259 writer.WriteFullSnapshot();
1263 } 1260 }
1264 1261
1265 // Invoke a function which returns an object. 1262 // Invoke a function which returns an object.
1266 Dart_Handle cls = Dart_GetClass(lib, NewString("FieldsTest")); 1263 Dart_Handle cls = Dart_GetClass(lib, NewString("FieldsTest"));
1267 Dart_Handle result = Dart_Invoke(cls, NewString("testMain"), 0, NULL); 1264 Dart_Handle result = Dart_Invoke(cls, NewString("testMain"), 0, NULL);
1268 EXPECT_VALID(result); 1265 EXPECT_VALID(result);
1269 } 1266 }
1270 1267
1271 // Now Create another isolate using the snapshot and execute a method 1268 // Now Create another isolate using the snapshot and execute a method
(...skipping 1745 matching lines...) Expand 10 before | Expand all | Expand 10 after
3017 StackZone zone(Thread::Current()); 3014 StackZone zone(Thread::Current());
3018 uint8_t* buffer; 3015 uint8_t* buffer;
3019 MessageWriter writer(&buffer, &zone_allocator, true); 3016 MessageWriter writer(&buffer, &zone_allocator, true);
3020 writer.WriteInlinedObjectHeader(kOmittedObjectId); 3017 writer.WriteInlinedObjectHeader(kOmittedObjectId);
3021 // For performance, we'd like single-byte headers when ids are omitted. 3018 // For performance, we'd like single-byte headers when ids are omitted.
3022 // If this starts failing, consider renumbering the snapshot ids. 3019 // If this starts failing, consider renumbering the snapshot ids.
3023 EXPECT_EQ(1, writer.BytesWritten()); 3020 EXPECT_EQ(1, writer.BytesWritten());
3024 } 3021 }
3025 3022
3026 } // namespace dart 3023 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/snapshot.cc ('k') | runtime/vm/symbols.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698