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

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

Issue 328893002: Begins removing intptr_t from raw object fields. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 6 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/raw_object.h ('k') | runtime/vm/stub_code_arm64.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/bigint_operations.h" 5 #include "vm/bigint_operations.h"
6 #include "vm/object.h" 6 #include "vm/object.h"
7 #include "vm/object_store.h" 7 #include "vm/object_store.h"
8 #include "vm/snapshot.h" 8 #include "vm/snapshot.h"
9 #include "vm/stub_code.h" 9 #include "vm/stub_code.h"
10 #include "vm/symbols.h" 10 #include "vm/symbols.h"
(...skipping 21 matching lines...) Expand all
32 RawClass* Class::ReadFrom(SnapshotReader* reader, 32 RawClass* Class::ReadFrom(SnapshotReader* reader,
33 intptr_t object_id, 33 intptr_t object_id,
34 intptr_t tags, 34 intptr_t tags,
35 Snapshot::Kind kind) { 35 Snapshot::Kind kind) {
36 ASSERT(reader != NULL); 36 ASSERT(reader != NULL);
37 37
38 Class& cls = Class::ZoneHandle(reader->isolate(), Class::null()); 38 Class& cls = Class::ZoneHandle(reader->isolate(), Class::null());
39 if ((kind == Snapshot::kFull) || 39 if ((kind == Snapshot::kFull) ||
40 (kind == Snapshot::kScript && !RawObject::IsCreatedFromSnapshot(tags))) { 40 (kind == Snapshot::kScript && !RawObject::IsCreatedFromSnapshot(tags))) {
41 // Read in the base information. 41 // Read in the base information.
42 intptr_t class_id = reader->ReadIntptrValue(); 42 int32_t class_id = reader->Read<int32_t>();
43 43
44 // Allocate class object of specified kind. 44 // Allocate class object of specified kind.
45 if (kind == Snapshot::kFull) { 45 if (kind == Snapshot::kFull) {
46 cls = reader->NewClass(class_id); 46 cls = reader->NewClass(class_id);
47 } else { 47 } else {
48 if (class_id < kNumPredefinedCids) { 48 if (class_id < kNumPredefinedCids) {
49 ASSERT((class_id >= kInstanceCid) && (class_id <= kMirrorReferenceCid)); 49 ASSERT((class_id >= kInstanceCid) && (class_id <= kMirrorReferenceCid));
50 cls = reader->isolate()->class_table()->At(class_id); 50 cls = reader->isolate()->class_table()->At(class_id);
51 } else { 51 } else {
52 cls = New<Instance>(kIllegalCid); 52 cls = New<Instance>(kIllegalCid);
53 } 53 }
54 } 54 }
55 reader->AddBackRef(object_id, &cls, kIsDeserialized); 55 reader->AddBackRef(object_id, &cls, kIsDeserialized);
56 56
57 // Set the object tags. 57 // Set the object tags.
58 cls.set_tags(tags); 58 cls.set_tags(tags);
59 59
60 // Set all non object fields. 60 // Set all non object fields.
61 if (!RawObject::IsInternalVMdefinedClassId(class_id)) { 61 if (!RawObject::IsInternalVMdefinedClassId(class_id)) {
62 // Instance size of a VM defined class is already set up. 62 // Instance size of a VM defined class is already set up.
63 cls.set_instance_size_in_words(reader->ReadIntptrValue()); 63 cls.set_instance_size_in_words(reader->Read<int32_t>());
64 cls.set_next_field_offset_in_words(reader->ReadIntptrValue()); 64 cls.set_next_field_offset_in_words(reader->Read<int32_t>());
65 } 65 }
66 cls.set_type_arguments_field_offset_in_words(reader->ReadIntptrValue()); 66 cls.set_type_arguments_field_offset_in_words(reader->Read<int32_t>());
67 cls.set_num_type_arguments(reader->Read<int16_t>()); 67 cls.set_num_type_arguments(reader->Read<int16_t>());
68 cls.set_num_own_type_arguments(reader->Read<int16_t>()); 68 cls.set_num_own_type_arguments(reader->Read<int16_t>());
69 cls.set_num_native_fields(reader->Read<uint16_t>()); 69 cls.set_num_native_fields(reader->Read<uint16_t>());
70 cls.set_token_pos(reader->ReadIntptrValue()); 70 cls.set_token_pos(reader->Read<int32_t>());
71 cls.set_state_bits(reader->Read<uint16_t>()); 71 cls.set_state_bits(reader->Read<uint16_t>());
72 72
73 // Set all the object fields. 73 // Set all the object fields.
74 // TODO(5411462): Need to assert No GC can happen here, even though 74 // TODO(5411462): Need to assert No GC can happen here, even though
75 // allocations may happen. 75 // allocations may happen.
76 intptr_t num_flds = (cls.raw()->to() - cls.raw()->from()); 76 intptr_t num_flds = (cls.raw()->to() - cls.raw()->from());
77 for (intptr_t i = 0; i <= num_flds; i++) { 77 for (intptr_t i = 0; i <= num_flds; i++) {
78 *(cls.raw()->from() + i) = reader->ReadObjectRef(); 78 *(cls.raw()->from() + i) = reader->ReadObjectRef();
79 } 79 }
80 } else { 80 } else {
(...skipping 13 matching lines...) Expand all
94 94
95 if ((kind == Snapshot::kFull) || 95 if ((kind == Snapshot::kFull) ||
96 (kind == Snapshot::kScript && 96 (kind == Snapshot::kScript &&
97 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this)))) { 97 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this)))) {
98 // Write out the class and tags information. 98 // Write out the class and tags information.
99 writer->WriteVMIsolateObject(kClassCid); 99 writer->WriteVMIsolateObject(kClassCid);
100 writer->WriteIntptrValue(writer->GetObjectTags(this)); 100 writer->WriteIntptrValue(writer->GetObjectTags(this));
101 101
102 // Write out all the non object pointer fields. 102 // Write out all the non object pointer fields.
103 // NOTE: cpp_vtable_ is not written. 103 // NOTE: cpp_vtable_ is not written.
104 intptr_t class_id = ptr()->id_; 104 int32_t class_id = ptr()->id_;
105 writer->WriteIntptrValue(class_id); 105 writer->Write<int32_t>(class_id);
106 if (!RawObject::IsInternalVMdefinedClassId(class_id)) { 106 if (!RawObject::IsInternalVMdefinedClassId(class_id)) {
107 // We don't write the instance size of VM defined classes as they 107 // We don't write the instance size of VM defined classes as they
108 // are already setup during initialization as part of pre populating 108 // are already setup during initialization as part of pre populating
109 // the class table. 109 // the class table.
110 writer->WriteIntptrValue(ptr()->instance_size_in_words_); 110 writer->Write<int32_t>(ptr()->instance_size_in_words_);
111 writer->WriteIntptrValue(ptr()->next_field_offset_in_words_); 111 writer->Write<int32_t>(ptr()->next_field_offset_in_words_);
112 } 112 }
113 writer->WriteIntptrValue(ptr()->type_arguments_field_offset_in_words_); 113 writer->Write<int32_t>(ptr()->type_arguments_field_offset_in_words_);
114 writer->Write<int16_t>(ptr()->num_type_arguments_); 114 writer->Write<int16_t>(ptr()->num_type_arguments_);
115 writer->Write<int16_t>(ptr()->num_own_type_arguments_); 115 writer->Write<int16_t>(ptr()->num_own_type_arguments_);
116 writer->Write<uint16_t>(ptr()->num_native_fields_); 116 writer->Write<uint16_t>(ptr()->num_native_fields_);
117 writer->WriteIntptrValue(ptr()->token_pos_); 117 writer->Write<int32_t>(ptr()->token_pos_);
118 writer->Write<uint16_t>(ptr()->state_bits_); 118 writer->Write<uint16_t>(ptr()->state_bits_);
119 119
120 // Write out all the object pointer fields. 120 // Write out all the object pointer fields.
121 SnapshotWriterVisitor visitor(writer); 121 SnapshotWriterVisitor visitor(writer);
122 visitor.VisitPointers(from(), to()); 122 visitor.VisitPointers(from(), to());
123 } else { 123 } else {
124 writer->WriteClassId(this); 124 writer->WriteClassId(this);
125 } 125 }
126 } 126 }
127 127
128 128
129 RawUnresolvedClass* UnresolvedClass::ReadFrom(SnapshotReader* reader, 129 RawUnresolvedClass* UnresolvedClass::ReadFrom(SnapshotReader* reader,
130 intptr_t object_id, 130 intptr_t object_id,
131 intptr_t tags, 131 intptr_t tags,
132 Snapshot::Kind kind) { 132 Snapshot::Kind kind) {
133 ASSERT(reader != NULL); 133 ASSERT(reader != NULL);
134 134
135 // Allocate unresolved class object. 135 // Allocate unresolved class object.
136 UnresolvedClass& unresolved_class = UnresolvedClass::ZoneHandle( 136 UnresolvedClass& unresolved_class = UnresolvedClass::ZoneHandle(
137 reader->isolate(), NEW_OBJECT(UnresolvedClass)); 137 reader->isolate(), NEW_OBJECT(UnresolvedClass));
138 reader->AddBackRef(object_id, &unresolved_class, kIsDeserialized); 138 reader->AddBackRef(object_id, &unresolved_class, kIsDeserialized);
139 139
140 // Set the object tags. 140 // Set the object tags.
141 unresolved_class.set_tags(tags); 141 unresolved_class.set_tags(tags);
142 142
143 // Set all non object fields. 143 // Set all non object fields.
144 unresolved_class.set_token_pos(reader->ReadIntptrValue()); 144 unresolved_class.set_token_pos(reader->Read<int32_t>());
145 145
146 // Set all the object fields. 146 // Set all the object fields.
147 // TODO(5411462): Need to assert No GC can happen here, even though 147 // TODO(5411462): Need to assert No GC can happen here, even though
148 // allocations may happen. 148 // allocations may happen.
149 intptr_t num_flds = (unresolved_class.raw()->to() - 149 intptr_t num_flds = (unresolved_class.raw()->to() -
150 unresolved_class.raw()->from()); 150 unresolved_class.raw()->from());
151 for (intptr_t i = 0; i <= num_flds; i++) { 151 for (intptr_t i = 0; i <= num_flds; i++) {
152 (*reader->ObjectHandle()) = reader->ReadObjectRef(); 152 (*reader->ObjectHandle()) = reader->ReadObjectRef();
153 unresolved_class.StorePointer((unresolved_class.raw()->from() + i), 153 unresolved_class.StorePointer((unresolved_class.raw()->from() + i),
154 reader->ObjectHandle()->raw()); 154 reader->ObjectHandle()->raw());
155 } 155 }
156 return unresolved_class.raw(); 156 return unresolved_class.raw();
157 } 157 }
158 158
159 159
160 void RawUnresolvedClass::WriteTo(SnapshotWriter* writer, 160 void RawUnresolvedClass::WriteTo(SnapshotWriter* writer,
161 intptr_t object_id, 161 intptr_t object_id,
162 Snapshot::Kind kind) { 162 Snapshot::Kind kind) {
163 ASSERT(writer != NULL); 163 ASSERT(writer != NULL);
164 164
165 // Write out the serialization header value for this object. 165 // Write out the serialization header value for this object.
166 writer->WriteInlinedObjectHeader(object_id); 166 writer->WriteInlinedObjectHeader(object_id);
167 167
168 // Write out the class and tags information. 168 // Write out the class and tags information.
169 writer->WriteVMIsolateObject(kUnresolvedClassCid); 169 writer->WriteVMIsolateObject(kUnresolvedClassCid);
170 writer->WriteIntptrValue(writer->GetObjectTags(this)); 170 writer->WriteIntptrValue(writer->GetObjectTags(this));
171 171
172 // Write out all the non object pointer fields. 172 // Write out all the non object pointer fields.
173 writer->WriteIntptrValue(ptr()->token_pos_); 173 writer->Write<int32_t>(ptr()->token_pos_);
174 174
175 // Write out all the object pointer fields. 175 // Write out all the object pointer fields.
176 SnapshotWriterVisitor visitor(writer); 176 SnapshotWriterVisitor visitor(writer);
177 visitor.VisitPointers(from(), to()); 177 visitor.VisitPointers(from(), to());
178 } 178 }
179 179
180 180
181 RawAbstractType* AbstractType::ReadFrom(SnapshotReader* reader, 181 RawAbstractType* AbstractType::ReadFrom(SnapshotReader* reader,
182 intptr_t object_id, 182 intptr_t object_id,
183 intptr_t tags, 183 intptr_t tags,
(...skipping 14 matching lines...) Expand all
198 intptr_t object_id, 198 intptr_t object_id,
199 intptr_t tags, 199 intptr_t tags,
200 Snapshot::Kind kind) { 200 Snapshot::Kind kind) {
201 ASSERT(reader != NULL); 201 ASSERT(reader != NULL);
202 202
203 // Allocate type object. 203 // Allocate type object.
204 Type& type = Type::ZoneHandle(reader->isolate(), NEW_OBJECT(Type)); 204 Type& type = Type::ZoneHandle(reader->isolate(), NEW_OBJECT(Type));
205 reader->AddBackRef(object_id, &type, kIsDeserialized); 205 reader->AddBackRef(object_id, &type, kIsDeserialized);
206 206
207 // Set all non object fields. 207 // Set all non object fields.
208 type.set_token_pos(reader->ReadIntptrValue()); 208 type.set_token_pos(reader->Read<int32_t>());
209 type.set_type_state(reader->Read<int8_t>()); 209 type.set_type_state(reader->Read<int8_t>());
210 210
211 // Set all the object fields. 211 // Set all the object fields.
212 // TODO(5411462): Need to assert No GC can happen here, even though 212 // TODO(5411462): Need to assert No GC can happen here, even though
213 // allocations may happen. 213 // allocations may happen.
214 intptr_t num_flds = (type.raw()->to() - type.raw()->from()); 214 intptr_t num_flds = (type.raw()->to() - type.raw()->from());
215 for (intptr_t i = 0; i <= num_flds; i++) { 215 for (intptr_t i = 0; i <= num_flds; i++) {
216 (*reader->ObjectHandle()) = reader->ReadObjectImpl(); 216 (*reader->ObjectHandle()) = reader->ReadObjectImpl();
217 type.StorePointer((type.raw()->from() + i), reader->ObjectHandle()->raw()); 217 type.StorePointer((type.raw()->from() + i), reader->ObjectHandle()->raw());
218 } 218 }
(...skipping 30 matching lines...) Expand all
249 (ptr()->type_state_ == RawType::kFinalizedUninstantiated)); 249 (ptr()->type_state_ == RawType::kFinalizedUninstantiated));
250 250
251 // Write out the serialization header value for this object. 251 // Write out the serialization header value for this object.
252 writer->WriteInlinedObjectHeader(object_id); 252 writer->WriteInlinedObjectHeader(object_id);
253 253
254 // Write out the class and tags information. 254 // Write out the class and tags information.
255 writer->WriteIndexedObject(kTypeCid); 255 writer->WriteIndexedObject(kTypeCid);
256 writer->WriteIntptrValue(writer->GetObjectTags(this)); 256 writer->WriteIntptrValue(writer->GetObjectTags(this));
257 257
258 // Write out all the non object pointer fields. 258 // Write out all the non object pointer fields.
259 writer->WriteIntptrValue(ptr()->token_pos_); 259 writer->Write<int32_t>(ptr()->token_pos_);
260 writer->Write<int8_t>(ptr()->type_state_); 260 writer->Write<int8_t>(ptr()->type_state_);
261 261
262 // Write out all the object pointer fields. Since we will be canonicalizing 262 // Write out all the object pointer fields. Since we will be canonicalizing
263 // the type object when reading it back we should write out all the fields 263 // the type object when reading it back we should write out all the fields
264 // inline and not as references. 264 // inline and not as references.
265 SnapshotWriterVisitor visitor(writer, false); 265 SnapshotWriterVisitor visitor(writer, false);
266 visitor.VisitPointers(from(), to()); 266 visitor.VisitPointers(from(), to());
267 } 267 }
268 268
269 269
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 321
322 // Allocate type parameter object. 322 // Allocate type parameter object.
323 TypeParameter& type_parameter = TypeParameter::ZoneHandle( 323 TypeParameter& type_parameter = TypeParameter::ZoneHandle(
324 reader->isolate(), NEW_OBJECT(TypeParameter)); 324 reader->isolate(), NEW_OBJECT(TypeParameter));
325 reader->AddBackRef(object_id, &type_parameter, kIsDeserialized); 325 reader->AddBackRef(object_id, &type_parameter, kIsDeserialized);
326 326
327 // Set the object tags. 327 // Set the object tags.
328 type_parameter.set_tags(tags); 328 type_parameter.set_tags(tags);
329 329
330 // Set all non object fields. 330 // Set all non object fields.
331 type_parameter.set_index(reader->ReadIntptrValue()); 331 type_parameter.set_index(reader->Read<int32_t>());
332 type_parameter.set_token_pos(reader->ReadIntptrValue()); 332 type_parameter.set_token_pos(reader->Read<int32_t>());
333 type_parameter.set_type_state(reader->Read<int8_t>()); 333 type_parameter.set_type_state(reader->Read<int8_t>());
334 334
335 // Set all the object fields. 335 // Set all the object fields.
336 // TODO(5411462): Need to assert No GC can happen here, even though 336 // TODO(5411462): Need to assert No GC can happen here, even though
337 // allocations may happen. 337 // allocations may happen.
338 intptr_t num_flds = (type_parameter.raw()->to() - 338 intptr_t num_flds = (type_parameter.raw()->to() -
339 type_parameter.raw()->from()); 339 type_parameter.raw()->from());
340 for (intptr_t i = 0; i <= num_flds; i++) { 340 for (intptr_t i = 0; i <= num_flds; i++) {
341 (*reader->ObjectHandle()) = reader->ReadObjectRef(); 341 (*reader->ObjectHandle()) = reader->ReadObjectRef();
342 type_parameter.StorePointer((type_parameter.raw()->from() + i), 342 type_parameter.StorePointer((type_parameter.raw()->from() + i),
(...skipping 13 matching lines...) Expand all
356 ASSERT(ptr()->type_state_ == RawTypeParameter::kFinalizedUninstantiated); 356 ASSERT(ptr()->type_state_ == RawTypeParameter::kFinalizedUninstantiated);
357 357
358 // Write out the serialization header value for this object. 358 // Write out the serialization header value for this object.
359 writer->WriteInlinedObjectHeader(object_id); 359 writer->WriteInlinedObjectHeader(object_id);
360 360
361 // Write out the class and tags information. 361 // Write out the class and tags information.
362 writer->WriteIndexedObject(kTypeParameterCid); 362 writer->WriteIndexedObject(kTypeParameterCid);
363 writer->WriteIntptrValue(writer->GetObjectTags(this)); 363 writer->WriteIntptrValue(writer->GetObjectTags(this));
364 364
365 // Write out all the non object pointer fields. 365 // Write out all the non object pointer fields.
366 writer->WriteIntptrValue(ptr()->index_); 366 writer->Write<int32_t>(ptr()->index_);
367 writer->WriteIntptrValue(ptr()->token_pos_); 367 writer->Write<int32_t>(ptr()->token_pos_);
368 writer->Write<int8_t>(ptr()->type_state_); 368 writer->Write<int8_t>(ptr()->type_state_);
369 369
370 // Write out all the object pointer fields. 370 // Write out all the object pointer fields.
371 SnapshotWriterVisitor visitor(writer); 371 SnapshotWriterVisitor visitor(writer);
372 visitor.VisitPointers(from(), to()); 372 visitor.VisitPointers(from(), to());
373 } 373 }
374 374
375 375
376 RawBoundedType* BoundedType::ReadFrom(SnapshotReader* reader, 376 RawBoundedType* BoundedType::ReadFrom(SnapshotReader* reader,
377 intptr_t object_id, 377 intptr_t object_id,
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 685
686 // Allocate function object. 686 // Allocate function object.
687 Function& func = Function::ZoneHandle( 687 Function& func = Function::ZoneHandle(
688 reader->isolate(), NEW_OBJECT(Function)); 688 reader->isolate(), NEW_OBJECT(Function));
689 reader->AddBackRef(object_id, &func, kIsDeserialized); 689 reader->AddBackRef(object_id, &func, kIsDeserialized);
690 690
691 // Set the object tags. 691 // Set the object tags.
692 func.set_tags(tags); 692 func.set_tags(tags);
693 693
694 // Set all the non object fields. 694 // Set all the non object fields.
695 func.set_token_pos(reader->ReadIntptrValue()); 695 func.set_token_pos(reader->Read<int32_t>());
696 func.set_end_token_pos(reader->ReadIntptrValue()); 696 func.set_end_token_pos(reader->Read<int32_t>());
697 func.set_usage_counter(reader->ReadIntptrValue()); 697 func.set_usage_counter(reader->Read<int32_t>());
698 func.set_num_fixed_parameters(reader->ReadIntptrValue()); 698 func.set_num_fixed_parameters(reader->Read<int16_t>());
699 func.set_num_optional_parameters(reader->ReadIntptrValue()); 699 func.set_num_optional_parameters(reader->Read<int16_t>());
700 func.set_deoptimization_counter(reader->ReadIntptrValue()); 700 func.set_deoptimization_counter(reader->Read<int16_t>());
701 func.set_kind_tag(reader->Read<uint16_t>()); 701 func.set_kind_tag(reader->Read<uint16_t>());
702 func.set_optimized_instruction_count(reader->Read<uint16_t>()); 702 func.set_optimized_instruction_count(reader->Read<uint16_t>());
703 func.set_optimized_call_site_count(reader->Read<uint16_t>()); 703 func.set_optimized_call_site_count(reader->Read<uint16_t>());
704 704
705 // Set all the object fields. 705 // Set all the object fields.
706 // TODO(5411462): Need to assert No GC can happen here, even though 706 // TODO(5411462): Need to assert No GC can happen here, even though
707 // allocations may happen. 707 // allocations may happen.
708 intptr_t num_flds = (func.raw()->to_snapshot() - func.raw()->from()); 708 intptr_t num_flds = (func.raw()->to() - func.raw()->from());
709 for (intptr_t i = 0; i <= num_flds; i++) { 709 for (intptr_t i = 0; i <= num_flds; i++) {
710 *(func.raw()->from() + i) = reader->ReadObjectRef(); 710 *(func.raw()->from() + i) = reader->ReadObjectRef();
711 } 711 }
712 712
713 // Initialize all fields that are not part of the snapshot. 713 // Set up code pointer with the lazy-compile-stub.
714 func.ClearCode(); 714 func.SetInstructions(Code::Handle(StubCode::LazyCompile_entry()->code()));
715
715 return func.raw(); 716 return func.raw();
716 } 717 }
717 718
718 719
719 void RawFunction::WriteTo(SnapshotWriter* writer, 720 void RawFunction::WriteTo(SnapshotWriter* writer,
720 intptr_t object_id, 721 intptr_t object_id,
721 Snapshot::Kind kind) { 722 Snapshot::Kind kind) {
722 ASSERT(writer != NULL); 723 ASSERT(writer != NULL);
723 ASSERT(((kind == Snapshot::kScript) && 724 ASSERT(((kind == Snapshot::kScript) &&
724 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))) || 725 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))) ||
725 (kind == Snapshot::kFull)); 726 (kind == Snapshot::kFull));
726 727
727 // Write out the serialization header value for this object. 728 // Write out the serialization header value for this object.
728 writer->WriteInlinedObjectHeader(object_id); 729 writer->WriteInlinedObjectHeader(object_id);
729 730
730 // Write out the class and tags information. 731 // Write out the class and tags information.
731 writer->WriteVMIsolateObject(kFunctionCid); 732 writer->WriteVMIsolateObject(kFunctionCid);
732 writer->WriteIntptrValue(writer->GetObjectTags(this)); 733 writer->WriteIntptrValue(writer->GetObjectTags(this));
733 734
734 // Write out all the non object fields. 735 // Write out all the non object fields.
735 writer->WriteIntptrValue(ptr()->token_pos_); 736 writer->Write<int32_t>(ptr()->token_pos_);
736 writer->WriteIntptrValue(ptr()->end_token_pos_); 737 writer->Write<int32_t>(ptr()->end_token_pos_);
737 writer->WriteIntptrValue(ptr()->usage_counter_); 738 writer->Write<int32_t>(ptr()->usage_counter_);
738 writer->WriteIntptrValue(ptr()->num_fixed_parameters_); 739 writer->Write<int16_t>(ptr()->num_fixed_parameters_);
739 writer->WriteIntptrValue(ptr()->num_optional_parameters_); 740 writer->Write<int16_t>(ptr()->num_optional_parameters_);
740 writer->WriteIntptrValue(ptr()->deoptimization_counter_); 741 writer->Write<int16_t>(ptr()->deoptimization_counter_);
741 writer->Write<uint16_t>(ptr()->kind_tag_); 742 writer->Write<uint16_t>(ptr()->kind_tag_);
742 writer->Write<uint16_t>(ptr()->optimized_instruction_count_); 743 writer->Write<uint16_t>(ptr()->optimized_instruction_count_);
743 writer->Write<uint16_t>(ptr()->optimized_call_site_count_); 744 writer->Write<uint16_t>(ptr()->optimized_call_site_count_);
744 745
745 // Write out all the object pointer fields. 746 // Write out all the object pointer fields.
746 SnapshotWriterVisitor visitor(writer); 747 SnapshotWriterVisitor visitor(writer);
747 visitor.VisitPointers(from(), to_snapshot()); 748 visitor.VisitPointers(from(), to_no_code());
749
750 // Write null for the instructions and unoptimized code.
751 writer->WriteVMIsolateObject(kNullObject);
752 writer->WriteVMIsolateObject(kNullObject);
748 } 753 }
749 754
750 755
751 RawField* Field::ReadFrom(SnapshotReader* reader, 756 RawField* Field::ReadFrom(SnapshotReader* reader,
752 intptr_t object_id, 757 intptr_t object_id,
753 intptr_t tags, 758 intptr_t tags,
754 Snapshot::Kind kind) { 759 Snapshot::Kind kind) {
755 ASSERT(reader != NULL); 760 ASSERT(reader != NULL);
756 ASSERT(((kind == Snapshot::kScript) && 761 ASSERT(((kind == Snapshot::kScript) &&
757 !RawObject::IsCreatedFromSnapshot(tags)) || 762 !RawObject::IsCreatedFromSnapshot(tags)) ||
758 (kind == Snapshot::kFull)); 763 (kind == Snapshot::kFull));
759 764
760 // Allocate field object. 765 // Allocate field object.
761 Field& field = Field::ZoneHandle(reader->isolate(), NEW_OBJECT(Field)); 766 Field& field = Field::ZoneHandle(reader->isolate(), NEW_OBJECT(Field));
762 reader->AddBackRef(object_id, &field, kIsDeserialized); 767 reader->AddBackRef(object_id, &field, kIsDeserialized);
763 768
764 // Set the object tags. 769 // Set the object tags.
765 field.set_tags(tags); 770 field.set_tags(tags);
766 771
767 // Set all non object fields. 772 // Set all non object fields.
768 field.set_token_pos(reader->ReadIntptrValue()); 773 field.set_token_pos(reader->Read<int32_t>());
769 field.set_guarded_cid(reader->ReadIntptrValue()); 774 field.set_guarded_cid(reader->Read<int32_t>());
770 field.set_is_nullable(reader->ReadIntptrValue()); 775 field.set_is_nullable(reader->Read<int32_t>());
771 field.set_kind_bits(reader->Read<uint8_t>()); 776 field.set_kind_bits(reader->Read<uint8_t>());
772 777
773 // Set all the object fields. 778 // Set all the object fields.
774 // TODO(5411462): Need to assert No GC can happen here, even though 779 // TODO(5411462): Need to assert No GC can happen here, even though
775 // allocations may happen. 780 // allocations may happen.
776 intptr_t num_flds = (field.raw()->to() - field.raw()->from()); 781 intptr_t num_flds = (field.raw()->to() - field.raw()->from());
777 for (intptr_t i = 0; i <= num_flds; i++) { 782 for (intptr_t i = 0; i <= num_flds; i++) {
778 *(field.raw()->from() + i) = reader->ReadObjectRef(); 783 *(field.raw()->from() + i) = reader->ReadObjectRef();
779 } 784 }
780 785
(...skipping 12 matching lines...) Expand all
793 (kind == Snapshot::kFull)); 798 (kind == Snapshot::kFull));
794 799
795 // Write out the serialization header value for this object. 800 // Write out the serialization header value for this object.
796 writer->WriteInlinedObjectHeader(object_id); 801 writer->WriteInlinedObjectHeader(object_id);
797 802
798 // Write out the class and tags information. 803 // Write out the class and tags information.
799 writer->WriteVMIsolateObject(kFieldCid); 804 writer->WriteVMIsolateObject(kFieldCid);
800 writer->WriteIntptrValue(writer->GetObjectTags(this)); 805 writer->WriteIntptrValue(writer->GetObjectTags(this));
801 806
802 // Write out all the non object fields. 807 // Write out all the non object fields.
803 writer->WriteIntptrValue(ptr()->token_pos_); 808 writer->Write<int32_t>(ptr()->token_pos_);
804 writer->WriteIntptrValue(ptr()->guarded_cid_); 809 writer->Write<int32_t>(ptr()->guarded_cid_);
805 writer->WriteIntptrValue(ptr()->is_nullable_); 810 writer->Write<int32_t>(ptr()->is_nullable_);
806 writer->Write<uint8_t>(ptr()->kind_bits_); 811 writer->Write<uint8_t>(ptr()->kind_bits_);
807 812
808 // Write out all the object pointer fields. 813 // Write out all the object pointer fields.
809 SnapshotWriterVisitor visitor(writer); 814 SnapshotWriterVisitor visitor(writer);
810 visitor.VisitPointers(from(), to()); 815 visitor.VisitPointers(from(), to());
811 } 816 }
812 817
813 818
814 RawLiteralToken* LiteralToken::ReadFrom(SnapshotReader* reader, 819 RawLiteralToken* LiteralToken::ReadFrom(SnapshotReader* reader,
815 intptr_t object_id, 820 intptr_t object_id,
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
1004 *reader->StringHandle() ^= reader->ReadObjectImpl(); 1009 *reader->StringHandle() ^= reader->ReadObjectImpl();
1005 library = Library::LookupLibrary(*reader->StringHandle()); 1010 library = Library::LookupLibrary(*reader->StringHandle());
1006 } else { 1011 } else {
1007 // Allocate library object. 1012 // Allocate library object.
1008 library = NEW_OBJECT(Library); 1013 library = NEW_OBJECT(Library);
1009 1014
1010 // Set the object tags. 1015 // Set the object tags.
1011 library.set_tags(tags); 1016 library.set_tags(tags);
1012 1017
1013 // Set all non object fields. 1018 // Set all non object fields.
1014 library.raw_ptr()->index_ = reader->ReadIntptrValue(); 1019 library.raw_ptr()->index_ = reader->Read<int32_t>();
1015 library.raw_ptr()->num_imports_ = reader->ReadIntptrValue(); 1020 library.raw_ptr()->num_imports_ = reader->Read<int32_t>();
1016 library.raw_ptr()->num_anonymous_ = reader->ReadIntptrValue(); 1021 library.raw_ptr()->num_anonymous_ = reader->Read<int32_t>();
1017 library.raw_ptr()->corelib_imported_ = reader->Read<bool>(); 1022 library.raw_ptr()->corelib_imported_ = reader->Read<bool>();
1018 library.raw_ptr()->is_dart_scheme_ = reader->Read<bool>(); 1023 library.raw_ptr()->is_dart_scheme_ = reader->Read<bool>();
1019 library.raw_ptr()->debuggable_ = reader->Read<bool>(); 1024 library.raw_ptr()->debuggable_ = reader->Read<bool>();
1020 library.raw_ptr()->load_state_ = reader->Read<int8_t>(); 1025 library.raw_ptr()->load_state_ = reader->Read<int8_t>();
1021 // The native resolver is not serialized. 1026 // The native resolver is not serialized.
1022 Dart_NativeEntryResolver resolver = 1027 Dart_NativeEntryResolver resolver =
1023 reader->Read<Dart_NativeEntryResolver>(); 1028 reader->Read<Dart_NativeEntryResolver>();
1024 ASSERT(resolver == NULL); 1029 ASSERT(resolver == NULL);
1025 library.set_native_entry_resolver(resolver); 1030 library.set_native_entry_resolver(resolver);
1026 // The symbol resolver is not serialized. 1031 // The symbol resolver is not serialized.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1059 writer->WriteVMIsolateObject(kLibraryCid); 1064 writer->WriteVMIsolateObject(kLibraryCid);
1060 writer->WriteIntptrValue(writer->GetObjectTags(this)); 1065 writer->WriteIntptrValue(writer->GetObjectTags(this));
1061 1066
1062 if ((kind == Snapshot::kScript) && 1067 if ((kind == Snapshot::kScript) &&
1063 RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))) { 1068 RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))) {
1064 ASSERT(kind != Snapshot::kFull); 1069 ASSERT(kind != Snapshot::kFull);
1065 // Write out library URL so that it can be looked up when reading. 1070 // Write out library URL so that it can be looked up when reading.
1066 writer->WriteObjectImpl(ptr()->url_); 1071 writer->WriteObjectImpl(ptr()->url_);
1067 } else { 1072 } else {
1068 // Write out all non object fields. 1073 // Write out all non object fields.
1069 writer->WriteIntptrValue(ptr()->index_); 1074 writer->Write<int32_t>(ptr()->index_);
1070 writer->WriteIntptrValue(ptr()->num_imports_); 1075 writer->Write<int32_t>(ptr()->num_imports_);
1071 writer->WriteIntptrValue(ptr()->num_anonymous_); 1076 writer->Write<int32_t>(ptr()->num_anonymous_);
1072 writer->Write<bool>(ptr()->corelib_imported_); 1077 writer->Write<bool>(ptr()->corelib_imported_);
1073 writer->Write<bool>(ptr()->is_dart_scheme_); 1078 writer->Write<bool>(ptr()->is_dart_scheme_);
1074 writer->Write<bool>(ptr()->debuggable_); 1079 writer->Write<bool>(ptr()->debuggable_);
1075 writer->Write<int8_t>(ptr()->load_state_); 1080 writer->Write<int8_t>(ptr()->load_state_);
1076 // We do not serialize the native resolver over, this needs to be explicitly 1081 // We do not serialize the native resolver over, this needs to be explicitly
1077 // set after deserialization. 1082 // set after deserialization.
1078 writer->Write<Dart_NativeEntryResolver>(NULL); 1083 writer->Write<Dart_NativeEntryResolver>(NULL);
1079 // We do not serialize the native entry symbol, this needs to be explicitly 1084 // We do not serialize the native entry symbol, this needs to be explicitly
1080 // set after deserialization. 1085 // set after deserialization.
1081 writer->Write<Dart_NativeEntrySymbol>(NULL); 1086 writer->Write<Dart_NativeEntrySymbol>(NULL);
(...skipping 19 matching lines...) Expand all
1101 1106
1102 // Allocate library prefix object. 1107 // Allocate library prefix object.
1103 LibraryPrefix& prefix = LibraryPrefix::ZoneHandle( 1108 LibraryPrefix& prefix = LibraryPrefix::ZoneHandle(
1104 reader->isolate(), NEW_OBJECT(LibraryPrefix)); 1109 reader->isolate(), NEW_OBJECT(LibraryPrefix));
1105 reader->AddBackRef(object_id, &prefix, kIsDeserialized); 1110 reader->AddBackRef(object_id, &prefix, kIsDeserialized);
1106 1111
1107 // Set the object tags. 1112 // Set the object tags.
1108 prefix.set_tags(tags); 1113 prefix.set_tags(tags);
1109 1114
1110 // Set all non object fields. 1115 // Set all non object fields.
1111 prefix.raw_ptr()->num_imports_ = reader->ReadIntptrValue(); 1116 prefix.raw_ptr()->num_imports_ = reader->Read<int32_t>();
1112 prefix.raw_ptr()->is_deferred_load_ = reader->Read<bool>(); 1117 prefix.raw_ptr()->is_deferred_load_ = reader->Read<bool>();
1113 prefix.raw_ptr()->is_loaded_ = reader->Read<bool>(); 1118 prefix.raw_ptr()->is_loaded_ = reader->Read<bool>();
1114 1119
1115 // Set all the object fields. 1120 // Set all the object fields.
1116 // TODO(5411462): Need to assert No GC can happen here, even though 1121 // TODO(5411462): Need to assert No GC can happen here, even though
1117 // allocations may happen. 1122 // allocations may happen.
1118 intptr_t num_flds = (prefix.raw()->to() - prefix.raw()->from()); 1123 intptr_t num_flds = (prefix.raw()->to() - prefix.raw()->from());
1119 for (intptr_t i = 0; i <= num_flds; i++) { 1124 for (intptr_t i = 0; i <= num_flds; i++) {
1120 *(prefix.raw()->from() + i) = reader->ReadObjectRef(); 1125 *(prefix.raw()->from() + i) = reader->ReadObjectRef();
1121 } 1126 }
(...skipping 11 matching lines...) Expand all
1133 (kind == Snapshot::kFull)); 1138 (kind == Snapshot::kFull));
1134 1139
1135 // Write out the serialization header value for this object. 1140 // Write out the serialization header value for this object.
1136 writer->WriteInlinedObjectHeader(object_id); 1141 writer->WriteInlinedObjectHeader(object_id);
1137 1142
1138 // Write out the class and tags information. 1143 // Write out the class and tags information.
1139 writer->WriteIndexedObject(kLibraryPrefixCid); 1144 writer->WriteIndexedObject(kLibraryPrefixCid);
1140 writer->WriteIntptrValue(writer->GetObjectTags(this)); 1145 writer->WriteIntptrValue(writer->GetObjectTags(this));
1141 1146
1142 // Write out all non object fields. 1147 // Write out all non object fields.
1143 writer->WriteIntptrValue(ptr()->num_imports_); 1148 writer->Write<int32_t>(ptr()->num_imports_);
1144 writer->Write<bool>(ptr()->is_deferred_load_); 1149 writer->Write<bool>(ptr()->is_deferred_load_);
1145 writer->Write<bool>(ptr()->is_loaded_); 1150 writer->Write<bool>(ptr()->is_loaded_);
1146 1151
1147 // Write out all the object pointer fields. 1152 // Write out all the object pointer fields.
1148 SnapshotWriterVisitor visitor(writer); 1153 SnapshotWriterVisitor visitor(writer);
1149 visitor.VisitPointers(from(), to()); 1154 visitor.VisitPointers(from(), to());
1150 } 1155 }
1151 1156
1152 1157
1153 RawNamespace* Namespace::ReadFrom(SnapshotReader* reader, 1158 RawNamespace* Namespace::ReadFrom(SnapshotReader* reader,
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
1507 1512
1508 // Allocate LanguageError object. 1513 // Allocate LanguageError object.
1509 LanguageError& language_error = 1514 LanguageError& language_error =
1510 LanguageError::ZoneHandle(reader->isolate(), NEW_OBJECT(LanguageError)); 1515 LanguageError::ZoneHandle(reader->isolate(), NEW_OBJECT(LanguageError));
1511 reader->AddBackRef(object_id, &language_error, kIsDeserialized); 1516 reader->AddBackRef(object_id, &language_error, kIsDeserialized);
1512 1517
1513 // Set the object tags. 1518 // Set the object tags.
1514 language_error.set_tags(tags); 1519 language_error.set_tags(tags);
1515 1520
1516 // Set all non object fields. 1521 // Set all non object fields.
1517 language_error.set_token_pos(reader->ReadIntptrValue()); 1522 language_error.set_token_pos(reader->Read<int32_t>());
1518 language_error.set_kind(reader->Read<uint8_t>()); 1523 language_error.set_kind(reader->Read<uint8_t>());
1519 1524
1520 // Set all the object fields. 1525 // Set all the object fields.
1521 // TODO(5411462): Need to assert No GC can happen here, even though 1526 // TODO(5411462): Need to assert No GC can happen here, even though
1522 // allocations may happen. 1527 // allocations may happen.
1523 intptr_t num_flds = 1528 intptr_t num_flds =
1524 (language_error.raw()->to() - language_error.raw()->from()); 1529 (language_error.raw()->to() - language_error.raw()->from());
1525 for (intptr_t i = 0; i <= num_flds; i++) { 1530 for (intptr_t i = 0; i <= num_flds; i++) {
1526 (*reader->ObjectHandle()) = reader->ReadObjectRef(); 1531 (*reader->ObjectHandle()) = reader->ReadObjectRef();
1527 language_error.StorePointer((language_error.raw()->from() + i), 1532 language_error.StorePointer((language_error.raw()->from() + i),
(...skipping 10 matching lines...) Expand all
1538 ASSERT(writer != NULL); 1543 ASSERT(writer != NULL);
1539 1544
1540 // Write out the serialization header value for this object. 1545 // Write out the serialization header value for this object.
1541 writer->WriteInlinedObjectHeader(object_id); 1546 writer->WriteInlinedObjectHeader(object_id);
1542 1547
1543 // Write out the class and tags information. 1548 // Write out the class and tags information.
1544 writer->WriteVMIsolateObject(kLanguageErrorCid); 1549 writer->WriteVMIsolateObject(kLanguageErrorCid);
1545 writer->WriteIntptrValue(writer->GetObjectTags(this)); 1550 writer->WriteIntptrValue(writer->GetObjectTags(this));
1546 1551
1547 // Write out all the non object fields. 1552 // Write out all the non object fields.
1548 writer->WriteIntptrValue(ptr()->token_pos_); 1553 writer->Write<int32_t>(ptr()->token_pos_);
1549 writer->Write<uint8_t>(ptr()->kind_); 1554 writer->Write<uint8_t>(ptr()->kind_);
1550 1555
1551 // Write out all the object pointer fields. 1556 // Write out all the object pointer fields.
1552 SnapshotWriterVisitor visitor(writer); 1557 SnapshotWriterVisitor visitor(writer);
1553 visitor.VisitPointers(from(), to()); 1558 visitor.VisitPointers(from(), to());
1554 } 1559 }
1555 1560
1556 1561
1557 RawUnhandledException* UnhandledException::ReadFrom(SnapshotReader* reader, 1562 RawUnhandledException* UnhandledException::ReadFrom(SnapshotReader* reader,
1558 intptr_t object_id, 1563 intptr_t object_id,
(...skipping 1219 matching lines...) Expand 10 before | Expand all | Expand 10 after
2778 // We do not allow objects with native fields in an isolate message. 2783 // We do not allow objects with native fields in an isolate message.
2779 writer->SetWriteException(Exceptions::kArgument, 2784 writer->SetWriteException(Exceptions::kArgument,
2780 "Illegal argument in isolate message" 2785 "Illegal argument in isolate message"
2781 " : (object is a UserTag)"); 2786 " : (object is a UserTag)");
2782 } else { 2787 } else {
2783 UNREACHABLE(); 2788 UNREACHABLE();
2784 } 2789 }
2785 } 2790 }
2786 2791
2787 } // namespace dart 2792 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/raw_object.h ('k') | runtime/vm/stub_code_arm64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698