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

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

Issue 1263843004: Temporary fix for pub crash by canonicalizing type only if the IsCreatedFromSnapshot bit is true (i… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: fix-test 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
« no previous file with comments | « no previous file | runtime/vm/snapshot_test.cc » ('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/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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 203
204 RawType* Type::ReadFrom(SnapshotReader* reader, 204 RawType* Type::ReadFrom(SnapshotReader* reader,
205 intptr_t object_id, 205 intptr_t object_id,
206 intptr_t tags, 206 intptr_t tags,
207 Snapshot::Kind kind) { 207 Snapshot::Kind kind) {
208 ASSERT(reader != NULL); 208 ASSERT(reader != NULL);
209 209
210 // Allocate type object. 210 // Allocate type object.
211 Type& type = Type::ZoneHandle(reader->zone(), NEW_OBJECT(Type)); 211 Type& type = Type::ZoneHandle(reader->zone(), NEW_OBJECT(Type));
212 bool is_canonical = RawObject::IsCanonical(tags); 212 bool is_canonical = RawObject::IsCanonical(tags);
213 bool defer_canonicalization = is_canonical && (kind != Snapshot::kFull); 213 bool defer_canonicalization = is_canonical &&
214 ((kind == Snapshot::kScript && RawObject::IsCreatedFromSnapshot(tags)) ||
215 kind == Snapshot::kMessage);
214 reader->AddBackRef(object_id, &type, kIsDeserialized, defer_canonicalization); 216 reader->AddBackRef(object_id, &type, kIsDeserialized, defer_canonicalization);
215 217
216 // Set all non object fields. 218 // Set all non object fields.
217 type.set_token_pos(reader->Read<int32_t>()); 219 type.set_token_pos(reader->Read<int32_t>());
218 type.set_type_state(reader->Read<int8_t>()); 220 type.set_type_state(reader->Read<int8_t>());
219 221
220 // Set all the object fields. 222 // Set all the object fields.
221 // TODO(5411462): Need to assert No GC can happen here, even though 223 // TODO(5411462): Need to assert No GC can happen here, even though
222 // allocations may happen. 224 // allocations may happen.
223 intptr_t num_flds = (type.raw()->to() - type.raw()->from()); 225 intptr_t num_flds = (type.raw()->to() - type.raw()->from());
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 intptr_t tags, 446 intptr_t tags,
445 Snapshot::Kind kind) { 447 Snapshot::Kind kind) {
446 ASSERT(reader != NULL); 448 ASSERT(reader != NULL);
447 449
448 // Read the length so that we can determine instance size to allocate. 450 // Read the length so that we can determine instance size to allocate.
449 intptr_t len = reader->ReadSmiValue(); 451 intptr_t len = reader->ReadSmiValue();
450 452
451 TypeArguments& type_arguments = TypeArguments::ZoneHandle( 453 TypeArguments& type_arguments = TypeArguments::ZoneHandle(
452 reader->zone(), NEW_OBJECT_WITH_LEN_SPACE(TypeArguments, len, kind)); 454 reader->zone(), NEW_OBJECT_WITH_LEN_SPACE(TypeArguments, len, kind));
453 bool is_canonical = RawObject::IsCanonical(tags); 455 bool is_canonical = RawObject::IsCanonical(tags);
454 bool defer_canonicalization = is_canonical && (kind != Snapshot::kFull); 456 bool defer_canonicalization = is_canonical &&
457 ((kind == Snapshot::kScript && RawObject::IsCreatedFromSnapshot(tags)) ||
458 kind == Snapshot::kMessage);
455 reader->AddBackRef(object_id, 459 reader->AddBackRef(object_id,
456 &type_arguments, 460 &type_arguments,
457 kIsDeserialized, 461 kIsDeserialized,
458 defer_canonicalization); 462 defer_canonicalization);
459 463
460 // Set the instantiations field, which is only read from a full snapshot. 464 // Set the instantiations field, which is only read from a full snapshot.
461 if (kind == Snapshot::kFull) { 465 if (kind == Snapshot::kFull) {
462 *(reader->ArrayHandle()) ^= reader->ReadObjectImpl(kAsInlinedObject); 466 *(reader->ArrayHandle()) ^= reader->ReadObjectImpl(kAsInlinedObject);
463 type_arguments.set_instantiations(*(reader->ArrayHandle())); 467 type_arguments.set_instantiations(*(reader->ArrayHandle()));
464 } else { 468 } else {
(...skipping 2633 matching lines...) Expand 10 before | Expand all | Expand 10 after
3098 // We do not allow objects with native fields in an isolate message. 3102 // We do not allow objects with native fields in an isolate message.
3099 writer->SetWriteException(Exceptions::kArgument, 3103 writer->SetWriteException(Exceptions::kArgument,
3100 "Illegal argument in isolate message" 3104 "Illegal argument in isolate message"
3101 " : (object is a UserTag)"); 3105 " : (object is a UserTag)");
3102 } else { 3106 } else {
3103 UNREACHABLE(); 3107 UNREACHABLE();
3104 } 3108 }
3105 } 3109 }
3106 3110
3107 } // namespace dart 3111 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/snapshot_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698