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

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

Issue 1378423002: Support serializing ObjectPool as reference. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 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/raw_object_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 "vm/snapshot.h" 5 #include "vm/snapshot.h"
6 6
7 #include "platform/assert.h" 7 #include "platform/assert.h"
8 #include "vm/bootstrap.h" 8 #include "vm/bootstrap.h"
9 #include "vm/class_finalizer.h" 9 #include "vm/class_finalizer.h"
10 #include "vm/dart.h" 10 #include "vm/dart.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 } 58 }
59 59
60 60
61 static bool IsSplitClassId(intptr_t class_id) { 61 static bool IsSplitClassId(intptr_t class_id) {
62 // Return whether this class is serialized in two steps: first a reference, 62 // Return whether this class is serialized in two steps: first a reference,
63 // with sufficient information to allocate a correctly sized object, and then 63 // with sufficient information to allocate a correctly sized object, and then
64 // later inline with complete contents. 64 // later inline with complete contents.
65 return class_id >= kNumPredefinedCids || 65 return class_id >= kNumPredefinedCids ||
66 class_id == kArrayCid || 66 class_id == kArrayCid ||
67 class_id == kImmutableArrayCid || 67 class_id == kImmutableArrayCid ||
68 class_id == kObjectPoolCid ||
68 RawObject::IsImplicitFieldClassId(class_id); 69 RawObject::IsImplicitFieldClassId(class_id);
69 } 70 }
70 71
71 72
72 static intptr_t ClassIdFromObjectId(intptr_t object_id) { 73 static intptr_t ClassIdFromObjectId(intptr_t object_id) {
73 ASSERT(object_id > kClassIdsOffset); 74 ASSERT(object_id > kClassIdsOffset);
74 intptr_t class_id = (object_id - kClassIdsOffset); 75 intptr_t class_id = (object_id - kClassIdsOffset);
75 return class_id; 76 return class_id;
76 } 77 }
77 78
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 // Read the length and allocate an object based on the len. 478 // Read the length and allocate an object based on the len.
478 intptr_t len = ReadSmiValue(); 479 intptr_t len = ReadSmiValue();
479 Array& array = Array::ZoneHandle( 480 Array& array = Array::ZoneHandle(
480 zone(), 481 zone(),
481 (kind_ == Snapshot::kFull) ? 482 (kind_ == Snapshot::kFull) ?
482 NewImmutableArray(len) : ImmutableArray::New(len, HEAP_SPACE(kind_))); 483 NewImmutableArray(len) : ImmutableArray::New(len, HEAP_SPACE(kind_)));
483 AddBackRef(object_id, &array, kIsNotDeserialized); 484 AddBackRef(object_id, &array, kIsNotDeserialized);
484 485
485 return array.raw(); 486 return array.raw();
486 } 487 }
488 if (class_id == kObjectPoolCid) {
489 // Read the length and allocate an object based on the len.
490 intptr_t len = Read<intptr_t>();
491 ObjectPool& pool = ObjectPool::ZoneHandle(
492 zone(),
493 (kind_ == Snapshot::kFull) ?
494 NewObjectPool(len) : ObjectPool::New(len));
siva 2015/10/01 21:05:09 ObjectPool should only be serialized in a Full sna
rmacnak 2015/10/01 21:32:48 Done.
495 AddBackRef(object_id, &pool, kIsNotDeserialized);
496
497 return pool.raw();
498 }
487 499
488 // For all other internal VM classes we read the object inline. 500 // For all other internal VM classes we read the object inline.
489 switch (class_id) { 501 switch (class_id) {
490 #define SNAPSHOT_READ(clazz) \ 502 #define SNAPSHOT_READ(clazz) \
491 case clazz::kClassId: { \ 503 case clazz::kClassId: { \
492 pobj_ = clazz::ReadFrom(this, object_id, tags, kind_); \ 504 pobj_ = clazz::ReadFrom(this, object_id, tags, kind_); \
493 break; \ 505 break; \
494 } 506 }
495 CLASS_LIST_NO_OBJECT(SNAPSHOT_READ) 507 CLASS_LIST_NO_OBJECT(SNAPSHOT_READ)
496 #undef SNAPSHOT_READ 508 #undef SNAPSHOT_READ
(...skipping 1758 matching lines...) Expand 10 before | Expand all | Expand 10 after
2255 2267
2256 // Write out the class information. 2268 // Write out the class information.
2257 WriteIndexedObject(class_id); 2269 WriteIndexedObject(class_id);
2258 WriteTags(tags); 2270 WriteTags(tags);
2259 2271
2260 // Write out the length field. 2272 // Write out the length field.
2261 Write<RawObject*>(rawarray->ptr()->length_); 2273 Write<RawObject*>(rawarray->ptr()->length_);
2262 2274
2263 return; 2275 return;
2264 } 2276 }
2277 if (class_id == kObjectPoolCid) {
2278 intptr_t tags = GetObjectTags(raw);
2279
2280 // Object is being referenced, add it to the forward ref list and mark
2281 // it so that future references to this object in the snapshot will use
2282 // this object id. Mark it as not having been serialized yet so that we
2283 // will serialize the object when we go through the forward list.
2284 forward_list_->MarkAndAddObject(raw, kIsNotSerialized);
2285
2286 RawObjectPool* rawpool = reinterpret_cast<RawObjectPool*>(raw);
2287
2288 // Write out the serialization header value for this object.
2289 WriteInlinedObjectHeader(kOmittedObjectId);
2290
2291 // Write out the class information.
2292 WriteVMIsolateObject(kObjectPoolCid);
2293 WriteTags(tags);
2294
2295 // Write out the length field.
2296 Write<intptr_t>(rawpool->ptr()->length_);
2297
2298 return;
2299 }
2265 // Add object to the forward ref list and mark it so that future references 2300 // Add object to the forward ref list and mark it so that future references
2266 // to this object in the snapshot will use this object id. Mark it as having 2301 // to this object in the snapshot will use this object id. Mark it as having
2267 // been serialized so that we do not serialize the object when we go through 2302 // been serialized so that we do not serialize the object when we go through
2268 // the forward list. 2303 // the forward list.
2269 forward_list_->MarkAndAddObject(raw, kIsSerialized); 2304 forward_list_->MarkAndAddObject(raw, kIsSerialized);
2270 switch (class_id) { 2305 switch (class_id) {
2271 #define SNAPSHOT_WRITE(clazz) \ 2306 #define SNAPSHOT_WRITE(clazz) \
2272 case clazz::kClassId: { \ 2307 case clazz::kClassId: { \
2273 Raw##clazz* raw_obj = reinterpret_cast<Raw##clazz*>(raw); \ 2308 Raw##clazz* raw_obj = reinterpret_cast<Raw##clazz*>(raw); \
2274 raw_obj->WriteTo(this, kOmittedObjectId, kind_); \ 2309 raw_obj->WriteTo(this, kOmittedObjectId, kind_); \
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
2791 NoSafepointScope no_safepoint; 2826 NoSafepointScope no_safepoint;
2792 WriteObject(obj.raw()); 2827 WriteObject(obj.raw());
2793 UnmarkAll(); 2828 UnmarkAll();
2794 } else { 2829 } else {
2795 ThrowException(exception_type(), exception_msg()); 2830 ThrowException(exception_type(), exception_msg());
2796 } 2831 }
2797 } 2832 }
2798 2833
2799 2834
2800 } // namespace dart 2835 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/raw_object_snapshot.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698