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

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

Issue 1918313003: Split Snapshot::kFull into kCore, kAppWithJIT, and kAppNoJIT. Remove snapshot_code flag. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: sync 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') | 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 810 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 EXPECT_EQ(kTypedDataLength, root->value.as_typed_data.length); 821 EXPECT_EQ(kTypedDataLength, root->value.as_typed_data.length);
822 EXPECT(root->value.as_typed_data.values == NULL); 822 EXPECT(root->value.as_typed_data.values == NULL);
823 CheckEncodeDecodeMessage(root); 823 CheckEncodeDecodeMessage(root);
824 } 824 }
825 825
826 826
827 class TestSnapshotWriter : public SnapshotWriter { 827 class TestSnapshotWriter : public SnapshotWriter {
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(Snapshot::kScript, 831 : SnapshotWriter(Thread::Current(),
832 Thread::Current(), 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 false, /* snapshot_code */
840 true /* vm_isolate_is_symbolic */), 839 true /* vm_isolate_is_symbolic */),
841 forward_list_(thread(), kMaxPredefinedObjectIds) { 840 forward_list_(thread(), kMaxPredefinedObjectIds) {
842 ASSERT(buffer != NULL); 841 ASSERT(buffer != NULL);
843 ASSERT(alloc != NULL); 842 ASSERT(alloc != NULL);
844 } 843 }
845 ~TestSnapshotWriter() { } 844 ~TestSnapshotWriter() { }
846 845
847 // Writes just a script object 846 // Writes just a script object
848 void WriteScript(const Script& script) { 847 void WriteScript(const Script& script) {
849 WriteObject(script.raw()); 848 WriteObject(script.raw());
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
1177 HandleScope scope(thread); 1176 HandleScope scope(thread);
1178 1177
1179 // Create a test library and Load up a test script in it. 1178 // Create a test library and Load up a test script in it.
1180 TestCase::LoadTestScript(kScriptChars, NULL); 1179 TestCase::LoadTestScript(kScriptChars, NULL);
1181 EXPECT_VALID(Api::CheckAndFinalizePendingClasses(thread)); 1180 EXPECT_VALID(Api::CheckAndFinalizePendingClasses(thread));
1182 timer1.Stop(); 1181 timer1.Stop();
1183 OS::PrintErr("Without Snapshot: %" Pd64 "us\n", timer1.TotalElapsedTime()); 1182 OS::PrintErr("Without Snapshot: %" Pd64 "us\n", timer1.TotalElapsedTime());
1184 1183
1185 // Write snapshot with object content. 1184 // Write snapshot with object content.
1186 { 1185 {
1187 FullSnapshotWriter writer(NULL, 1186 FullSnapshotWriter writer(Snapshot::kCore,
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 false, /* snapshot_code */
1192 true); 1191 true);
1193 writer.WriteFullSnapshot(); 1192 writer.WriteFullSnapshot();
1194 } 1193 }
1195 } 1194 }
1196 1195
1197 // Now Create another isolate using the snapshot and execute a method 1196 // Now Create another isolate using the snapshot and execute a method
1198 // from the script. 1197 // from the script.
1199 Timer timer2(true, "Snapshot_test"); 1198 Timer timer2(true, "Snapshot_test");
1200 timer2.Start(); 1199 timer2.Start();
1201 TestCase::CreateTestIsolateFromSnapshot(isolate_snapshot_buffer); 1200 TestCase::CreateTestIsolateFromSnapshot(isolate_snapshot_buffer);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1238 HandleScope scope(thread); 1237 HandleScope scope(thread);
1239 1238
1240 // Create a test library and Load up a test script in it. 1239 // Create a test library and Load up a test script in it.
1241 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); 1240 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
1242 EXPECT_VALID(Api::CheckAndFinalizePendingClasses(thread)); 1241 EXPECT_VALID(Api::CheckAndFinalizePendingClasses(thread));
1243 timer1.Stop(); 1242 timer1.Stop();
1244 OS::PrintErr("Without Snapshot: %" Pd64 "us\n", timer1.TotalElapsedTime()); 1243 OS::PrintErr("Without Snapshot: %" Pd64 "us\n", timer1.TotalElapsedTime());
1245 1244
1246 // Write snapshot with object content. 1245 // Write snapshot with object content.
1247 { 1246 {
1248 FullSnapshotWriter writer(NULL, 1247 FullSnapshotWriter writer(Snapshot::kCore,
1248 NULL,
1249 &isolate_snapshot_buffer, 1249 &isolate_snapshot_buffer,
1250 &malloc_allocator, 1250 &malloc_allocator,
1251 NULL, /* instructions_writer */ 1251 NULL, /* instructions_writer */
1252 false, /* snapshot_code */
1253 true /* vm_isolate_is_symbolic */); 1252 true /* vm_isolate_is_symbolic */);
1254 writer.WriteFullSnapshot(); 1253 writer.WriteFullSnapshot();
1255 } 1254 }
1256 1255
1257 // Invoke a function which returns an object. 1256 // Invoke a function which returns an object.
1258 Dart_Handle cls = Dart_GetClass(lib, NewString("FieldsTest")); 1257 Dart_Handle cls = Dart_GetClass(lib, NewString("FieldsTest"));
1259 Dart_Handle result = Dart_Invoke(cls, NewString("testMain"), 0, NULL); 1258 Dart_Handle result = Dart_Invoke(cls, NewString("testMain"), 0, NULL);
1260 EXPECT_VALID(result); 1259 EXPECT_VALID(result);
1261 } 1260 }
1262 1261
(...skipping 1746 matching lines...) Expand 10 before | Expand all | Expand 10 after
3009 StackZone zone(Thread::Current()); 3008 StackZone zone(Thread::Current());
3010 uint8_t* buffer; 3009 uint8_t* buffer;
3011 MessageWriter writer(&buffer, &zone_allocator, true); 3010 MessageWriter writer(&buffer, &zone_allocator, true);
3012 writer.WriteInlinedObjectHeader(kOmittedObjectId); 3011 writer.WriteInlinedObjectHeader(kOmittedObjectId);
3013 // For performance, we'd like single-byte headers when ids are omitted. 3012 // For performance, we'd like single-byte headers when ids are omitted.
3014 // If this starts failing, consider renumbering the snapshot ids. 3013 // If this starts failing, consider renumbering the snapshot ids.
3015 EXPECT_EQ(1, writer.BytesWritten()); 3014 EXPECT_EQ(1, writer.BytesWritten());
3016 } 3015 }
3017 3016
3018 } // namespace dart 3017 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/snapshot.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698