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

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

Issue 998763002: While creating snapshots do not write out fields of an empty context and while reading do not creat… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/object.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 "vm/object.h" 5 #include "vm/object.h"
6 #include "vm/object_store.h" 6 #include "vm/object_store.h"
7 #include "vm/snapshot.h" 7 #include "vm/snapshot.h"
8 #include "vm/stub_code.h" 8 #include "vm/stub_code.h"
9 #include "vm/symbols.h" 9 #include "vm/symbols.h"
10 #include "vm/visitor.h" 10 #include "vm/visitor.h"
(...skipping 1348 matching lines...) Expand 10 before | Expand all | Expand 10 after
1359 1359
1360 1360
1361 RawContext* Context::ReadFrom(SnapshotReader* reader, 1361 RawContext* Context::ReadFrom(SnapshotReader* reader,
1362 intptr_t object_id, 1362 intptr_t object_id,
1363 intptr_t tags, 1363 intptr_t tags,
1364 Snapshot::Kind kind) { 1364 Snapshot::Kind kind) {
1365 ASSERT(reader != NULL); 1365 ASSERT(reader != NULL);
1366 1366
1367 // Allocate context object. 1367 // Allocate context object.
1368 int32_t num_vars = reader->Read<int32_t>(); 1368 int32_t num_vars = reader->Read<int32_t>();
1369 Context& context = Context::ZoneHandle( 1369 Context& context = Context::ZoneHandle(reader->isolate());
1370 reader->isolate(), NEW_OBJECT_WITH_LEN(Context, num_vars));
1371 reader->AddBackRef(object_id, &context, kIsDeserialized); 1370 reader->AddBackRef(object_id, &context, kIsDeserialized);
1371 if (num_vars == 0) {
1372 context ^= reader->object_store()->empty_context();
1373 } else {
1374 context ^= NEW_OBJECT_WITH_LEN(Context, num_vars);
1372 1375
1373 // Set the object tags. 1376 // Set the object tags.
1374 context.set_tags(tags); 1377 context.set_tags(tags);
1375 1378
1376 // Set all the object fields. 1379 // Set all the object fields.
1377 // TODO(5411462): Need to assert No GC can happen here, even though 1380 // TODO(5411462): Need to assert No GC can happen here, even though
1378 // allocations may happen. 1381 // allocations may happen.
1379 intptr_t num_flds = (context.raw()->to(num_vars) - context.raw()->from()); 1382 intptr_t num_flds = (context.raw()->to(num_vars) - context.raw()->from());
1380 for (intptr_t i = 0; i <= num_flds; i++) { 1383 for (intptr_t i = 0; i <= num_flds; i++) {
1381 (*reader->PassiveObjectHandle()) = reader->ReadObjectRef(); 1384 (*reader->PassiveObjectHandle()) = reader->ReadObjectRef();
1382 context.StorePointer((context.raw()->from() + i), 1385 context.StorePointer((context.raw()->from() + i),
1383 reader->PassiveObjectHandle()->raw()); 1386 reader->PassiveObjectHandle()->raw());
1387 }
1384 } 1388 }
1385
1386 return context.raw(); 1389 return context.raw();
1387 } 1390 }
1388 1391
1389 1392
1390 void RawContext::WriteTo(SnapshotWriter* writer, 1393 void RawContext::WriteTo(SnapshotWriter* writer,
1391 intptr_t object_id, 1394 intptr_t object_id,
1392 Snapshot::Kind kind) { 1395 Snapshot::Kind kind) {
1393 ASSERT(writer != NULL); 1396 ASSERT(writer != NULL);
1394 1397
1395 // Write out the serialization header value for this object. 1398 // Write out the serialization header value for this object.
1396 writer->WriteInlinedObjectHeader(object_id); 1399 writer->WriteInlinedObjectHeader(object_id);
1397 1400
1398 // Write out the class and tags information. 1401 // Write out the class and tags information.
1399 writer->WriteVMIsolateObject(kContextCid); 1402 writer->WriteVMIsolateObject(kContextCid);
1400 writer->WriteTags(writer->GetObjectTags(this)); 1403 writer->WriteTags(writer->GetObjectTags(this));
1401 1404
1402 // Write out num of variables in the context. 1405 // Write out num of variables in the context.
1403 writer->Write<int32_t>(ptr()->num_variables_); 1406 int32_t num_variables = ptr()->num_variables_;
1404 1407 writer->Write<int32_t>(num_variables);
1405 // Write out all the object pointer fields. 1408 if (num_variables != 0) {
1406 SnapshotWriterVisitor visitor(writer); 1409 // Write out all the object pointer fields.
1407 visitor.VisitPointers(from(), to(ptr()->num_variables_)); 1410 SnapshotWriterVisitor visitor(writer);
1411 visitor.VisitPointers(from(), to(num_variables));
1412 }
1408 } 1413 }
1409 1414
1410 1415
1411 RawContextScope* ContextScope::ReadFrom(SnapshotReader* reader, 1416 RawContextScope* ContextScope::ReadFrom(SnapshotReader* reader,
1412 intptr_t object_id, 1417 intptr_t object_id,
1413 intptr_t tags, 1418 intptr_t tags,
1414 Snapshot::Kind kind) { 1419 Snapshot::Kind kind) {
1415 UNREACHABLE(); 1420 UNREACHABLE();
1416 return NULL; 1421 return NULL;
1417 } 1422 }
(...skipping 1482 matching lines...) Expand 10 before | Expand all | Expand 10 after
2900 // We do not allow objects with native fields in an isolate message. 2905 // We do not allow objects with native fields in an isolate message.
2901 writer->SetWriteException(Exceptions::kArgument, 2906 writer->SetWriteException(Exceptions::kArgument,
2902 "Illegal argument in isolate message" 2907 "Illegal argument in isolate message"
2903 " : (object is a UserTag)"); 2908 " : (object is a UserTag)");
2904 } else { 2909 } else {
2905 UNREACHABLE(); 2910 UNREACHABLE();
2906 } 2911 }
2907 } 2912 }
2908 2913
2909 } // namespace dart 2914 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698