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

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

Issue 1012333002: Keep zone cached in SnapshotReader to allow removing ZoneHandle(Isolate*) interface. (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') | runtime/vm/service_isolate.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 10 matching lines...) Expand all
21 ((kind == Snapshot::kFull) ? \ 21 ((kind == Snapshot::kFull) ? \
22 reader->New##type(len) : type::New(len, HEAP_SPACE(kind))) 22 reader->New##type(len) : type::New(len, HEAP_SPACE(kind)))
23 23
24 24
25 RawClass* Class::ReadFrom(SnapshotReader* reader, 25 RawClass* Class::ReadFrom(SnapshotReader* reader,
26 intptr_t object_id, 26 intptr_t object_id,
27 intptr_t tags, 27 intptr_t tags,
28 Snapshot::Kind kind) { 28 Snapshot::Kind kind) {
29 ASSERT(reader != NULL); 29 ASSERT(reader != NULL);
30 30
31 Class& cls = Class::ZoneHandle(reader->isolate(), Class::null()); 31 Class& cls = Class::ZoneHandle(reader->zone(), Class::null());
32 if ((kind == Snapshot::kFull) || 32 if ((kind == Snapshot::kFull) ||
33 (kind == Snapshot::kScript && !RawObject::IsCreatedFromSnapshot(tags))) { 33 (kind == Snapshot::kScript && !RawObject::IsCreatedFromSnapshot(tags))) {
34 // Read in the base information. 34 // Read in the base information.
35 int32_t class_id = reader->Read<int32_t>(); 35 int32_t class_id = reader->Read<int32_t>();
36 36
37 // Allocate class object of specified kind. 37 // Allocate class object of specified kind.
38 if (kind == Snapshot::kFull) { 38 if (kind == Snapshot::kFull) {
39 cls = reader->NewClass(class_id); 39 cls = reader->NewClass(class_id);
40 } else { 40 } else {
41 if (class_id < kNumPredefinedCids) { 41 if (class_id < kNumPredefinedCids) {
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 132
133 133
134 RawUnresolvedClass* UnresolvedClass::ReadFrom(SnapshotReader* reader, 134 RawUnresolvedClass* UnresolvedClass::ReadFrom(SnapshotReader* reader,
135 intptr_t object_id, 135 intptr_t object_id,
136 intptr_t tags, 136 intptr_t tags,
137 Snapshot::Kind kind) { 137 Snapshot::Kind kind) {
138 ASSERT(reader != NULL); 138 ASSERT(reader != NULL);
139 139
140 // Allocate unresolved class object. 140 // Allocate unresolved class object.
141 UnresolvedClass& unresolved_class = UnresolvedClass::ZoneHandle( 141 UnresolvedClass& unresolved_class = UnresolvedClass::ZoneHandle(
142 reader->isolate(), NEW_OBJECT(UnresolvedClass)); 142 reader->zone(), NEW_OBJECT(UnresolvedClass));
143 reader->AddBackRef(object_id, &unresolved_class, kIsDeserialized); 143 reader->AddBackRef(object_id, &unresolved_class, kIsDeserialized);
144 144
145 // Set the object tags. 145 // Set the object tags.
146 unresolved_class.set_tags(tags); 146 unresolved_class.set_tags(tags);
147 147
148 // Set all non object fields. 148 // Set all non object fields.
149 unresolved_class.set_token_pos(reader->Read<int32_t>()); 149 unresolved_class.set_token_pos(reader->Read<int32_t>());
150 150
151 // Set all the object fields. 151 // Set all the object fields.
152 // TODO(5411462): Need to assert No GC can happen here, even though 152 // TODO(5411462): Need to assert No GC can happen here, even though
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 } 199 }
200 200
201 201
202 RawType* Type::ReadFrom(SnapshotReader* reader, 202 RawType* Type::ReadFrom(SnapshotReader* reader,
203 intptr_t object_id, 203 intptr_t object_id,
204 intptr_t tags, 204 intptr_t tags,
205 Snapshot::Kind kind) { 205 Snapshot::Kind kind) {
206 ASSERT(reader != NULL); 206 ASSERT(reader != NULL);
207 207
208 // Allocate type object. 208 // Allocate type object.
209 Type& type = Type::ZoneHandle(reader->isolate(), NEW_OBJECT(Type)); 209 Type& type = Type::ZoneHandle(reader->zone(), NEW_OBJECT(Type));
210 reader->AddBackRef(object_id, &type, kIsDeserialized); 210 reader->AddBackRef(object_id, &type, kIsDeserialized);
211 211
212 // Set all non object fields. 212 // Set all non object fields.
213 type.set_token_pos(reader->Read<int32_t>()); 213 type.set_token_pos(reader->Read<int32_t>());
214 type.set_type_state(reader->Read<int8_t>()); 214 type.set_type_state(reader->Read<int8_t>());
215 215
216 // Set all the object fields. 216 // Set all the object fields.
217 // TODO(5411462): Need to assert No GC can happen here, even though 217 // TODO(5411462): Need to assert No GC can happen here, even though
218 // allocations may happen. 218 // allocations may happen.
219 intptr_t num_flds = (type.raw()->to() - type.raw()->from()); 219 intptr_t num_flds = (type.raw()->to() - type.raw()->from());
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 274
275 275
276 RawTypeRef* TypeRef::ReadFrom(SnapshotReader* reader, 276 RawTypeRef* TypeRef::ReadFrom(SnapshotReader* reader,
277 intptr_t object_id, 277 intptr_t object_id,
278 intptr_t tags, 278 intptr_t tags,
279 Snapshot::Kind kind) { 279 Snapshot::Kind kind) {
280 ASSERT(reader != NULL); 280 ASSERT(reader != NULL);
281 281
282 // Allocate type ref object. 282 // Allocate type ref object.
283 TypeRef& type_ref = TypeRef::ZoneHandle( 283 TypeRef& type_ref = TypeRef::ZoneHandle(
284 reader->isolate(), NEW_OBJECT(TypeRef)); 284 reader->zone(), NEW_OBJECT(TypeRef));
285 reader->AddBackRef(object_id, &type_ref, kIsDeserialized); 285 reader->AddBackRef(object_id, &type_ref, kIsDeserialized);
286 286
287 // Set the object tags. 287 // Set the object tags.
288 type_ref.set_tags(tags); 288 type_ref.set_tags(tags);
289 289
290 // Set all the object fields. 290 // Set all the object fields.
291 // TODO(5411462): Need to assert No GC can happen here, even though 291 // TODO(5411462): Need to assert No GC can happen here, even though
292 // allocations may happen. 292 // allocations may happen.
293 intptr_t num_flds = (type_ref.raw()->to() - type_ref.raw()->from()); 293 intptr_t num_flds = (type_ref.raw()->to() - type_ref.raw()->from());
294 for (intptr_t i = 0; i <= num_flds; i++) { 294 for (intptr_t i = 0; i <= num_flds; i++) {
(...skipping 25 matching lines...) Expand all
320 320
321 321
322 RawTypeParameter* TypeParameter::ReadFrom(SnapshotReader* reader, 322 RawTypeParameter* TypeParameter::ReadFrom(SnapshotReader* reader,
323 intptr_t object_id, 323 intptr_t object_id,
324 intptr_t tags, 324 intptr_t tags,
325 Snapshot::Kind kind) { 325 Snapshot::Kind kind) {
326 ASSERT(reader != NULL); 326 ASSERT(reader != NULL);
327 327
328 // Allocate type parameter object. 328 // Allocate type parameter object.
329 TypeParameter& type_parameter = TypeParameter::ZoneHandle( 329 TypeParameter& type_parameter = TypeParameter::ZoneHandle(
330 reader->isolate(), NEW_OBJECT(TypeParameter)); 330 reader->zone(), NEW_OBJECT(TypeParameter));
331 reader->AddBackRef(object_id, &type_parameter, kIsDeserialized); 331 reader->AddBackRef(object_id, &type_parameter, kIsDeserialized);
332 332
333 // Set the object tags. 333 // Set the object tags.
334 type_parameter.set_tags(tags); 334 type_parameter.set_tags(tags);
335 335
336 // Set all non object fields. 336 // Set all non object fields.
337 type_parameter.set_index(reader->Read<int32_t>()); 337 type_parameter.set_index(reader->Read<int32_t>());
338 type_parameter.set_token_pos(reader->Read<int32_t>()); 338 type_parameter.set_token_pos(reader->Read<int32_t>());
339 type_parameter.set_type_state(reader->Read<int8_t>()); 339 type_parameter.set_type_state(reader->Read<int8_t>());
340 340
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 380
381 381
382 RawBoundedType* BoundedType::ReadFrom(SnapshotReader* reader, 382 RawBoundedType* BoundedType::ReadFrom(SnapshotReader* reader,
383 intptr_t object_id, 383 intptr_t object_id,
384 intptr_t tags, 384 intptr_t tags,
385 Snapshot::Kind kind) { 385 Snapshot::Kind kind) {
386 ASSERT(reader != NULL); 386 ASSERT(reader != NULL);
387 387
388 // Allocate bounded type object. 388 // Allocate bounded type object.
389 BoundedType& bounded_type = BoundedType::ZoneHandle( 389 BoundedType& bounded_type = BoundedType::ZoneHandle(
390 reader->isolate(), NEW_OBJECT(BoundedType)); 390 reader->zone(), NEW_OBJECT(BoundedType));
391 reader->AddBackRef(object_id, &bounded_type, kIsDeserialized); 391 reader->AddBackRef(object_id, &bounded_type, kIsDeserialized);
392 392
393 // Set the object tags. 393 // Set the object tags.
394 bounded_type.set_tags(tags); 394 bounded_type.set_tags(tags);
395 395
396 // Set all the object fields. 396 // Set all the object fields.
397 // TODO(5411462): Need to assert No GC can happen here, even though 397 // TODO(5411462): Need to assert No GC can happen here, even though
398 // allocations may happen. 398 // allocations may happen.
399 intptr_t num_flds = (bounded_type.raw()->to() - 399 intptr_t num_flds = (bounded_type.raw()->to() -
400 bounded_type.raw()->from()); 400 bounded_type.raw()->from());
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 RawTypeArguments* TypeArguments::ReadFrom(SnapshotReader* reader, 445 RawTypeArguments* TypeArguments::ReadFrom(SnapshotReader* reader,
446 intptr_t object_id, 446 intptr_t object_id,
447 intptr_t tags, 447 intptr_t tags,
448 Snapshot::Kind kind) { 448 Snapshot::Kind kind) {
449 ASSERT(reader != NULL); 449 ASSERT(reader != NULL);
450 450
451 // Read the length so that we can determine instance size to allocate. 451 // Read the length so that we can determine instance size to allocate.
452 intptr_t len = reader->ReadSmiValue(); 452 intptr_t len = reader->ReadSmiValue();
453 453
454 TypeArguments& type_arguments = TypeArguments::ZoneHandle( 454 TypeArguments& type_arguments = TypeArguments::ZoneHandle(
455 reader->isolate(), NEW_OBJECT_WITH_LEN_SPACE(TypeArguments, len, kind)); 455 reader->zone(), NEW_OBJECT_WITH_LEN_SPACE(TypeArguments, len, kind));
456 reader->AddBackRef(object_id, &type_arguments, kIsDeserialized); 456 reader->AddBackRef(object_id, &type_arguments, kIsDeserialized);
457 457
458 // Set the instantiations field, which is only read from a full snapshot. 458 // Set the instantiations field, which is only read from a full snapshot.
459 if (kind == Snapshot::kFull) { 459 if (kind == Snapshot::kFull) {
460 *(reader->ArrayHandle()) ^= reader->ReadObjectImpl(); 460 *(reader->ArrayHandle()) ^= reader->ReadObjectImpl();
461 type_arguments.set_instantiations(*(reader->ArrayHandle())); 461 type_arguments.set_instantiations(*(reader->ArrayHandle()));
462 } else { 462 } else {
463 type_arguments.set_instantiations(Object::zero_array()); 463 type_arguments.set_instantiations(Object::zero_array());
464 } 464 }
465 465
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 RawPatchClass* PatchClass::ReadFrom(SnapshotReader* reader, 524 RawPatchClass* PatchClass::ReadFrom(SnapshotReader* reader,
525 intptr_t object_id, 525 intptr_t object_id,
526 intptr_t tags, 526 intptr_t tags,
527 Snapshot::Kind kind) { 527 Snapshot::Kind kind) {
528 ASSERT(reader != NULL); 528 ASSERT(reader != NULL);
529 ASSERT(((kind == Snapshot::kScript) && 529 ASSERT(((kind == Snapshot::kScript) &&
530 !RawObject::IsCreatedFromSnapshot(tags)) || 530 !RawObject::IsCreatedFromSnapshot(tags)) ||
531 (kind == Snapshot::kFull)); 531 (kind == Snapshot::kFull));
532 532
533 // Allocate function object. 533 // Allocate function object.
534 PatchClass& cls = PatchClass::ZoneHandle(reader->isolate(), 534 PatchClass& cls = PatchClass::ZoneHandle(reader->zone(),
535 NEW_OBJECT(PatchClass)); 535 NEW_OBJECT(PatchClass));
536 reader->AddBackRef(object_id, &cls, kIsDeserialized); 536 reader->AddBackRef(object_id, &cls, kIsDeserialized);
537 537
538 // Set the object tags. 538 // Set the object tags.
539 cls.set_tags(tags); 539 cls.set_tags(tags);
540 540
541 // Set all the object fields. 541 // Set all the object fields.
542 // TODO(5411462): Need to assert No GC can happen here, even though 542 // TODO(5411462): Need to assert No GC can happen here, even though
543 // allocations may happen. 543 // allocations may happen.
544 intptr_t num_flds = (cls.raw()->to() - cls.raw()->from()); 544 intptr_t num_flds = (cls.raw()->to() - cls.raw()->from());
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 intptr_t object_id, 576 intptr_t object_id,
577 intptr_t tags, 577 intptr_t tags,
578 Snapshot::Kind kind) { 578 Snapshot::Kind kind) {
579 ASSERT(reader != NULL); 579 ASSERT(reader != NULL);
580 ASSERT(((kind == Snapshot::kScript) && 580 ASSERT(((kind == Snapshot::kScript) &&
581 !RawObject::IsCreatedFromSnapshot(tags)) || 581 !RawObject::IsCreatedFromSnapshot(tags)) ||
582 (kind == Snapshot::kFull)); 582 (kind == Snapshot::kFull));
583 583
584 // Allocate closure data object. 584 // Allocate closure data object.
585 ClosureData& data = ClosureData::ZoneHandle( 585 ClosureData& data = ClosureData::ZoneHandle(
586 reader->isolate(), NEW_OBJECT(ClosureData)); 586 reader->zone(), NEW_OBJECT(ClosureData));
587 reader->AddBackRef(object_id, &data, kIsDeserialized); 587 reader->AddBackRef(object_id, &data, kIsDeserialized);
588 588
589 // Set the object tags. 589 // Set the object tags.
590 data.set_tags(tags); 590 data.set_tags(tags);
591 591
592 // Set all the object fields. 592 // Set all the object fields.
593 // TODO(5411462): Need to assert No GC can happen here, even though 593 // TODO(5411462): Need to assert No GC can happen here, even though
594 // allocations may happen. 594 // allocations may happen.
595 intptr_t num_flds = (data.raw()->to() - data.raw()->from()); 595 intptr_t num_flds = (data.raw()->to() - data.raw()->from());
596 for (intptr_t i = 0; i <= num_flds; i++) { 596 for (intptr_t i = 0; i <= num_flds; i++) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 intptr_t object_id, 636 intptr_t object_id,
637 intptr_t tags, 637 intptr_t tags,
638 Snapshot::Kind kind) { 638 Snapshot::Kind kind) {
639 ASSERT(reader != NULL); 639 ASSERT(reader != NULL);
640 ASSERT(((kind == Snapshot::kScript) && 640 ASSERT(((kind == Snapshot::kScript) &&
641 !RawObject::IsCreatedFromSnapshot(tags)) || 641 !RawObject::IsCreatedFromSnapshot(tags)) ||
642 (kind == Snapshot::kFull)); 642 (kind == Snapshot::kFull));
643 643
644 // Allocate redirection data object. 644 // Allocate redirection data object.
645 RedirectionData& data = RedirectionData::ZoneHandle( 645 RedirectionData& data = RedirectionData::ZoneHandle(
646 reader->isolate(), NEW_OBJECT(RedirectionData)); 646 reader->zone(), NEW_OBJECT(RedirectionData));
647 reader->AddBackRef(object_id, &data, kIsDeserialized); 647 reader->AddBackRef(object_id, &data, kIsDeserialized);
648 648
649 // Set the object tags. 649 // Set the object tags.
650 data.set_tags(tags); 650 data.set_tags(tags);
651 651
652 // Set all the object fields. 652 // Set all the object fields.
653 // TODO(5411462): Need to assert No GC can happen here, even though 653 // TODO(5411462): Need to assert No GC can happen here, even though
654 // allocations may happen. 654 // allocations may happen.
655 intptr_t num_flds = (data.raw()->to() - data.raw()->from()); 655 intptr_t num_flds = (data.raw()->to() - data.raw()->from());
656 for (intptr_t i = 0; i <= num_flds; i++) { 656 for (intptr_t i = 0; i <= num_flds; i++) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 intptr_t object_id, 688 intptr_t object_id,
689 intptr_t tags, 689 intptr_t tags,
690 Snapshot::Kind kind) { 690 Snapshot::Kind kind) {
691 ASSERT(reader != NULL); 691 ASSERT(reader != NULL);
692 ASSERT(((kind == Snapshot::kScript) && 692 ASSERT(((kind == Snapshot::kScript) &&
693 !RawObject::IsCreatedFromSnapshot(tags)) || 693 !RawObject::IsCreatedFromSnapshot(tags)) ||
694 (kind == Snapshot::kFull)); 694 (kind == Snapshot::kFull));
695 695
696 // Allocate function object. 696 // Allocate function object.
697 Function& func = Function::ZoneHandle( 697 Function& func = Function::ZoneHandle(
698 reader->isolate(), NEW_OBJECT(Function)); 698 reader->zone(), NEW_OBJECT(Function));
699 reader->AddBackRef(object_id, &func, kIsDeserialized); 699 reader->AddBackRef(object_id, &func, kIsDeserialized);
700 700
701 // Set the object tags. 701 // Set the object tags.
702 func.set_tags(tags); 702 func.set_tags(tags);
703 703
704 // Set all the non object fields. 704 // Set all the non object fields.
705 func.set_token_pos(reader->Read<int32_t>()); 705 func.set_token_pos(reader->Read<int32_t>());
706 func.set_end_token_pos(reader->Read<int32_t>()); 706 func.set_end_token_pos(reader->Read<int32_t>());
707 func.set_usage_counter(reader->Read<int32_t>()); 707 func.set_usage_counter(reader->Read<int32_t>());
708 func.set_num_fixed_parameters(reader->Read<int16_t>()); 708 func.set_num_fixed_parameters(reader->Read<int16_t>());
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 RawField* Field::ReadFrom(SnapshotReader* reader, 766 RawField* Field::ReadFrom(SnapshotReader* reader,
767 intptr_t object_id, 767 intptr_t object_id,
768 intptr_t tags, 768 intptr_t tags,
769 Snapshot::Kind kind) { 769 Snapshot::Kind kind) {
770 ASSERT(reader != NULL); 770 ASSERT(reader != NULL);
771 ASSERT(((kind == Snapshot::kScript) && 771 ASSERT(((kind == Snapshot::kScript) &&
772 !RawObject::IsCreatedFromSnapshot(tags)) || 772 !RawObject::IsCreatedFromSnapshot(tags)) ||
773 (kind == Snapshot::kFull)); 773 (kind == Snapshot::kFull));
774 774
775 // Allocate field object. 775 // Allocate field object.
776 Field& field = Field::ZoneHandle(reader->isolate(), NEW_OBJECT(Field)); 776 Field& field = Field::ZoneHandle(reader->zone(), NEW_OBJECT(Field));
777 reader->AddBackRef(object_id, &field, kIsDeserialized); 777 reader->AddBackRef(object_id, &field, kIsDeserialized);
778 778
779 // Set the object tags. 779 // Set the object tags.
780 field.set_tags(tags); 780 field.set_tags(tags);
781 781
782 // Set all non object fields. 782 // Set all non object fields.
783 field.set_token_pos(reader->Read<int32_t>()); 783 field.set_token_pos(reader->Read<int32_t>());
784 field.set_guarded_cid(reader->Read<int32_t>()); 784 field.set_guarded_cid(reader->Read<int32_t>());
785 field.set_is_nullable(reader->Read<int32_t>()); 785 field.set_is_nullable(reader->Read<int32_t>());
786 field.set_kind_bits(reader->Read<uint8_t>()); 786 field.set_kind_bits(reader->Read<uint8_t>());
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 830
831 RawLiteralToken* LiteralToken::ReadFrom(SnapshotReader* reader, 831 RawLiteralToken* LiteralToken::ReadFrom(SnapshotReader* reader,
832 intptr_t object_id, 832 intptr_t object_id,
833 intptr_t tags, 833 intptr_t tags,
834 Snapshot::Kind kind) { 834 Snapshot::Kind kind) {
835 ASSERT(reader != NULL); 835 ASSERT(reader != NULL);
836 ASSERT(kind != Snapshot::kMessage); 836 ASSERT(kind != Snapshot::kMessage);
837 837
838 // Create the literal token object. 838 // Create the literal token object.
839 LiteralToken& literal_token = LiteralToken::ZoneHandle( 839 LiteralToken& literal_token = LiteralToken::ZoneHandle(
840 reader->isolate(), NEW_OBJECT(LiteralToken)); 840 reader->zone(), NEW_OBJECT(LiteralToken));
841 reader->AddBackRef(object_id, &literal_token, kIsDeserialized); 841 reader->AddBackRef(object_id, &literal_token, kIsDeserialized);
842 842
843 // Set the object tags. 843 // Set the object tags.
844 literal_token.set_tags(tags); 844 literal_token.set_tags(tags);
845 845
846 // Read the token attributes. 846 // Read the token attributes.
847 Token::Kind token_kind = static_cast<Token::Kind>(reader->Read<int32_t>()); 847 Token::Kind token_kind = static_cast<Token::Kind>(reader->Read<int32_t>());
848 literal_token.set_kind(token_kind); 848 literal_token.set_kind(token_kind);
849 849
850 // Set all the object fields. 850 // Set all the object fields.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 ASSERT(reader != NULL); 890 ASSERT(reader != NULL);
891 ASSERT(((kind == Snapshot::kScript) && 891 ASSERT(((kind == Snapshot::kScript) &&
892 !RawObject::IsCreatedFromSnapshot(tags)) || 892 !RawObject::IsCreatedFromSnapshot(tags)) ||
893 (kind == Snapshot::kFull)); 893 (kind == Snapshot::kFull));
894 894
895 // Read the length so that we can determine number of tokens to read. 895 // Read the length so that we can determine number of tokens to read.
896 intptr_t len = reader->ReadSmiValue(); 896 intptr_t len = reader->ReadSmiValue();
897 897
898 // Create the token stream object. 898 // Create the token stream object.
899 TokenStream& token_stream = TokenStream::ZoneHandle( 899 TokenStream& token_stream = TokenStream::ZoneHandle(
900 reader->isolate(), NEW_OBJECT_WITH_LEN(TokenStream, len)); 900 reader->zone(), NEW_OBJECT_WITH_LEN(TokenStream, len));
901 reader->AddBackRef(object_id, &token_stream, kIsDeserialized); 901 reader->AddBackRef(object_id, &token_stream, kIsDeserialized);
902 902
903 // Set the object tags. 903 // Set the object tags.
904 token_stream.set_tags(tags); 904 token_stream.set_tags(tags);
905 905
906 // Read the stream of tokens into the TokenStream object for script 906 // Read the stream of tokens into the TokenStream object for script
907 // snapshots as we made a copy of token stream. 907 // snapshots as we made a copy of token stream.
908 if (kind == Snapshot::kScript) { 908 if (kind == Snapshot::kScript) {
909 NoGCScope no_gc; 909 NoGCScope no_gc;
910 RawExternalTypedData* stream = token_stream.GetStream(); 910 RawExternalTypedData* stream = token_stream.GetStream();
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
953 RawScript* Script::ReadFrom(SnapshotReader* reader, 953 RawScript* Script::ReadFrom(SnapshotReader* reader,
954 intptr_t object_id, 954 intptr_t object_id,
955 intptr_t tags, 955 intptr_t tags,
956 Snapshot::Kind kind) { 956 Snapshot::Kind kind) {
957 ASSERT(reader != NULL); 957 ASSERT(reader != NULL);
958 ASSERT(((kind == Snapshot::kScript) && 958 ASSERT(((kind == Snapshot::kScript) &&
959 !RawObject::IsCreatedFromSnapshot(tags)) || 959 !RawObject::IsCreatedFromSnapshot(tags)) ||
960 (kind == Snapshot::kFull)); 960 (kind == Snapshot::kFull));
961 961
962 // Allocate script object. 962 // Allocate script object.
963 Script& script = Script::ZoneHandle(reader->isolate(), NEW_OBJECT(Script)); 963 Script& script = Script::ZoneHandle(reader->zone(), NEW_OBJECT(Script));
964 reader->AddBackRef(object_id, &script, kIsDeserialized); 964 reader->AddBackRef(object_id, &script, kIsDeserialized);
965 965
966 // Set the object tags. 966 // Set the object tags.
967 script.set_tags(tags); 967 script.set_tags(tags);
968 968
969 script.StoreNonPointer(&script.raw_ptr()->line_offset_, 969 script.StoreNonPointer(&script.raw_ptr()->line_offset_,
970 reader->Read<int32_t>()); 970 reader->Read<int32_t>());
971 script.StoreNonPointer(&script.raw_ptr()->col_offset_, 971 script.StoreNonPointer(&script.raw_ptr()->col_offset_,
972 reader->Read<int32_t>()); 972 reader->Read<int32_t>());
973 script.StoreNonPointer(&script.raw_ptr()->kind_, 973 script.StoreNonPointer(&script.raw_ptr()->kind_,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1017 } 1017 }
1018 1018
1019 1019
1020 RawLibrary* Library::ReadFrom(SnapshotReader* reader, 1020 RawLibrary* Library::ReadFrom(SnapshotReader* reader,
1021 intptr_t object_id, 1021 intptr_t object_id,
1022 intptr_t tags, 1022 intptr_t tags,
1023 Snapshot::Kind kind) { 1023 Snapshot::Kind kind) {
1024 ASSERT(reader != NULL); 1024 ASSERT(reader != NULL);
1025 ASSERT(kind != Snapshot::kMessage); 1025 ASSERT(kind != Snapshot::kMessage);
1026 1026
1027 Library& library = Library::ZoneHandle(reader->isolate(), Library::null()); 1027 Library& library = Library::ZoneHandle(reader->zone(), Library::null());
1028 reader->AddBackRef(object_id, &library, kIsDeserialized); 1028 reader->AddBackRef(object_id, &library, kIsDeserialized);
1029 1029
1030 if ((kind == Snapshot::kScript) && RawObject::IsCreatedFromSnapshot(tags)) { 1030 if ((kind == Snapshot::kScript) && RawObject::IsCreatedFromSnapshot(tags)) {
1031 ASSERT(kind != Snapshot::kFull); 1031 ASSERT(kind != Snapshot::kFull);
1032 // Lookup the object as it should already exist in the heap. 1032 // Lookup the object as it should already exist in the heap.
1033 *reader->StringHandle() ^= reader->ReadObjectImpl(); 1033 *reader->StringHandle() ^= reader->ReadObjectImpl();
1034 library = Library::LookupLibrary(*reader->StringHandle()); 1034 library = Library::LookupLibrary(*reader->StringHandle());
1035 } else { 1035 } else {
1036 // Allocate library object. 1036 // Allocate library object.
1037 library = NEW_OBJECT(Library); 1037 library = NEW_OBJECT(Library);
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1132 intptr_t object_id, 1132 intptr_t object_id,
1133 intptr_t tags, 1133 intptr_t tags,
1134 Snapshot::Kind kind) { 1134 Snapshot::Kind kind) {
1135 ASSERT(reader != NULL); 1135 ASSERT(reader != NULL);
1136 ASSERT(((kind == Snapshot::kScript) && 1136 ASSERT(((kind == Snapshot::kScript) &&
1137 !RawObject::IsCreatedFromSnapshot(tags)) || 1137 !RawObject::IsCreatedFromSnapshot(tags)) ||
1138 (kind == Snapshot::kFull)); 1138 (kind == Snapshot::kFull));
1139 1139
1140 // Allocate library prefix object. 1140 // Allocate library prefix object.
1141 LibraryPrefix& prefix = LibraryPrefix::ZoneHandle( 1141 LibraryPrefix& prefix = LibraryPrefix::ZoneHandle(
1142 reader->isolate(), NEW_OBJECT(LibraryPrefix)); 1142 reader->zone(), NEW_OBJECT(LibraryPrefix));
1143 reader->AddBackRef(object_id, &prefix, kIsDeserialized); 1143 reader->AddBackRef(object_id, &prefix, kIsDeserialized);
1144 1144
1145 // Set the object tags. 1145 // Set the object tags.
1146 prefix.set_tags(tags); 1146 prefix.set_tags(tags);
1147 1147
1148 // Set all non object fields. 1148 // Set all non object fields.
1149 prefix.StoreNonPointer(&prefix.raw_ptr()->num_imports_, 1149 prefix.StoreNonPointer(&prefix.raw_ptr()->num_imports_,
1150 reader->Read<int32_t>()); 1150 reader->Read<int32_t>());
1151 prefix.StoreNonPointer(&prefix.raw_ptr()->is_deferred_load_, 1151 prefix.StoreNonPointer(&prefix.raw_ptr()->is_deferred_load_,
1152 reader->Read<bool>()); 1152 reader->Read<bool>());
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1196 intptr_t object_id, 1196 intptr_t object_id,
1197 intptr_t tags, 1197 intptr_t tags,
1198 Snapshot::Kind kind) { 1198 Snapshot::Kind kind) {
1199 ASSERT(reader != NULL); 1199 ASSERT(reader != NULL);
1200 ASSERT(((kind == Snapshot::kScript) && 1200 ASSERT(((kind == Snapshot::kScript) &&
1201 !RawObject::IsCreatedFromSnapshot(tags)) || 1201 !RawObject::IsCreatedFromSnapshot(tags)) ||
1202 (kind == Snapshot::kFull)); 1202 (kind == Snapshot::kFull));
1203 1203
1204 // Allocate Namespace object. 1204 // Allocate Namespace object.
1205 Namespace& ns = Namespace::ZoneHandle( 1205 Namespace& ns = Namespace::ZoneHandle(
1206 reader->isolate(), NEW_OBJECT(Namespace)); 1206 reader->zone(), NEW_OBJECT(Namespace));
1207 reader->AddBackRef(object_id, &ns, kIsDeserialized); 1207 reader->AddBackRef(object_id, &ns, kIsDeserialized);
1208 1208
1209 // Set the object tags. 1209 // Set the object tags.
1210 ns.set_tags(tags); 1210 ns.set_tags(tags);
1211 1211
1212 // Set all the object fields. 1212 // Set all the object fields.
1213 // TODO(5411462): Need to assert No GC can happen here, even though 1213 // TODO(5411462): Need to assert No GC can happen here, even though
1214 // allocations may happen. 1214 // allocations may happen.
1215 intptr_t num_flds = (ns.raw()->to() - ns.raw()->from()); 1215 intptr_t num_flds = (ns.raw()->to() - ns.raw()->from());
1216 for (intptr_t i = 0; i <= num_flds; i++) { 1216 for (intptr_t i = 0; i <= num_flds; i++) {
(...skipping 142 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(reader->isolate()); 1369 Context& context = Context::ZoneHandle(reader->zone());
1370 reader->AddBackRef(object_id, &context, kIsDeserialized); 1370 reader->AddBackRef(object_id, &context, kIsDeserialized);
1371 if (num_vars == 0) { 1371 if (num_vars == 0) {
1372 context ^= reader->object_store()->empty_context(); 1372 context ^= reader->object_store()->empty_context();
1373 } else { 1373 } else {
1374 context ^= NEW_OBJECT_WITH_LEN(Context, num_vars); 1374 context ^= NEW_OBJECT_WITH_LEN(Context, num_vars);
1375 1375
1376 // Set the object tags. 1376 // Set the object tags.
1377 context.set_tags(tags); 1377 context.set_tags(tags);
1378 1378
1379 // Set all the object fields. 1379 // Set all the object fields.
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1494 1494
1495 1495
1496 RawApiError* ApiError::ReadFrom(SnapshotReader* reader, 1496 RawApiError* ApiError::ReadFrom(SnapshotReader* reader,
1497 intptr_t object_id, 1497 intptr_t object_id,
1498 intptr_t tags, 1498 intptr_t tags,
1499 Snapshot::Kind kind) { 1499 Snapshot::Kind kind) {
1500 ASSERT(reader != NULL); 1500 ASSERT(reader != NULL);
1501 1501
1502 // Allocate ApiError object. 1502 // Allocate ApiError object.
1503 ApiError& api_error = 1503 ApiError& api_error =
1504 ApiError::ZoneHandle(reader->isolate(), NEW_OBJECT(ApiError)); 1504 ApiError::ZoneHandle(reader->zone(), NEW_OBJECT(ApiError));
1505 reader->AddBackRef(object_id, &api_error, kIsDeserialized); 1505 reader->AddBackRef(object_id, &api_error, kIsDeserialized);
1506 1506
1507 // Set the object tags. 1507 // Set the object tags.
1508 api_error.set_tags(tags); 1508 api_error.set_tags(tags);
1509 1509
1510 // Set all the object fields. 1510 // Set all the object fields.
1511 // TODO(5411462): Need to assert No GC can happen here, even though 1511 // TODO(5411462): Need to assert No GC can happen here, even though
1512 // allocations may happen. 1512 // allocations may happen.
1513 intptr_t num_flds = (api_error.raw()->to() - api_error.raw()->from()); 1513 intptr_t num_flds = (api_error.raw()->to() - api_error.raw()->from());
1514 for (intptr_t i = 0; i <= num_flds; i++) { 1514 for (intptr_t i = 0; i <= num_flds; i++) {
(...skipping 25 matching lines...) Expand all
1540 1540
1541 1541
1542 RawLanguageError* LanguageError::ReadFrom(SnapshotReader* reader, 1542 RawLanguageError* LanguageError::ReadFrom(SnapshotReader* reader,
1543 intptr_t object_id, 1543 intptr_t object_id,
1544 intptr_t tags, 1544 intptr_t tags,
1545 Snapshot::Kind kind) { 1545 Snapshot::Kind kind) {
1546 ASSERT(reader != NULL); 1546 ASSERT(reader != NULL);
1547 1547
1548 // Allocate LanguageError object. 1548 // Allocate LanguageError object.
1549 LanguageError& language_error = 1549 LanguageError& language_error =
1550 LanguageError::ZoneHandle(reader->isolate(), NEW_OBJECT(LanguageError)); 1550 LanguageError::ZoneHandle(reader->zone(), NEW_OBJECT(LanguageError));
1551 reader->AddBackRef(object_id, &language_error, kIsDeserialized); 1551 reader->AddBackRef(object_id, &language_error, kIsDeserialized);
1552 1552
1553 // Set the object tags. 1553 // Set the object tags.
1554 language_error.set_tags(tags); 1554 language_error.set_tags(tags);
1555 1555
1556 // Set all non object fields. 1556 // Set all non object fields.
1557 language_error.set_token_pos(reader->Read<int32_t>()); 1557 language_error.set_token_pos(reader->Read<int32_t>());
1558 language_error.set_kind(reader->Read<uint8_t>()); 1558 language_error.set_kind(reader->Read<uint8_t>());
1559 1559
1560 // Set all the object fields. 1560 // Set all the object fields.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1592 SnapshotWriterVisitor visitor(writer); 1592 SnapshotWriterVisitor visitor(writer);
1593 visitor.VisitPointers(from(), to()); 1593 visitor.VisitPointers(from(), to());
1594 } 1594 }
1595 1595
1596 1596
1597 RawUnhandledException* UnhandledException::ReadFrom(SnapshotReader* reader, 1597 RawUnhandledException* UnhandledException::ReadFrom(SnapshotReader* reader,
1598 intptr_t object_id, 1598 intptr_t object_id,
1599 intptr_t tags, 1599 intptr_t tags,
1600 Snapshot::Kind kind) { 1600 Snapshot::Kind kind) {
1601 UnhandledException& result = UnhandledException::ZoneHandle( 1601 UnhandledException& result = UnhandledException::ZoneHandle(
1602 reader->isolate(), NEW_OBJECT(UnhandledException)); 1602 reader->zone(), NEW_OBJECT(UnhandledException));
1603 reader->AddBackRef(object_id, &result, kIsDeserialized); 1603 reader->AddBackRef(object_id, &result, kIsDeserialized);
1604 1604
1605 // Set the object tags. 1605 // Set the object tags.
1606 result.set_tags(tags); 1606 result.set_tags(tags);
1607 1607
1608 // Set all the object fields. 1608 // Set all the object fields.
1609 // TODO(5411462): Need to assert No GC can happen here, even though 1609 // TODO(5411462): Need to assert No GC can happen here, even though
1610 // allocations may happen. 1610 // allocations may happen.
1611 intptr_t num_flds = (result.raw()->to() - result.raw()->from()); 1611 intptr_t num_flds = (result.raw()->to() - result.raw()->from());
1612 for (intptr_t i = 0; i <= num_flds; i++) { 1612 for (intptr_t i = 0; i <= num_flds; i++) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1651 1651
1652 1652
1653 RawInstance* Instance::ReadFrom(SnapshotReader* reader, 1653 RawInstance* Instance::ReadFrom(SnapshotReader* reader,
1654 intptr_t object_id, 1654 intptr_t object_id,
1655 intptr_t tags, 1655 intptr_t tags,
1656 Snapshot::Kind kind) { 1656 Snapshot::Kind kind) {
1657 ASSERT(reader != NULL); 1657 ASSERT(reader != NULL);
1658 1658
1659 // Create an Instance object or get canonical one if it is a canonical 1659 // Create an Instance object or get canonical one if it is a canonical
1660 // constant. 1660 // constant.
1661 Instance& obj = Instance::ZoneHandle(reader->isolate(), Instance::null()); 1661 Instance& obj = Instance::ZoneHandle(reader->zone(), Instance::null());
1662 if (kind == Snapshot::kFull) { 1662 if (kind == Snapshot::kFull) {
1663 obj = reader->NewInstance(); 1663 obj = reader->NewInstance();
1664 } else { 1664 } else {
1665 obj ^= Object::Allocate(kInstanceCid, 1665 obj ^= Object::Allocate(kInstanceCid,
1666 Instance::InstanceSize(), 1666 Instance::InstanceSize(),
1667 HEAP_SPACE(kind)); 1667 HEAP_SPACE(kind));
1668 // When reading a script snapshot we need to canonicalize only those object 1668 // When reading a script snapshot we need to canonicalize only those object
1669 // references that are objects from the core library (loaded from a 1669 // references that are objects from the core library (loaded from a
1670 // full snapshot). Objects that are only in the script need not be 1670 // full snapshot). Objects that are only in the script need not be
1671 // canonicalized as they are already canonical. 1671 // canonicalized as they are already canonical.
(...skipping 30 matching lines...) Expand all
1702 RawMint* Mint::ReadFrom(SnapshotReader* reader, 1702 RawMint* Mint::ReadFrom(SnapshotReader* reader,
1703 intptr_t object_id, 1703 intptr_t object_id,
1704 intptr_t tags, 1704 intptr_t tags,
1705 Snapshot::Kind kind) { 1705 Snapshot::Kind kind) {
1706 ASSERT(reader != NULL); 1706 ASSERT(reader != NULL);
1707 1707
1708 // Read the 64 bit value for the object. 1708 // Read the 64 bit value for the object.
1709 int64_t value = reader->Read<int64_t>(); 1709 int64_t value = reader->Read<int64_t>();
1710 1710
1711 // Create a Mint object or get canonical one if it is a canonical constant. 1711 // Create a Mint object or get canonical one if it is a canonical constant.
1712 Mint& mint = Mint::ZoneHandle(reader->isolate(), Mint::null()); 1712 Mint& mint = Mint::ZoneHandle(reader->zone(), Mint::null());
1713 if (kind == Snapshot::kFull) { 1713 if (kind == Snapshot::kFull) {
1714 mint = reader->NewMint(value); 1714 mint = reader->NewMint(value);
1715 } else { 1715 } else {
1716 // When reading a script snapshot we need to canonicalize only those object 1716 // When reading a script snapshot we need to canonicalize only those object
1717 // references that are objects from the core library (loaded from a 1717 // references that are objects from the core library (loaded from a
1718 // full snapshot). Objects that are only in the script need not be 1718 // full snapshot). Objects that are only in the script need not be
1719 // canonicalized as they are already canonical. 1719 // canonicalized as they are already canonical.
1720 // When reading a message snapshot we always have to canonicalize. 1720 // When reading a message snapshot we always have to canonicalize.
1721 if (RawObject::IsCanonical(tags) && 1721 if (RawObject::IsCanonical(tags) &&
1722 (RawObject::IsCreatedFromSnapshot(tags) || 1722 (RawObject::IsCreatedFromSnapshot(tags) ||
(...skipping 29 matching lines...) Expand all
1752 } 1752 }
1753 1753
1754 1754
1755 RawBigint* Bigint::ReadFrom(SnapshotReader* reader, 1755 RawBigint* Bigint::ReadFrom(SnapshotReader* reader,
1756 intptr_t object_id, 1756 intptr_t object_id,
1757 intptr_t tags, 1757 intptr_t tags,
1758 Snapshot::Kind kind) { 1758 Snapshot::Kind kind) {
1759 ASSERT(reader != NULL); 1759 ASSERT(reader != NULL);
1760 1760
1761 // Allocate bigint object. 1761 // Allocate bigint object.
1762 Bigint& obj = Bigint::ZoneHandle(reader->isolate(), NEW_OBJECT(Bigint)); 1762 Bigint& obj = Bigint::ZoneHandle(reader->zone(), NEW_OBJECT(Bigint));
1763 reader->AddBackRef(object_id, &obj, kIsDeserialized); 1763 reader->AddBackRef(object_id, &obj, kIsDeserialized);
1764 1764
1765 // Set all the object fields. 1765 // Set all the object fields.
1766 // TODO(5411462): Need to assert No GC can happen here, even though 1766 // TODO(5411462): Need to assert No GC can happen here, even though
1767 // allocations may happen. 1767 // allocations may happen.
1768 intptr_t num_flds = (obj.raw()->to() - obj.raw()->from()); 1768 intptr_t num_flds = (obj.raw()->to() - obj.raw()->from());
1769 for (intptr_t i = 0; i <= num_flds; i++) { 1769 for (intptr_t i = 0; i <= num_flds; i++) {
1770 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(); 1770 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl();
1771 obj.StorePointer(obj.raw()->from() + i, 1771 obj.StorePointer(obj.raw()->from() + i,
1772 reader->PassiveObjectHandle()->raw()); 1772 reader->PassiveObjectHandle()->raw());
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1815 RawDouble* Double::ReadFrom(SnapshotReader* reader, 1815 RawDouble* Double::ReadFrom(SnapshotReader* reader,
1816 intptr_t object_id, 1816 intptr_t object_id,
1817 intptr_t tags, 1817 intptr_t tags,
1818 Snapshot::Kind kind) { 1818 Snapshot::Kind kind) {
1819 ASSERT(reader != NULL); 1819 ASSERT(reader != NULL);
1820 ASSERT(kind != Snapshot::kMessage); 1820 ASSERT(kind != Snapshot::kMessage);
1821 // Read the double value for the object. 1821 // Read the double value for the object.
1822 double value = reader->ReadDouble(); 1822 double value = reader->ReadDouble();
1823 1823
1824 // Create a Double object or get canonical one if it is a canonical constant. 1824 // Create a Double object or get canonical one if it is a canonical constant.
1825 Double& dbl = Double::ZoneHandle(reader->isolate(), Double::null()); 1825 Double& dbl = Double::ZoneHandle(reader->zone(), Double::null());
1826 if (kind == Snapshot::kFull) { 1826 if (kind == Snapshot::kFull) {
1827 dbl = reader->NewDouble(value); 1827 dbl = reader->NewDouble(value);
1828 } else { 1828 } else {
1829 // When reading a script snapshot we need to canonicalize only those object 1829 // When reading a script snapshot we need to canonicalize only those object
1830 // references that are objects from the core library (loaded from a 1830 // references that are objects from the core library (loaded from a
1831 // full snapshot). Objects that are only in the script need not be 1831 // full snapshot). Objects that are only in the script need not be
1832 // canonicalized as they are already canonical. 1832 // canonicalized as they are already canonical.
1833 if (RawObject::IsCanonical(tags) && 1833 if (RawObject::IsCanonical(tags) &&
1834 RawObject::IsCreatedFromSnapshot(tags)) { 1834 RawObject::IsCreatedFromSnapshot(tags)) {
1835 dbl = Double::NewCanonical(value); 1835 dbl = Double::NewCanonical(value);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1882 template<typename StringType, typename CharacterType, typename CallbackType> 1882 template<typename StringType, typename CharacterType, typename CallbackType>
1883 void String::ReadFromImpl(SnapshotReader* reader, 1883 void String::ReadFromImpl(SnapshotReader* reader,
1884 String* str_obj, 1884 String* str_obj,
1885 intptr_t len, 1885 intptr_t len,
1886 intptr_t tags, 1886 intptr_t tags,
1887 CallbackType new_symbol, 1887 CallbackType new_symbol,
1888 Snapshot::Kind kind) { 1888 Snapshot::Kind kind) {
1889 ASSERT(reader != NULL); 1889 ASSERT(reader != NULL);
1890 if (RawObject::IsCanonical(tags)) { 1890 if (RawObject::IsCanonical(tags)) {
1891 // Set up canonical string object. 1891 // Set up canonical string object.
1892 Isolate* isolate = reader->isolate();
1893 ASSERT(reader != NULL); 1892 ASSERT(reader != NULL);
1894 CharacterType* ptr = 1893 CharacterType* ptr = reader->zone()->Alloc<CharacterType>(len);
1895 isolate->current_zone()->Alloc<CharacterType>(len);
1896 for (intptr_t i = 0; i < len; i++) { 1894 for (intptr_t i = 0; i < len; i++) {
1897 ptr[i] = reader->Read<CharacterType>(); 1895 ptr[i] = reader->Read<CharacterType>();
1898 } 1896 }
1899 *str_obj ^= (*new_symbol)(ptr, len); 1897 *str_obj ^= (*new_symbol)(ptr, len);
1900 } else { 1898 } else {
1901 // Set up the string object. 1899 // Set up the string object.
1902 *str_obj = StringType::New(len, HEAP_SPACE(kind)); 1900 *str_obj = StringType::New(len, HEAP_SPACE(kind));
1903 str_obj->set_tags(tags); 1901 str_obj->set_tags(tags);
1904 str_obj->SetHash(0); // Will get computed when needed. 1902 str_obj->SetHash(0); // Will get computed when needed.
1905 if (len == 0) { 1903 if (len == 0) {
(...skipping 10 matching lines...) Expand all
1916 1914
1917 1915
1918 RawOneByteString* OneByteString::ReadFrom(SnapshotReader* reader, 1916 RawOneByteString* OneByteString::ReadFrom(SnapshotReader* reader,
1919 intptr_t object_id, 1917 intptr_t object_id,
1920 intptr_t tags, 1918 intptr_t tags,
1921 Snapshot::Kind kind) { 1919 Snapshot::Kind kind) {
1922 // Read the length so that we can determine instance size to allocate. 1920 // Read the length so that we can determine instance size to allocate.
1923 ASSERT(reader != NULL); 1921 ASSERT(reader != NULL);
1924 intptr_t len = reader->ReadSmiValue(); 1922 intptr_t len = reader->ReadSmiValue();
1925 intptr_t hash = reader->ReadSmiValue(); 1923 intptr_t hash = reader->ReadSmiValue();
1926 String& str_obj = String::Handle(reader->isolate(), String::null()); 1924 String& str_obj = String::Handle(reader->zone(), String::null());
1927 1925
1928 if (kind == Snapshot::kFull) { 1926 if (kind == Snapshot::kFull) {
1929 ASSERT(reader->isolate()->no_gc_scope_depth() != 0); 1927 ASSERT(reader->isolate()->no_gc_scope_depth() != 0);
1930 RawOneByteString* obj = reader->NewOneByteString(len); 1928 RawOneByteString* obj = reader->NewOneByteString(len);
1931 str_obj = obj; 1929 str_obj = obj;
1932 str_obj.set_tags(tags); 1930 str_obj.set_tags(tags);
1933 str_obj.SetHash(hash); 1931 str_obj.SetHash(hash);
1934 if (len > 0) { 1932 if (len > 0) {
1935 uint8_t* raw_ptr = CharAddr(str_obj, 0); 1933 uint8_t* raw_ptr = CharAddr(str_obj, 0);
1936 reader->ReadBytes(raw_ptr, len); 1934 reader->ReadBytes(raw_ptr, len);
1937 } 1935 }
1938 ASSERT((hash == 0) || (String::Hash(str_obj, 0, str_obj.Length()) == hash)); 1936 ASSERT((hash == 0) || (String::Hash(str_obj, 0, str_obj.Length()) == hash));
1939 } else { 1937 } else {
1940 String::ReadFromImpl<OneByteString, uint8_t>( 1938 String::ReadFromImpl<OneByteString, uint8_t>(
1941 reader, &str_obj, len, tags, Symbols::FromLatin1, kind); 1939 reader, &str_obj, len, tags, Symbols::FromLatin1, kind);
1942 } 1940 }
1943 reader->AddBackRef(object_id, &str_obj, kIsDeserialized); 1941 reader->AddBackRef(object_id, &str_obj, kIsDeserialized);
1944 return raw(str_obj); 1942 return raw(str_obj);
1945 } 1943 }
1946 1944
1947 1945
1948 RawTwoByteString* TwoByteString::ReadFrom(SnapshotReader* reader, 1946 RawTwoByteString* TwoByteString::ReadFrom(SnapshotReader* reader,
1949 intptr_t object_id, 1947 intptr_t object_id,
1950 intptr_t tags, 1948 intptr_t tags,
1951 Snapshot::Kind kind) { 1949 Snapshot::Kind kind) {
1952 // Read the length so that we can determine instance size to allocate. 1950 // Read the length so that we can determine instance size to allocate.
1953 ASSERT(reader != NULL); 1951 ASSERT(reader != NULL);
1954 intptr_t len = reader->ReadSmiValue(); 1952 intptr_t len = reader->ReadSmiValue();
1955 intptr_t hash = reader->ReadSmiValue(); 1953 intptr_t hash = reader->ReadSmiValue();
1956 String& str_obj = String::Handle(reader->isolate(), String::null()); 1954 String& str_obj = String::Handle(reader->zone(), String::null());
1957 1955
1958 if (kind == Snapshot::kFull) { 1956 if (kind == Snapshot::kFull) {
1959 RawTwoByteString* obj = reader->NewTwoByteString(len); 1957 RawTwoByteString* obj = reader->NewTwoByteString(len);
1960 str_obj = obj; 1958 str_obj = obj;
1961 str_obj.set_tags(tags); 1959 str_obj.set_tags(tags);
1962 str_obj.SetHash(hash); 1960 str_obj.SetHash(hash);
1963 NoGCScope no_gc; 1961 NoGCScope no_gc;
1964 uint16_t* raw_ptr = (len > 0)? CharAddr(str_obj, 0) : NULL; 1962 uint16_t* raw_ptr = (len > 0)? CharAddr(str_obj, 0) : NULL;
1965 for (intptr_t i = 0; i < len; i++) { 1963 for (intptr_t i = 0; i < len; i++) {
1966 ASSERT(CharAddr(str_obj, i) == raw_ptr); // Will trigger assertions. 1964 ASSERT(CharAddr(str_obj, i) == raw_ptr); // Will trigger assertions.
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
2113 intptr_t object_id, 2111 intptr_t object_id,
2114 intptr_t tags, 2112 intptr_t tags,
2115 Snapshot::Kind kind) { 2113 Snapshot::Kind kind) {
2116 ASSERT(reader != NULL); 2114 ASSERT(reader != NULL);
2117 2115
2118 // Read the length so that we can determine instance size to allocate. 2116 // Read the length so that we can determine instance size to allocate.
2119 intptr_t len = reader->ReadSmiValue(); 2117 intptr_t len = reader->ReadSmiValue();
2120 Array* array = reinterpret_cast<Array*>( 2118 Array* array = reinterpret_cast<Array*>(
2121 reader->GetBackRef(object_id)); 2119 reader->GetBackRef(object_id));
2122 if (array == NULL) { 2120 if (array == NULL) {
2123 array = &(Array::ZoneHandle(reader->isolate(), 2121 array = &(Array::ZoneHandle(reader->zone(),
2124 NEW_OBJECT_WITH_LEN_SPACE(Array, len, kind))); 2122 NEW_OBJECT_WITH_LEN_SPACE(Array, len, kind)));
2125 reader->AddBackRef(object_id, array, kIsDeserialized); 2123 reader->AddBackRef(object_id, array, kIsDeserialized);
2126 } 2124 }
2127 ASSERT(!RawObject::IsCanonical(tags)); 2125 ASSERT(!RawObject::IsCanonical(tags));
2128 reader->ArrayReadFrom(*array, len, tags); 2126 reader->ArrayReadFrom(*array, len, tags);
2129 return array->raw(); 2127 return array->raw();
2130 } 2128 }
2131 2129
2132 2130
2133 RawImmutableArray* ImmutableArray::ReadFrom(SnapshotReader* reader, 2131 RawImmutableArray* ImmutableArray::ReadFrom(SnapshotReader* reader,
2134 intptr_t object_id, 2132 intptr_t object_id,
2135 intptr_t tags, 2133 intptr_t tags,
2136 Snapshot::Kind kind) { 2134 Snapshot::Kind kind) {
2137 ASSERT(reader != NULL); 2135 ASSERT(reader != NULL);
2138 2136
2139 // Read the length so that we can determine instance size to allocate. 2137 // Read the length so that we can determine instance size to allocate.
2140 intptr_t len = reader->ReadSmiValue(); 2138 intptr_t len = reader->ReadSmiValue();
2141 Array* array = reinterpret_cast<Array*>(reader->GetBackRef(object_id)); 2139 Array* array = reinterpret_cast<Array*>(reader->GetBackRef(object_id));
2142 if (array == NULL) { 2140 if (array == NULL) {
2143 array = &(Array::ZoneHandle( 2141 array = &(Array::ZoneHandle(
2144 reader->isolate(), 2142 reader->zone(),
2145 NEW_OBJECT_WITH_LEN_SPACE(ImmutableArray, len, kind))); 2143 NEW_OBJECT_WITH_LEN_SPACE(ImmutableArray, len, kind)));
2146 reader->AddBackRef(object_id, array, kIsDeserialized); 2144 reader->AddBackRef(object_id, array, kIsDeserialized);
2147 } 2145 }
2148 reader->ArrayReadFrom(*array, len, tags); 2146 reader->ArrayReadFrom(*array, len, tags);
2149 if (RawObject::IsCanonical(tags)) { 2147 if (RawObject::IsCanonical(tags)) {
2150 *array ^= array->CheckAndCanonicalize(NULL); 2148 *array ^= array->CheckAndCanonicalize(NULL);
2151 } 2149 }
2152 return raw(*array); 2150 return raw(*array);
2153 } 2151 }
2154 2152
(...skipping 24 matching lines...) Expand all
2179 2177
2180 2178
2181 RawGrowableObjectArray* GrowableObjectArray::ReadFrom(SnapshotReader* reader, 2179 RawGrowableObjectArray* GrowableObjectArray::ReadFrom(SnapshotReader* reader,
2182 intptr_t object_id, 2180 intptr_t object_id,
2183 intptr_t tags, 2181 intptr_t tags,
2184 Snapshot::Kind kind) { 2182 Snapshot::Kind kind) {
2185 ASSERT(reader != NULL); 2183 ASSERT(reader != NULL);
2186 2184
2187 // Read the length so that we can determine instance size to allocate. 2185 // Read the length so that we can determine instance size to allocate.
2188 GrowableObjectArray& array = GrowableObjectArray::ZoneHandle( 2186 GrowableObjectArray& array = GrowableObjectArray::ZoneHandle(
2189 reader->isolate(), GrowableObjectArray::null()); 2187 reader->zone(), GrowableObjectArray::null());
2190 if (kind == Snapshot::kFull) { 2188 if (kind == Snapshot::kFull) {
2191 array = reader->NewGrowableObjectArray(); 2189 array = reader->NewGrowableObjectArray();
2192 } else { 2190 } else {
2193 array = GrowableObjectArray::New(0, HEAP_SPACE(kind)); 2191 array = GrowableObjectArray::New(0, HEAP_SPACE(kind));
2194 } 2192 }
2195 reader->AddBackRef(object_id, &array, kIsDeserialized); 2193 reader->AddBackRef(object_id, &array, kIsDeserialized);
2196 intptr_t length = reader->ReadSmiValue(); 2194 intptr_t length = reader->ReadSmiValue();
2197 array.SetLength(length); 2195 array.SetLength(length);
2198 *(reader->ArrayHandle()) ^= reader->ReadObjectImpl(); 2196 *(reader->ArrayHandle()) ^= reader->ReadObjectImpl();
2199 array.SetData(*(reader->ArrayHandle())); 2197 array.SetData(*(reader->ArrayHandle()));
(...skipping 23 matching lines...) Expand all
2223 } 2221 }
2224 2222
2225 2223
2226 RawLinkedHashMap* LinkedHashMap::ReadFrom(SnapshotReader* reader, 2224 RawLinkedHashMap* LinkedHashMap::ReadFrom(SnapshotReader* reader,
2227 intptr_t object_id, 2225 intptr_t object_id,
2228 intptr_t tags, 2226 intptr_t tags,
2229 Snapshot::Kind kind) { 2227 Snapshot::Kind kind) {
2230 ASSERT(reader != NULL); 2228 ASSERT(reader != NULL);
2231 2229
2232 LinkedHashMap& map = LinkedHashMap::ZoneHandle( 2230 LinkedHashMap& map = LinkedHashMap::ZoneHandle(
2233 reader->isolate(), LinkedHashMap::null()); 2231 reader->zone(), LinkedHashMap::null());
2234 if (kind == Snapshot::kFull || kind == Snapshot::kScript) { 2232 if (kind == Snapshot::kFull || kind == Snapshot::kScript) {
2235 // The immutable maps that seed map literals are not yet VM-internal, so 2233 // The immutable maps that seed map literals are not yet VM-internal, so
2236 // we don't reach this. 2234 // we don't reach this.
2237 UNREACHABLE(); 2235 UNREACHABLE();
2238 } else { 2236 } else {
2239 map = LinkedHashMap::New(HEAP_SPACE(kind)); 2237 map = LinkedHashMap::New(HEAP_SPACE(kind));
2240 } 2238 }
2241 reader->AddBackRef(object_id, &map, kIsDeserialized); 2239 reader->AddBackRef(object_id, &map, kIsDeserialized);
2242 *(reader->ArrayHandle()) ^= reader->ReadObjectImpl(); 2240 *(reader->ArrayHandle()) ^= reader->ReadObjectImpl();
2243 map.SetData(*(reader->ArrayHandle())); 2241 map.SetData(*(reader->ArrayHandle()));
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2276 intptr_t tags, 2274 intptr_t tags,
2277 Snapshot::Kind kind) { 2275 Snapshot::Kind kind) {
2278 ASSERT(reader != NULL); 2276 ASSERT(reader != NULL);
2279 // Read the values. 2277 // Read the values.
2280 float value0 = reader->Read<float>(); 2278 float value0 = reader->Read<float>();
2281 float value1 = reader->Read<float>(); 2279 float value1 = reader->Read<float>();
2282 float value2 = reader->Read<float>(); 2280 float value2 = reader->Read<float>();
2283 float value3 = reader->Read<float>(); 2281 float value3 = reader->Read<float>();
2284 2282
2285 // Create a Float32x4 object. 2283 // Create a Float32x4 object.
2286 Float32x4& simd = Float32x4::ZoneHandle(reader->isolate(), 2284 Float32x4& simd = Float32x4::ZoneHandle(reader->zone(),
2287 Float32x4::null()); 2285 Float32x4::null());
2288 if (kind == Snapshot::kFull) { 2286 if (kind == Snapshot::kFull) {
2289 simd = reader->NewFloat32x4(value0, value1, value2, value3); 2287 simd = reader->NewFloat32x4(value0, value1, value2, value3);
2290 } else { 2288 } else {
2291 simd = Float32x4::New(value0, value1, value2, value3, HEAP_SPACE(kind)); 2289 simd = Float32x4::New(value0, value1, value2, value3, HEAP_SPACE(kind));
2292 } 2290 }
2293 reader->AddBackRef(object_id, &simd, kIsDeserialized); 2291 reader->AddBackRef(object_id, &simd, kIsDeserialized);
2294 // Set the object tags. 2292 // Set the object tags.
2295 simd.set_tags(tags); 2293 simd.set_tags(tags);
2296 return simd.raw(); 2294 return simd.raw();
(...skipping 25 matching lines...) Expand all
2322 intptr_t tags, 2320 intptr_t tags,
2323 Snapshot::Kind kind) { 2321 Snapshot::Kind kind) {
2324 ASSERT(reader != NULL); 2322 ASSERT(reader != NULL);
2325 // Read the values. 2323 // Read the values.
2326 uint32_t value0 = reader->Read<uint32_t>(); 2324 uint32_t value0 = reader->Read<uint32_t>();
2327 uint32_t value1 = reader->Read<uint32_t>(); 2325 uint32_t value1 = reader->Read<uint32_t>();
2328 uint32_t value2 = reader->Read<uint32_t>(); 2326 uint32_t value2 = reader->Read<uint32_t>();
2329 uint32_t value3 = reader->Read<uint32_t>(); 2327 uint32_t value3 = reader->Read<uint32_t>();
2330 2328
2331 // Create a Float32x4 object. 2329 // Create a Float32x4 object.
2332 Int32x4& simd = Int32x4::ZoneHandle(reader->isolate(), Int32x4::null()); 2330 Int32x4& simd = Int32x4::ZoneHandle(reader->zone(), Int32x4::null());
2333 2331
2334 if (kind == Snapshot::kFull) { 2332 if (kind == Snapshot::kFull) {
2335 simd = reader->NewInt32x4(value0, value1, value2, value3); 2333 simd = reader->NewInt32x4(value0, value1, value2, value3);
2336 } else { 2334 } else {
2337 simd = Int32x4::New(value0, value1, value2, value3, HEAP_SPACE(kind)); 2335 simd = Int32x4::New(value0, value1, value2, value3, HEAP_SPACE(kind));
2338 } 2336 }
2339 reader->AddBackRef(object_id, &simd, kIsDeserialized); 2337 reader->AddBackRef(object_id, &simd, kIsDeserialized);
2340 // Set the object tags. 2338 // Set the object tags.
2341 simd.set_tags(tags); 2339 simd.set_tags(tags);
2342 return simd.raw(); 2340 return simd.raw();
(...skipping 23 matching lines...) Expand all
2366 RawFloat64x2* Float64x2::ReadFrom(SnapshotReader* reader, 2364 RawFloat64x2* Float64x2::ReadFrom(SnapshotReader* reader,
2367 intptr_t object_id, 2365 intptr_t object_id,
2368 intptr_t tags, 2366 intptr_t tags,
2369 Snapshot::Kind kind) { 2367 Snapshot::Kind kind) {
2370 ASSERT(reader != NULL); 2368 ASSERT(reader != NULL);
2371 // Read the values. 2369 // Read the values.
2372 double value0 = reader->Read<double>(); 2370 double value0 = reader->Read<double>();
2373 double value1 = reader->Read<double>(); 2371 double value1 = reader->Read<double>();
2374 2372
2375 // Create a Float64x2 object. 2373 // Create a Float64x2 object.
2376 Float64x2& simd = Float64x2::ZoneHandle(reader->isolate(), 2374 Float64x2& simd = Float64x2::ZoneHandle(reader->zone(),
2377 Float64x2::null()); 2375 Float64x2::null());
2378 if (kind == Snapshot::kFull) { 2376 if (kind == Snapshot::kFull) {
2379 simd = reader->NewFloat64x2(value0, value1); 2377 simd = reader->NewFloat64x2(value0, value1);
2380 } else { 2378 } else {
2381 simd = Float64x2::New(value0, value1, HEAP_SPACE(kind)); 2379 simd = Float64x2::New(value0, value1, HEAP_SPACE(kind));
2382 } 2380 }
2383 reader->AddBackRef(object_id, &simd, kIsDeserialized); 2381 reader->AddBackRef(object_id, &simd, kIsDeserialized);
2384 // Set the object tags. 2382 // Set the object tags.
2385 simd.set_tags(tags); 2383 simd.set_tags(tags);
2386 return simd.raw(); 2384 return simd.raw();
(...skipping 25 matching lines...) Expand all
2412 2410
2413 2411
2414 RawTypedData* TypedData::ReadFrom(SnapshotReader* reader, 2412 RawTypedData* TypedData::ReadFrom(SnapshotReader* reader,
2415 intptr_t object_id, 2413 intptr_t object_id,
2416 intptr_t tags, 2414 intptr_t tags,
2417 Snapshot::Kind kind) { 2415 Snapshot::Kind kind) {
2418 ASSERT(reader != NULL); 2416 ASSERT(reader != NULL);
2419 2417
2420 intptr_t cid = RawObject::ClassIdTag::decode(tags); 2418 intptr_t cid = RawObject::ClassIdTag::decode(tags);
2421 intptr_t len = reader->ReadSmiValue(); 2419 intptr_t len = reader->ReadSmiValue();
2422 TypedData& result = TypedData::ZoneHandle(reader->isolate(), 2420 TypedData& result = TypedData::ZoneHandle(reader->zone(),
2423 (kind == Snapshot::kFull) ? reader->NewTypedData(cid, len) 2421 (kind == Snapshot::kFull) ? reader->NewTypedData(cid, len)
2424 : TypedData::New(cid, len, HEAP_SPACE(kind))); 2422 : TypedData::New(cid, len, HEAP_SPACE(kind)));
2425 reader->AddBackRef(object_id, &result, kIsDeserialized); 2423 reader->AddBackRef(object_id, &result, kIsDeserialized);
2426 2424
2427 // Set the object tags. 2425 // Set the object tags.
2428 result.set_tags(tags); 2426 result.set_tags(tags);
2429 2427
2430 // Setup the array elements. 2428 // Setup the array elements.
2431 intptr_t element_size = ElementSizeInBytes(cid); 2429 intptr_t element_size = ElementSizeInBytes(cid);
2432 intptr_t length_in_bytes = len * element_size; 2430 intptr_t length_in_bytes = len * element_size;
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
2624 #undef TYPED_DATA_WRITE 2622 #undef TYPED_DATA_WRITE
2625 #undef EXT_TYPED_DATA_WRITE 2623 #undef EXT_TYPED_DATA_WRITE
2626 2624
2627 2625
2628 RawCapability* Capability::ReadFrom(SnapshotReader* reader, 2626 RawCapability* Capability::ReadFrom(SnapshotReader* reader,
2629 intptr_t object_id, 2627 intptr_t object_id,
2630 intptr_t tags, 2628 intptr_t tags,
2631 Snapshot::Kind kind) { 2629 Snapshot::Kind kind) {
2632 uint64_t id = reader->Read<uint64_t>(); 2630 uint64_t id = reader->Read<uint64_t>();
2633 2631
2634 Capability& result = Capability::ZoneHandle(reader->isolate(), 2632 Capability& result = Capability::ZoneHandle(reader->zone(),
2635 Capability::New(id)); 2633 Capability::New(id));
2636 reader->AddBackRef(object_id, &result, kIsDeserialized); 2634 reader->AddBackRef(object_id, &result, kIsDeserialized);
2637 return result.raw(); 2635 return result.raw();
2638 } 2636 }
2639 2637
2640 2638
2641 void RawCapability::WriteTo(SnapshotWriter* writer, 2639 void RawCapability::WriteTo(SnapshotWriter* writer,
2642 intptr_t object_id, 2640 intptr_t object_id,
2643 Snapshot::Kind kind) { 2641 Snapshot::Kind kind) {
2644 // Write out the serialization header value for this object. 2642 // Write out the serialization header value for this object.
(...skipping 30 matching lines...) Expand all
2675 } 2673 }
2676 2674
2677 2675
2678 RawSendPort* SendPort::ReadFrom(SnapshotReader* reader, 2676 RawSendPort* SendPort::ReadFrom(SnapshotReader* reader,
2679 intptr_t object_id, 2677 intptr_t object_id,
2680 intptr_t tags, 2678 intptr_t tags,
2681 Snapshot::Kind kind) { 2679 Snapshot::Kind kind) {
2682 uint64_t id = reader->Read<uint64_t>(); 2680 uint64_t id = reader->Read<uint64_t>();
2683 uint64_t origin_id = reader->Read<uint64_t>(); 2681 uint64_t origin_id = reader->Read<uint64_t>();
2684 2682
2685 SendPort& result = SendPort::ZoneHandle(reader->isolate(), 2683 SendPort& result = SendPort::ZoneHandle(reader->zone(),
2686 SendPort::New(id, origin_id)); 2684 SendPort::New(id, origin_id));
2687 reader->AddBackRef(object_id, &result, kIsDeserialized); 2685 reader->AddBackRef(object_id, &result, kIsDeserialized);
2688 return result.raw(); 2686 return result.raw();
2689 } 2687 }
2690 2688
2691 2689
2692 void RawSendPort::WriteTo(SnapshotWriter* writer, 2690 void RawSendPort::WriteTo(SnapshotWriter* writer,
2693 intptr_t object_id, 2691 intptr_t object_id,
2694 Snapshot::Kind kind) { 2692 Snapshot::Kind kind) {
2695 // Write out the serialization header value for this object. 2693 // Write out the serialization header value for this object.
2696 writer->WriteInlinedObjectHeader(object_id); 2694 writer->WriteInlinedObjectHeader(object_id);
2697 2695
2698 // Write out the class and tags information. 2696 // Write out the class and tags information.
2699 writer->WriteIndexedObject(kSendPortCid); 2697 writer->WriteIndexedObject(kSendPortCid);
2700 writer->WriteTags(writer->GetObjectTags(this)); 2698 writer->WriteTags(writer->GetObjectTags(this));
2701 2699
2702 writer->Write<uint64_t>(ptr()->id_); 2700 writer->Write<uint64_t>(ptr()->id_);
2703 writer->Write<uint64_t>(ptr()->origin_id_); 2701 writer->Write<uint64_t>(ptr()->origin_id_);
2704 } 2702 }
2705 2703
2706 2704
2707 RawStacktrace* Stacktrace::ReadFrom(SnapshotReader* reader, 2705 RawStacktrace* Stacktrace::ReadFrom(SnapshotReader* reader,
2708 intptr_t object_id, 2706 intptr_t object_id,
2709 intptr_t tags, 2707 intptr_t tags,
2710 Snapshot::Kind kind) { 2708 Snapshot::Kind kind) {
2711 if (kind == Snapshot::kFull) { 2709 if (kind == Snapshot::kFull) {
2712 Stacktrace& result = Stacktrace::ZoneHandle(reader->isolate(), 2710 Stacktrace& result = Stacktrace::ZoneHandle(reader->zone(),
2713 reader->NewStacktrace()); 2711 reader->NewStacktrace());
2714 reader->AddBackRef(object_id, &result, kIsDeserialized); 2712 reader->AddBackRef(object_id, &result, kIsDeserialized);
2715 2713
2716 // Set all the object fields. 2714 // Set all the object fields.
2717 // TODO(5411462): Need to assert No GC can happen here, even though 2715 // TODO(5411462): Need to assert No GC can happen here, even though
2718 // allocations may happen. 2716 // allocations may happen.
2719 intptr_t num_flds = (result.raw()->to() - result.raw()->from()); 2717 intptr_t num_flds = (result.raw()->to() - result.raw()->from());
2720 for (intptr_t i = 0; i <= num_flds; i++) { 2718 for (intptr_t i = 0; i <= num_flds; i++) {
2721 (*reader->PassiveObjectHandle()) = reader->ReadObjectRef(); 2719 (*reader->PassiveObjectHandle()) = reader->ReadObjectRef();
2722 result.StorePointer((result.raw()->from() + i), 2720 result.StorePointer((result.raw()->from() + i),
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
2767 intptr_t tags, 2765 intptr_t tags,
2768 Snapshot::Kind kind) { 2766 Snapshot::Kind kind) {
2769 ASSERT(reader != NULL); 2767 ASSERT(reader != NULL);
2770 ASSERT(kind == Snapshot::kMessage); 2768 ASSERT(kind == Snapshot::kMessage);
2771 2769
2772 // Read the length so that we can determine instance size to allocate. 2770 // Read the length so that we can determine instance size to allocate.
2773 intptr_t len = reader->ReadSmiValue(); 2771 intptr_t len = reader->ReadSmiValue();
2774 2772
2775 // Allocate JSRegExp object. 2773 // Allocate JSRegExp object.
2776 JSRegExp& regex = JSRegExp::ZoneHandle( 2774 JSRegExp& regex = JSRegExp::ZoneHandle(
2777 reader->isolate(), JSRegExp::New(len, HEAP_SPACE(kind))); 2775 reader->zone(), JSRegExp::New(len, HEAP_SPACE(kind)));
2778 reader->AddBackRef(object_id, &regex, kIsDeserialized); 2776 reader->AddBackRef(object_id, &regex, kIsDeserialized);
2779 2777
2780 // Set the object tags. 2778 // Set the object tags.
2781 regex.set_tags(tags); 2779 regex.set_tags(tags);
2782 2780
2783 // Read and Set all the other fields. 2781 // Read and Set all the other fields.
2784 regex.StoreSmi(&regex.raw_ptr()->num_bracket_expressions_, 2782 regex.StoreSmi(&regex.raw_ptr()->num_bracket_expressions_,
2785 reader->ReadAsSmi()); 2783 reader->ReadAsSmi());
2786 *reader->StringHandle() ^= reader->ReadObjectImpl(); 2784 *reader->StringHandle() ^= reader->ReadObjectImpl();
2787 regex.set_pattern(*reader->StringHandle()); 2785 regex.set_pattern(*reader->StringHandle());
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2820 2818
2821 2819
2822 RawWeakProperty* WeakProperty::ReadFrom(SnapshotReader* reader, 2820 RawWeakProperty* WeakProperty::ReadFrom(SnapshotReader* reader,
2823 intptr_t object_id, 2821 intptr_t object_id,
2824 intptr_t tags, 2822 intptr_t tags,
2825 Snapshot::Kind kind) { 2823 Snapshot::Kind kind) {
2826 ASSERT(reader != NULL); 2824 ASSERT(reader != NULL);
2827 2825
2828 // Allocate the weak property object. 2826 // Allocate the weak property object.
2829 WeakProperty& weak_property = WeakProperty::ZoneHandle( 2827 WeakProperty& weak_property = WeakProperty::ZoneHandle(
2830 reader->isolate(), WeakProperty::New(HEAP_SPACE(kind))); 2828 reader->zone(), WeakProperty::New(HEAP_SPACE(kind)));
2831 reader->AddBackRef(object_id, &weak_property, kIsDeserialized); 2829 reader->AddBackRef(object_id, &weak_property, kIsDeserialized);
2832 2830
2833 // Set the object tags. 2831 // Set the object tags.
2834 weak_property.set_tags(tags); 2832 weak_property.set_tags(tags);
2835 2833
2836 // Set all the object fields. 2834 // Set all the object fields.
2837 // TODO(5411462): Need to assert No GC can happen here, even though 2835 // TODO(5411462): Need to assert No GC can happen here, even though
2838 // allocations may happen. 2836 // allocations may happen.
2839 intptr_t num_flds = (weak_property.raw()->to() - 2837 intptr_t num_flds = (weak_property.raw()->to() -
2840 weak_property.raw()->from()); 2838 weak_property.raw()->from());
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
2905 // We do not allow objects with native fields in an isolate message. 2903 // We do not allow objects with native fields in an isolate message.
2906 writer->SetWriteException(Exceptions::kArgument, 2904 writer->SetWriteException(Exceptions::kArgument,
2907 "Illegal argument in isolate message" 2905 "Illegal argument in isolate message"
2908 " : (object is a UserTag)"); 2906 " : (object is a UserTag)");
2909 } else { 2907 } else {
2910 UNREACHABLE(); 2908 UNREACHABLE();
2911 } 2909 }
2912 } 2910 }
2913 2911
2914 } // namespace dart 2912 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/service_isolate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698