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

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

Issue 1290933002: Toward precompiled snapshots. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 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
« runtime/vm/snapshot_ids.h ('K') | « runtime/vm/snapshot_ids.h ('k') | no next file » | 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 879 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 true), 900 true, /* can_send_any_object */
901 false /* snapshot_code */),
901 forward_list_(kMaxPredefinedObjectIds) { 902 forward_list_(kMaxPredefinedObjectIds) {
902 ASSERT(buffer != NULL); 903 ASSERT(buffer != NULL);
903 ASSERT(alloc != NULL); 904 ASSERT(alloc != NULL);
904 } 905 }
905 ~TestSnapshotWriter() { } 906 ~TestSnapshotWriter() { }
906 907
907 // Writes just a script object 908 // Writes just a script object
908 void WriteScript(const Script& script) { 909 void WriteScript(const Script& script) {
909 WriteObject(script.raw()); 910 WriteObject(script.raw());
910 UnmarkAll(); 911 UnmarkAll();
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
1237 // Create a test library and Load up a test script in it. 1238 // Create a test library and Load up a test script in it.
1238 TestCase::LoadTestScript(kScriptChars, NULL); 1239 TestCase::LoadTestScript(kScriptChars, NULL);
1239 EXPECT_VALID(Api::CheckAndFinalizePendingClasses(isolate)); 1240 EXPECT_VALID(Api::CheckAndFinalizePendingClasses(isolate));
1240 timer1.Stop(); 1241 timer1.Stop();
1241 OS::PrintErr("Without Snapshot: %" Pd64 "us\n", timer1.TotalElapsedTime()); 1242 OS::PrintErr("Without Snapshot: %" Pd64 "us\n", timer1.TotalElapsedTime());
1242 1243
1243 // Write snapshot with object content. 1244 // Write snapshot with object content.
1244 { 1245 {
1245 FullSnapshotWriter writer(NULL, 1246 FullSnapshotWriter writer(NULL,
1246 &isolate_snapshot_buffer, 1247 &isolate_snapshot_buffer,
1247 &malloc_allocator); 1248 &malloc_allocator,
1249 false /* snapshot_code */);
1248 writer.WriteFullSnapshot(); 1250 writer.WriteFullSnapshot();
1249 } 1251 }
1250 } 1252 }
1251 1253
1252 // Now Create another isolate using the snapshot and execute a method 1254 // Now Create another isolate using the snapshot and execute a method
1253 // from the script. 1255 // from the script.
1254 Timer timer2(true, "Snapshot_test"); 1256 Timer timer2(true, "Snapshot_test");
1255 timer2.Start(); 1257 timer2.Start();
1256 TestCase::CreateTestIsolateFromSnapshot(isolate_snapshot_buffer); 1258 TestCase::CreateTestIsolateFromSnapshot(isolate_snapshot_buffer);
1257 { 1259 {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1295 // Create a test library and Load up a test script in it. 1297 // Create a test library and Load up a test script in it.
1296 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); 1298 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
1297 EXPECT_VALID(Api::CheckAndFinalizePendingClasses(isolate)); 1299 EXPECT_VALID(Api::CheckAndFinalizePendingClasses(isolate));
1298 timer1.Stop(); 1300 timer1.Stop();
1299 OS::PrintErr("Without Snapshot: %" Pd64 "us\n", timer1.TotalElapsedTime()); 1301 OS::PrintErr("Without Snapshot: %" Pd64 "us\n", timer1.TotalElapsedTime());
1300 1302
1301 // Write snapshot with object content. 1303 // Write snapshot with object content.
1302 { 1304 {
1303 FullSnapshotWriter writer(NULL, 1305 FullSnapshotWriter writer(NULL,
1304 &isolate_snapshot_buffer, 1306 &isolate_snapshot_buffer,
1305 &malloc_allocator); 1307 &malloc_allocator,
1308 false /* snapshot_code */);
1306 writer.WriteFullSnapshot(); 1309 writer.WriteFullSnapshot();
1307 } 1310 }
1308 1311
1309 // Invoke a function which returns an object. 1312 // Invoke a function which returns an object.
1310 Dart_Handle cls = Dart_GetClass(lib, NewString("FieldsTest")); 1313 Dart_Handle cls = Dart_GetClass(lib, NewString("FieldsTest"));
1311 Dart_Handle result = Dart_Invoke(cls, NewString("testMain"), 0, NULL); 1314 Dart_Handle result = Dart_Invoke(cls, NewString("testMain"), 0, NULL);
1312 EXPECT_VALID(result); 1315 EXPECT_VALID(result);
1313 } 1316 }
1314 1317
1315 // Now Create another isolate using the snapshot and execute a method 1318 // Now Create another isolate using the snapshot and execute a method
(...skipping 1737 matching lines...) Expand 10 before | Expand all | Expand 10 after
3053 StackZone zone(Isolate::Current()); 3056 StackZone zone(Isolate::Current());
3054 uint8_t* buffer; 3057 uint8_t* buffer;
3055 MessageWriter writer(&buffer, &zone_allocator, true); 3058 MessageWriter writer(&buffer, &zone_allocator, true);
3056 writer.WriteInlinedObjectHeader(kOmittedObjectId); 3059 writer.WriteInlinedObjectHeader(kOmittedObjectId);
3057 // For performance, we'd like single-byte headers when ids are omitted. 3060 // For performance, we'd like single-byte headers when ids are omitted.
3058 // If this starts failing, consider renumbering the snapshot ids. 3061 // If this starts failing, consider renumbering the snapshot ids.
3059 EXPECT_EQ(1, writer.BytesWritten()); 3062 EXPECT_EQ(1, writer.BytesWritten());
3060 } 3063 }
3061 3064
3062 } // namespace dart 3065 } // namespace dart
OLDNEW
« runtime/vm/snapshot_ids.h ('K') | « runtime/vm/snapshot_ids.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698