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

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

Issue 2750193002: Fix for issue 28854. (Closed)
Patch Set: Adjust status file for dartium as the test will fail because Isolate.spawn is used. Created 3 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
« no previous file with comments | « no previous file | tests/standalone/regress_28854_1_test.dart » ('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 "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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 LongJumpScope jump; 233 LongJumpScope jump;
234 if (setjmp(*jump.Set()) == 0) { 234 if (setjmp(*jump.Set()) == 0) {
235 PassiveObject& obj = 235 PassiveObject& obj =
236 PassiveObject::Handle(zone(), ReadObjectImpl(kAsInlinedObject)); 236 PassiveObject::Handle(zone(), ReadObjectImpl(kAsInlinedObject));
237 for (intptr_t i = 0; i < backward_references_->length(); i++) { 237 for (intptr_t i = 0; i < backward_references_->length(); i++) {
238 if (!(*backward_references_)[i].is_deserialized()) { 238 if (!(*backward_references_)[i].is_deserialized()) {
239 ReadObjectImpl(kAsInlinedObject); 239 ReadObjectImpl(kAsInlinedObject);
240 (*backward_references_)[i].set_state(kIsDeserialized); 240 (*backward_references_)[i].set_state(kIsDeserialized);
241 } 241 }
242 } 242 }
243 ProcessDeferredCanonicalizations(); 243 if (backward_references_->length() > 0) {
244 return obj.raw(); 244 ProcessDeferredCanonicalizations();
245 return (*backward_references_)[0].reference()->raw();
246 } else {
247 return obj.raw();
248 }
245 } else { 249 } else {
246 // An error occurred while reading, return the error object. 250 // An error occurred while reading, return the error object.
247 const Error& err = Error::Handle(thread()->sticky_error()); 251 const Error& err = Error::Handle(thread()->sticky_error());
248 thread()->clear_sticky_error(); 252 thread()->clear_sticky_error();
249 return err.raw(); 253 return err.raw();
250 } 254 }
251 } 255 }
252 256
253 257
254 RawClass* SnapshotReader::ReadClassId(intptr_t object_id) { 258 RawClass* SnapshotReader::ReadClassId(intptr_t object_id) {
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 intptr_t next_field_offset = cls_.next_field_offset(); 508 intptr_t next_field_offset = cls_.next_field_offset();
505 509
506 intptr_t type_argument_field_offset = cls_.type_arguments_field_offset(); 510 intptr_t type_argument_field_offset = cls_.type_arguments_field_offset();
507 ASSERT(next_field_offset > 0); 511 ASSERT(next_field_offset > 0);
508 // Instance::NextFieldOffset() returns the offset of the first field in 512 // Instance::NextFieldOffset() returns the offset of the first field in
509 // a Dart object. 513 // a Dart object.
510 bool read_as_reference = RawObject::IsCanonical(tags) ? false : true; 514 bool read_as_reference = RawObject::IsCanonical(tags) ? false : true;
511 intptr_t offset = Instance::NextFieldOffset(); 515 intptr_t offset = Instance::NextFieldOffset();
512 intptr_t result_cid = result->GetClassId(); 516 intptr_t result_cid = result->GetClassId();
513 while (offset < next_field_offset) { 517 while (offset < next_field_offset) {
514 pobj_ = ReadObjectImpl(read_as_reference); 518 pobj_ =
519 ReadObjectImpl(read_as_reference, object_id, (offset / kWordSize));
515 result->SetFieldAtOffset(offset, pobj_); 520 result->SetFieldAtOffset(offset, pobj_);
516 if ((offset != type_argument_field_offset) && 521 if ((offset != type_argument_field_offset) &&
517 (kind_ == Snapshot::kMessage) && isolate()->use_field_guards()) { 522 (kind_ == Snapshot::kMessage) && isolate()->use_field_guards()) {
518 // TODO(fschneider): Consider hoisting these lookups out of the loop. 523 // TODO(fschneider): Consider hoisting these lookups out of the loop.
519 // This would involve creating a handle, since cls_ can't be reused 524 // This would involve creating a handle, since cls_ can't be reused
520 // across the call to ReadObjectImpl. 525 // across the call to ReadObjectImpl.
521 cls_ = isolate()->class_table()->At(result_cid); 526 cls_ = isolate()->class_table()->At(result_cid);
522 array_ = cls_.OffsetToFieldMap(); 527 array_ = cls_.OffsetToFieldMap();
523 field_ ^= array_.At(offset >> kWordSizeLog2); 528 field_ ^= array_.At(offset >> kWordSizeLog2);
524 ASSERT(!field_.IsNull()); 529 ASSERT(!field_.IsNull());
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after
1210 typeobj ^= objref->raw(); 1215 typeobj ^= objref->raw();
1211 newobj = typeobj.Canonicalize(); 1216 newobj = typeobj.Canonicalize();
1212 } else { 1217 } else {
1213 ASSERT(objref->IsTypeArguments()); 1218 ASSERT(objref->IsTypeArguments());
1214 typeargs ^= objref->raw(); 1219 typeargs ^= objref->raw();
1215 newobj = typeargs.Canonicalize(); 1220 newobj = typeargs.Canonicalize();
1216 } 1221 }
1217 if (newobj.raw() != objref->raw()) { 1222 if (newobj.raw() != objref->raw()) {
1218 ZoneGrowableArray<intptr_t>* patches = backref.patch_records(); 1223 ZoneGrowableArray<intptr_t>* patches = backref.patch_records();
1219 ASSERT(newobj.IsNull() || newobj.IsCanonical()); 1224 ASSERT(newobj.IsNull() || newobj.IsCanonical());
1220 ASSERT(patches != NULL);
1221 // First we replace the back ref table with the canonical object. 1225 // First we replace the back ref table with the canonical object.
1222 *objref = newobj.raw(); 1226 *objref = newobj.raw();
1223 // Now we go over all the patch records and patch the canonical object. 1227 if (patches != NULL) {
1224 for (intptr_t j = 0; j < patches->length(); j += 2) { 1228 // Now go over all the patch records and patch the canonical object.
1225 NoSafepointScope no_safepoint; 1229 for (intptr_t j = 0; j < patches->length(); j += 2) {
1226 intptr_t patch_object_id = (*patches)[j]; 1230 NoSafepointScope no_safepoint;
1227 intptr_t patch_offset = (*patches)[j + 1]; 1231 intptr_t patch_object_id = (*patches)[j];
1228 Object* target = GetBackRef(patch_object_id); 1232 intptr_t patch_offset = (*patches)[j + 1];
1229 // We should not backpatch an object that is canonical. 1233 Object* target = GetBackRef(patch_object_id);
1230 if (!target->IsCanonical()) { 1234 // We should not backpatch an object that is canonical.
1231 RawObject** rawptr = 1235 if (!target->IsCanonical()) {
1232 reinterpret_cast<RawObject**>(target->raw()->ptr()); 1236 RawObject** rawptr =
1233 target->StorePointer((rawptr + patch_offset), newobj.raw()); 1237 reinterpret_cast<RawObject**>(target->raw()->ptr());
1238 target->StorePointer((rawptr + patch_offset), newobj.raw());
1239 }
1234 } 1240 }
1235 } 1241 }
1236 } else { 1242 } else {
1237 ASSERT(objref->IsCanonical()); 1243 ASSERT(objref->IsCanonical());
1238 } 1244 }
1239 } 1245 }
1240 } 1246 }
1241 } 1247 }
1242 1248
1243 1249
(...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after
2046 *buffer_len_ = BytesWritten(); 2052 *buffer_len_ = BytesWritten();
2047 } 2053 }
2048 } else { 2054 } else {
2049 FreeBuffer(); 2055 FreeBuffer();
2050 ThrowException(exception_type(), exception_msg()); 2056 ThrowException(exception_type(), exception_msg());
2051 } 2057 }
2052 } 2058 }
2053 2059
2054 2060
2055 } // namespace dart 2061 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | tests/standalone/regress_28854_1_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698