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

Side by Side Diff: vm/raw_object_snapshot.cc

Issue 8879063: Changes to set up the object tag bits (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: '' Created 9 years 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 | « vm/raw_object.h ('k') | vm/snapshot.h » ('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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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/visitor.h" 9 #include "vm/visitor.h"
10 10
11 namespace dart { 11 namespace dart {
12 12
13 static RawSmi* GetSmi(intptr_t value) { 13 static RawSmi* GetSmi(intptr_t value) {
14 ASSERT((value & kSmiTagMask) == 0); 14 ASSERT((value & kSmiTagMask) == 0);
15 return reinterpret_cast<RawSmi*>(value); 15 return reinterpret_cast<RawSmi*>(value);
16 } 16 }
17 17
18 18
19 static uword ZoneAllocator(intptr_t size) { 19 static uword ZoneAllocator(intptr_t size) {
20 Zone* zone = Isolate::Current()->current_zone(); 20 Zone* zone = Isolate::Current()->current_zone();
21 return zone->Allocate(size); 21 return zone->Allocate(size);
22 } 22 }
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 Snapshot::Kind kind) { 28 Snapshot::Kind kind) {
28 ASSERT(reader != NULL); 29 ASSERT(reader != NULL);
29 30
30 Class& cls = Class::ZoneHandle(); 31 Class& cls = Class::ZoneHandle();
31 if (kind == Snapshot::kFull) { 32 if (kind == Snapshot::kFull) {
32 // Read in the base information. 33 // Read in the base information.
33 ObjectKind kind = reader->Read<ObjectKind>(); 34 ObjectKind kind = reader->Read<ObjectKind>();
34 35
35 // Allocate class object of specified kind. 36 // Allocate class object of specified kind.
36 cls = Class::GetClass(kind); 37 cls = Class::GetClass(kind);
37 reader->AddBackwardReference(object_id, &cls); 38 reader->AddBackwardReference(object_id, &cls);
38 39
40 // Set the object tags.
41 cls.set_tags(tags);
42
39 // Set all non object fields. 43 // Set all non object fields.
40 cls.set_instance_size(reader->Read<intptr_t>()); 44 cls.set_instance_size(reader->Read<intptr_t>());
41 cls.set_type_arguments_instance_field_offset(reader->Read<intptr_t>()); 45 cls.set_type_arguments_instance_field_offset(reader->Read<intptr_t>());
42 cls.set_next_field_offset(reader->Read<intptr_t>()); 46 cls.set_next_field_offset(reader->Read<intptr_t>());
43 cls.set_num_native_fields(reader->Read<intptr_t>()); 47 cls.set_num_native_fields(reader->Read<intptr_t>());
44 cls.set_class_state(reader->Read<int8_t>()); 48 cls.set_class_state(reader->Read<int8_t>());
45 if (reader->Read<bool>()) { 49 if (reader->Read<bool>()) {
46 cls.set_is_const(); 50 cls.set_is_const();
47 } 51 }
48 if (reader->Read<bool>()) { 52 if (reader->Read<bool>()) {
(...skipping 14 matching lines...) Expand all
63 } 67 }
64 68
65 69
66 void RawClass::WriteTo(SnapshotWriter* writer, 70 void RawClass::WriteTo(SnapshotWriter* writer,
67 intptr_t object_id, 71 intptr_t object_id,
68 Snapshot::Kind kind) { 72 Snapshot::Kind kind) {
69 ASSERT(writer != NULL); 73 ASSERT(writer != NULL);
70 SnapshotWriterVisitor visitor(writer); 74 SnapshotWriterVisitor visitor(writer);
71 75
72 // Write out the serialization header value for this object. 76 // Write out the serialization header value for this object.
73 writer->WriteObjectHeader(kInlined, object_id); 77 writer->WriteSerializationMarker(kInlined, object_id);
74 78
75 if (kind == Snapshot::kFull) { 79 if (kind == Snapshot::kFull) {
76 // Write out the class information. 80 // Write out the class and tags information.
77 writer->WriteObjectHeader(kObjectId, Object::kClassClass); 81 writer->WriteObjectHeader(Object::kClassClass, ptr()->tags_);
78 82
79 // Write out all the non object pointer fields. 83 // Write out all the non object pointer fields.
80 // NOTE: cpp_vtable_ is not written. 84 // NOTE: cpp_vtable_ is not written.
81 writer->Write<ObjectKind>(ptr()->instance_kind_); 85 writer->Write<ObjectKind>(ptr()->instance_kind_);
82 writer->Write<intptr_t>(ptr()->instance_size_); 86 writer->Write<intptr_t>(ptr()->instance_size_);
83 writer->Write<intptr_t>(ptr()->type_arguments_instance_field_offset_); 87 writer->Write<intptr_t>(ptr()->type_arguments_instance_field_offset_);
84 writer->Write<intptr_t>(ptr()->next_field_offset_); 88 writer->Write<intptr_t>(ptr()->next_field_offset_);
85 writer->Write<intptr_t>(ptr()->num_native_fields_); 89 writer->Write<intptr_t>(ptr()->num_native_fields_);
86 writer->Write<int8_t>(ptr()->class_state_); 90 writer->Write<int8_t>(ptr()->class_state_);
87 writer->Write<bool>(ptr()->is_const_); 91 writer->Write<bool>(ptr()->is_const_);
88 writer->Write<bool>(ptr()->is_interface_); 92 writer->Write<bool>(ptr()->is_interface_);
89 93
90 // Write out all the object pointer fields. 94 // Write out all the object pointer fields.
91 visitor.VisitPointers(from(), to()); 95 visitor.VisitPointers(from(), to());
92 } else { 96 } else {
93 writer->WriteClassId(this); 97 writer->WriteClassId(this);
94 } 98 }
95 } 99 }
96 100
97 101
98 RawUnresolvedClass* UnresolvedClass::ReadFrom(SnapshotReader* reader, 102 RawUnresolvedClass* UnresolvedClass::ReadFrom(SnapshotReader* reader,
99 intptr_t object_id, 103 intptr_t object_id,
104 intptr_t tags,
100 Snapshot::Kind kind) { 105 Snapshot::Kind kind) {
101 ASSERT(reader != NULL); 106 ASSERT(reader != NULL);
102 107
103 // Allocate parameterized type object. 108 // Allocate parameterized type object.
104 UnresolvedClass& unresolved_class = 109 UnresolvedClass& unresolved_class =
105 UnresolvedClass::ZoneHandle(UnresolvedClass::New()); 110 UnresolvedClass::ZoneHandle(UnresolvedClass::New());
106 reader->AddBackwardReference(object_id, &unresolved_class); 111 reader->AddBackwardReference(object_id, &unresolved_class);
107 112
113 // Set the object tags.
114 unresolved_class.set_tags(tags);
115
108 // Set all non object fields. 116 // Set all non object fields.
109 unresolved_class.set_token_index(reader->Read<intptr_t>()); 117 unresolved_class.set_token_index(reader->Read<intptr_t>());
110 118
111 // Set all the object fields. 119 // Set all the object fields.
112 // TODO(5411462): Need to assert No GC can happen here, even though 120 // TODO(5411462): Need to assert No GC can happen here, even though
113 // allocations may happen. 121 // allocations may happen.
114 intptr_t num_flds = (unresolved_class.raw()->to() - 122 intptr_t num_flds = (unresolved_class.raw()->to() -
115 unresolved_class.raw()->from()); 123 unresolved_class.raw()->from());
116 for (intptr_t i = 0; i <= num_flds; i++) { 124 for (intptr_t i = 0; i <= num_flds; i++) {
117 *(unresolved_class.raw()->from() + i) = reader->ReadObject(); 125 *(unresolved_class.raw()->from() + i) = reader->ReadObject();
118 } 126 }
119 return unresolved_class.raw(); 127 return unresolved_class.raw();
120 } 128 }
121 129
122 130
123 void RawUnresolvedClass::WriteTo(SnapshotWriter* writer, 131 void RawUnresolvedClass::WriteTo(SnapshotWriter* writer,
124 intptr_t object_id, 132 intptr_t object_id,
125 Snapshot::Kind kind) { 133 Snapshot::Kind kind) {
126 ASSERT(writer != NULL); 134 ASSERT(writer != NULL);
127 SnapshotWriterVisitor visitor(writer); 135 SnapshotWriterVisitor visitor(writer);
128 136
129 // Write out the serialization header value for this object. 137 // Write out the serialization header value for this object.
130 writer->WriteObjectHeader(kInlined, object_id); 138 writer->WriteSerializationMarker(kInlined, object_id);
131 139
132 // Write out the class information. 140 // Write out the class and tags information.
133 writer->WriteObjectHeader(kObjectId, Object::kUnresolvedClassClass); 141 writer->WriteObjectHeader(Object::kUnresolvedClassClass, ptr()->tags_);
134 142
135 // Write out all the non object pointer fields. 143 // Write out all the non object pointer fields.
136 writer->Write<intptr_t>(ptr()->token_index_); 144 writer->Write<intptr_t>(ptr()->token_index_);
137 145
138 // Write out all the object pointer fields. 146 // Write out all the object pointer fields.
139 visitor.VisitPointers(from(), to()); 147 visitor.VisitPointers(from(), to());
140 } 148 }
141 149
142 150
143 RawAbstractType* AbstractType::ReadFrom(SnapshotReader* reader, 151 RawAbstractType* AbstractType::ReadFrom(SnapshotReader* reader,
144 intptr_t object_id, 152 intptr_t object_id,
145 Snapshot::Kind kind) { 153 intptr_t tags,
154 Snapshot::Kind kind) {
146 UNREACHABLE(); // AbstractType is an abstract class. 155 UNREACHABLE(); // AbstractType is an abstract class.
147 return NULL; 156 return NULL;
148 } 157 }
149 158
150 159
151 void RawAbstractType::WriteTo(SnapshotWriter* writer, 160 void RawAbstractType::WriteTo(SnapshotWriter* writer,
152 intptr_t object_id, 161 intptr_t object_id,
153 Snapshot::Kind kind) { 162 Snapshot::Kind kind) {
154 UNREACHABLE(); // AbstractType is an abstract class. 163 UNREACHABLE(); // AbstractType is an abstract class.
155 } 164 }
156 165
157 166
158 RawType* Type::ReadFrom(SnapshotReader* reader, 167 RawType* Type::ReadFrom(SnapshotReader* reader,
159 intptr_t object_id, 168 intptr_t object_id,
160 Snapshot::Kind kind) { 169 intptr_t tags,
170 Snapshot::Kind kind) {
161 ASSERT(reader != NULL); 171 ASSERT(reader != NULL);
162 172
163 // Allocate parameterized type object. 173 // Allocate parameterized type object.
164 Type& parameterized_type = Type::ZoneHandle(Type::New()); 174 Type& parameterized_type = Type::ZoneHandle(Type::New());
165 reader->AddBackwardReference(object_id, &parameterized_type); 175 reader->AddBackwardReference(object_id, &parameterized_type);
166 176
177 // Set the object tags.
178 parameterized_type.set_tags(tags);
179
167 // Set all non object fields. 180 // Set all non object fields.
168 parameterized_type.set_type_state(reader->Read<int8_t>()); 181 parameterized_type.set_type_state(reader->Read<int8_t>());
169 182
170 // Set all the object fields. 183 // Set all the object fields.
171 // TODO(5411462): Need to assert No GC can happen here, even though 184 // TODO(5411462): Need to assert No GC can happen here, even though
172 // allocations may happen. 185 // allocations may happen.
173 intptr_t num_flds = (parameterized_type.raw()->to() - 186 intptr_t num_flds = (parameterized_type.raw()->to() -
174 parameterized_type.raw()->from()); 187 parameterized_type.raw()->from());
175 for (intptr_t i = 0; i <= num_flds; i++) { 188 for (intptr_t i = 0; i <= num_flds; i++) {
176 *(parameterized_type.raw()->from() + i) = reader->ReadObject(); 189 *(parameterized_type.raw()->from() + i) = reader->ReadObject();
177 } 190 }
178 return parameterized_type.raw(); 191 return parameterized_type.raw();
179 } 192 }
180 193
181 194
182 void RawType::WriteTo(SnapshotWriter* writer, 195 void RawType::WriteTo(SnapshotWriter* writer,
183 intptr_t object_id, 196 intptr_t object_id,
184 Snapshot::Kind kind) { 197 Snapshot::Kind kind) {
185 ASSERT(writer != NULL); 198 ASSERT(writer != NULL);
186 SnapshotWriterVisitor visitor(writer); 199 SnapshotWriterVisitor visitor(writer);
187 200
188 // Write out the serialization header value for this object. 201 // Write out the serialization header value for this object.
189 writer->WriteObjectHeader(kInlined, object_id); 202 writer->WriteSerializationMarker(kInlined, object_id);
190 203
191 // Write out the class information. 204 // Write out the class and tags information.
192 writer->WriteObjectHeader(kObjectId, Object::kTypeClass); 205 writer->WriteObjectHeader(Object::kTypeClass, ptr()->tags_);
193 206
194 // Write out all the non object pointer fields. 207 // Write out all the non object pointer fields.
195 writer->Write<int8_t>(ptr()->type_state_); 208 writer->Write<int8_t>(ptr()->type_state_);
196 209
197 // Write out all the object pointer fields. 210 // Write out all the object pointer fields.
198 visitor.VisitPointers(from(), to()); 211 visitor.VisitPointers(from(), to());
199 } 212 }
200 213
201 214
202 RawTypeParameter* TypeParameter::ReadFrom(SnapshotReader* reader, 215 RawTypeParameter* TypeParameter::ReadFrom(SnapshotReader* reader,
203 intptr_t object_id, 216 intptr_t object_id,
217 intptr_t tags,
204 Snapshot::Kind kind) { 218 Snapshot::Kind kind) {
205 ASSERT(reader != NULL); 219 ASSERT(reader != NULL);
206 220
207 // Allocate type parameter object. 221 // Allocate type parameter object.
208 TypeParameter& type_parameter = 222 TypeParameter& type_parameter =
209 TypeParameter::ZoneHandle(TypeParameter::New()); 223 TypeParameter::ZoneHandle(TypeParameter::New());
210 reader->AddBackwardReference(object_id, &type_parameter); 224 reader->AddBackwardReference(object_id, &type_parameter);
211 225
226 // Set the object tags.
227 type_parameter.set_tags(tags);
228
212 // Set all non object fields. 229 // Set all non object fields.
213 type_parameter.set_index(reader->Read<intptr_t>()); 230 type_parameter.set_index(reader->Read<intptr_t>());
214 type_parameter.set_type_state(reader->Read<int8_t>()); 231 type_parameter.set_type_state(reader->Read<int8_t>());
215 232
216 // Set all the object fields. 233 // Set all the object fields.
217 // TODO(5411462): Need to assert No GC can happen here, even though 234 // TODO(5411462): Need to assert No GC can happen here, even though
218 // allocations may happen. 235 // allocations may happen.
219 intptr_t num_flds = (type_parameter.raw()->to() - 236 intptr_t num_flds = (type_parameter.raw()->to() -
220 type_parameter.raw()->from()); 237 type_parameter.raw()->from());
221 for (intptr_t i = 0; i <= num_flds; i++) { 238 for (intptr_t i = 0; i <= num_flds; i++) {
222 *(type_parameter.raw()->from() + i) = reader->ReadObject(); 239 *(type_parameter.raw()->from() + i) = reader->ReadObject();
223 } 240 }
224 241
225 return type_parameter.raw(); 242 return type_parameter.raw();
226 } 243 }
227 244
228 245
229 void RawTypeParameter::WriteTo(SnapshotWriter* writer, 246 void RawTypeParameter::WriteTo(SnapshotWriter* writer,
230 intptr_t object_id, 247 intptr_t object_id,
231 Snapshot::Kind kind) { 248 Snapshot::Kind kind) {
232 ASSERT(writer != NULL); 249 ASSERT(writer != NULL);
233 SnapshotWriterVisitor visitor(writer); 250 SnapshotWriterVisitor visitor(writer);
234 251
235 // Write out the serialization header value for this object. 252 // Write out the serialization header value for this object.
236 writer->WriteObjectHeader(kInlined, object_id); 253 writer->WriteSerializationMarker(kInlined, object_id);
237 254
238 // Write out the class information. 255 // Write out the class and tags information.
239 writer->WriteObjectHeader(kObjectId, Object::kTypeParameterClass); 256 writer->WriteObjectHeader(Object::kTypeParameterClass, ptr()->tags_);
240 257
241 // Write out all the non object pointer fields. 258 // Write out all the non object pointer fields.
242 writer->Write<intptr_t>(ptr()->index_); 259 writer->Write<intptr_t>(ptr()->index_);
243 writer->Write<int8_t>(ptr()->type_state_); 260 writer->Write<int8_t>(ptr()->type_state_);
244 261
245 // Write out all the object pointer fields. 262 // Write out all the object pointer fields.
246 visitor.VisitPointers(from(), to()); 263 visitor.VisitPointers(from(), to());
247 } 264 }
248 265
249 266
250 RawInstantiatedType* InstantiatedType::ReadFrom(SnapshotReader* reader, 267 RawInstantiatedType* InstantiatedType::ReadFrom(SnapshotReader* reader,
251 intptr_t object_id, 268 intptr_t object_id,
269 intptr_t tags,
252 Snapshot::Kind kind) { 270 Snapshot::Kind kind) {
253 ASSERT(reader != NULL); 271 ASSERT(reader != NULL);
254 ASSERT(kind == Snapshot::kMessage); 272 ASSERT(kind == Snapshot::kMessage);
255 273
256 // Allocate instantiated type object. 274 // Allocate instantiated type object.
257 InstantiatedType& instantiated_type = 275 InstantiatedType& instantiated_type =
258 InstantiatedType::ZoneHandle(InstantiatedType::New()); 276 InstantiatedType::ZoneHandle(InstantiatedType::New());
259 reader->AddBackwardReference(object_id, &instantiated_type); 277 reader->AddBackwardReference(object_id, &instantiated_type);
260 278
279 // Set the object tags.
280 instantiated_type.set_tags(tags);
281
261 // Now set all the object fields. 282 // Now set all the object fields.
262 // TODO(5411462): Need to assert No GC can happen here, even though 283 // TODO(5411462): Need to assert No GC can happen here, even though
263 // allocations may happen. 284 // allocations may happen.
264 intptr_t num_flds = (instantiated_type.raw()->to() - 285 intptr_t num_flds = (instantiated_type.raw()->to() -
265 instantiated_type.raw()->from()); 286 instantiated_type.raw()->from());
266 for (intptr_t i = 0; i <= num_flds; i++) { 287 for (intptr_t i = 0; i <= num_flds; i++) {
267 *(instantiated_type.raw()->from() + i) = reader->ReadObject(); 288 *(instantiated_type.raw()->from() + i) = reader->ReadObject();
268 } 289 }
269 return instantiated_type.raw(); 290 return instantiated_type.raw();
270 } 291 }
271 292
272 293
273 void RawInstantiatedType::WriteTo(SnapshotWriter* writer, 294 void RawInstantiatedType::WriteTo(SnapshotWriter* writer,
274 intptr_t object_id, 295 intptr_t object_id,
275 Snapshot::Kind kind) { 296 Snapshot::Kind kind) {
276 ASSERT(writer != NULL); 297 ASSERT(writer != NULL);
277 ASSERT(kind == Snapshot::kMessage); 298 ASSERT(kind == Snapshot::kMessage);
278 SnapshotWriterVisitor visitor(writer); 299 SnapshotWriterVisitor visitor(writer);
279 300
280 // Write out the serialization header value for this object. 301 // Write out the serialization header value for this object.
281 writer->WriteObjectHeader(kInlined, object_id); 302 writer->WriteSerializationMarker(kInlined, object_id);
282 303
283 // Write out the class information. 304 // Write out the class and tags information.
284 writer->WriteObjectHeader(kObjectId, Object::kInstantiatedTypeClass); 305 writer->WriteObjectHeader(Object::kInstantiatedTypeClass, ptr()->tags_);
285 306
286 // Write out all the object pointer fields. 307 // Write out all the object pointer fields.
287 visitor.VisitPointers(from(), to()); 308 visitor.VisitPointers(from(), to());
288 } 309 }
289 310
290 311
291 RawAbstractTypeArguments* AbstractTypeArguments::ReadFrom( 312 RawAbstractTypeArguments* AbstractTypeArguments::ReadFrom(
292 SnapshotReader* reader, 313 SnapshotReader* reader,
293 intptr_t object_id, 314 intptr_t object_id,
315 intptr_t tags,
294 Snapshot::Kind kind) { 316 Snapshot::Kind kind) {
295 UNREACHABLE(); // AbstractTypeArguments is an abstract class. 317 UNREACHABLE(); // AbstractTypeArguments is an abstract class.
296 return TypeArguments::null(); 318 return TypeArguments::null();
297 } 319 }
298 320
299 321
300 void RawAbstractTypeArguments::WriteTo(SnapshotWriter* writer, 322 void RawAbstractTypeArguments::WriteTo(SnapshotWriter* writer,
301 intptr_t object_id, 323 intptr_t object_id,
302 Snapshot::Kind kind) { 324 Snapshot::Kind kind) {
303 UNREACHABLE(); // AbstractTypeArguments is an abstract class. 325 UNREACHABLE(); // AbstractTypeArguments is an abstract class.
304 } 326 }
305 327
306 328
307 RawTypeArguments* TypeArguments::ReadFrom(SnapshotReader* reader, 329 RawTypeArguments* TypeArguments::ReadFrom(SnapshotReader* reader,
308 intptr_t object_id, 330 intptr_t object_id,
331 intptr_t tags,
309 Snapshot::Kind kind) { 332 Snapshot::Kind kind) {
310 ASSERT(reader != NULL); 333 ASSERT(reader != NULL);
311 334
312 const bool is_canonical = reader->Read<bool>();
313 // Read the length so that we can determine instance size to allocate. 335 // Read the length so that we can determine instance size to allocate.
314 RawSmi* smi_len = GetSmi(reader->Read<intptr_t>()); 336 RawSmi* smi_len = GetSmi(reader->Read<intptr_t>());
315 intptr_t len = Smi::Value(smi_len); 337 intptr_t len = Smi::Value(smi_len);
316 338
317 TypeArguments& type_arguments = 339 TypeArguments& type_arguments =
318 TypeArguments::Handle(TypeArguments::New(len)); 340 TypeArguments::Handle(TypeArguments::New(len));
319 reader->AddBackwardReference(object_id, &type_arguments); 341 reader->AddBackwardReference(object_id, &type_arguments);
342
343 // Now set all the object fields.
320 AbstractType& type = AbstractType::Handle(); 344 AbstractType& type = AbstractType::Handle();
321 for (intptr_t i = 0; i < len; i++) { 345 for (intptr_t i = 0; i < len; i++) {
322 type ^= reader->ReadObject(); 346 type ^= reader->ReadObject();
323 type_arguments.SetTypeAt(i, type); 347 type_arguments.SetTypeAt(i, type);
324 } 348 }
325 type_arguments.set_is_canonical(is_canonical); 349
350 // Set the object tags.
351 type_arguments.set_tags(tags);
326 352
327 return type_arguments.raw(); 353 return type_arguments.raw();
328 } 354 }
329 355
330 356
331 void RawTypeArguments::WriteTo(SnapshotWriter* writer, 357 void RawTypeArguments::WriteTo(SnapshotWriter* writer,
332 intptr_t object_id, 358 intptr_t object_id,
333 Snapshot::Kind kind) { 359 Snapshot::Kind kind) {
334 ASSERT(writer != NULL); 360 ASSERT(writer != NULL);
335 361
336 // Write out the serialization header value for this object. 362 // Write out the serialization header value for this object.
337 writer->WriteObjectHeader(kInlined, object_id); 363 writer->WriteSerializationMarker(kInlined, object_id);
338 364
339 // Write out the class information. 365 // Write out the class and tags information.
340 writer->WriteObjectHeader(kObjectId, Object::kTypeArgumentsClass); 366 writer->WriteObjectHeader(Object::kTypeArgumentsClass, ptr()->tags_);
341 367
342 writer->Write<bool>(ptr()->is_canonical_);
343 // Write out the length field. 368 // Write out the length field.
344 writer->Write<RawObject*>(ptr()->length_); 369 writer->Write<RawObject*>(ptr()->length_);
345 370
346 // Write out the individual types. 371 // Write out the individual types.
347 intptr_t len = Smi::Value(ptr()->length_); 372 intptr_t len = Smi::Value(ptr()->length_);
348 for (intptr_t i = 0; i < len; i++) { 373 for (intptr_t i = 0; i < len; i++) {
349 writer->WriteObject(ptr()->types_[i]); 374 writer->WriteObject(ptr()->types_[i]);
350 } 375 }
351 } 376 }
352 377
353 378
354 RawInstantiatedTypeArguments* InstantiatedTypeArguments::ReadFrom( 379 RawInstantiatedTypeArguments* InstantiatedTypeArguments::ReadFrom(
355 SnapshotReader* reader, 380 SnapshotReader* reader,
356 intptr_t object_id, 381 intptr_t object_id,
382 intptr_t tags,
357 Snapshot::Kind kind) { 383 Snapshot::Kind kind) {
358 ASSERT(reader != NULL); 384 ASSERT(reader != NULL);
359 ASSERT(kind == Snapshot::kMessage); 385 ASSERT(kind == Snapshot::kMessage);
360 386
361 // Allocate instantiated types object. 387 // Allocate instantiated types object.
362 InstantiatedTypeArguments& instantiated_type_arguments = 388 InstantiatedTypeArguments& instantiated_type_arguments =
363 InstantiatedTypeArguments::ZoneHandle(InstantiatedTypeArguments::New()); 389 InstantiatedTypeArguments::ZoneHandle(InstantiatedTypeArguments::New());
364 reader->AddBackwardReference(object_id, &instantiated_type_arguments); 390 reader->AddBackwardReference(object_id, &instantiated_type_arguments);
365 391
392 // Set the object tags.
393 instantiated_type_arguments.set_tags(tags);
394
366 // Set all the object fields. 395 // Set all the object fields.
367 // TODO(5411462): Need to assert No GC can happen here, even though 396 // TODO(5411462): Need to assert No GC can happen here, even though
368 // allocations may happen. 397 // allocations may happen.
369 intptr_t num_flds = (instantiated_type_arguments.raw()->to() - 398 intptr_t num_flds = (instantiated_type_arguments.raw()->to() -
370 instantiated_type_arguments.raw()->from()); 399 instantiated_type_arguments.raw()->from());
371 for (intptr_t i = 0; i <= num_flds; i++) { 400 for (intptr_t i = 0; i <= num_flds; i++) {
372 *(instantiated_type_arguments.raw()->from() + i) = reader->ReadObject(); 401 *(instantiated_type_arguments.raw()->from() + i) = reader->ReadObject();
373 } 402 }
374 return instantiated_type_arguments.raw(); 403 return instantiated_type_arguments.raw();
375 } 404 }
376 405
377 406
378 void RawInstantiatedTypeArguments::WriteTo(SnapshotWriter* writer, 407 void RawInstantiatedTypeArguments::WriteTo(SnapshotWriter* writer,
379 intptr_t object_id, 408 intptr_t object_id,
380 Snapshot::Kind kind) { 409 Snapshot::Kind kind) {
381 ASSERT(writer != NULL); 410 ASSERT(writer != NULL);
382 ASSERT(kind == Snapshot::kMessage); 411 ASSERT(kind == Snapshot::kMessage);
383 SnapshotWriterVisitor visitor(writer); 412 SnapshotWriterVisitor visitor(writer);
384 413
385 // Write out the serialization header value for this object. 414 // Write out the serialization header value for this object.
386 writer->WriteObjectHeader(kInlined, object_id); 415 writer->WriteSerializationMarker(kInlined, object_id);
387 416
388 // Write out the class information. 417 // Write out the class and tags information.
389 writer->WriteObjectHeader(kObjectId, Object::kInstantiatedTypeArgumentsClass); 418 writer->WriteObjectHeader(Object::kInstantiatedTypeArgumentsClass,
419 ptr()->tags_);
390 420
391 // Write out all the object pointer fields. 421 // Write out all the object pointer fields.
392 visitor.VisitPointers(from(), to()); 422 visitor.VisitPointers(from(), to());
393 } 423 }
394 424
395 425
396 RawFunction* Function::ReadFrom(SnapshotReader* reader, 426 RawFunction* Function::ReadFrom(SnapshotReader* reader,
397 intptr_t object_id, 427 intptr_t object_id,
428 intptr_t tags,
398 Snapshot::Kind kind) { 429 Snapshot::Kind kind) {
399 ASSERT(reader != NULL); 430 ASSERT(reader != NULL);
400 431
401 // Allocate function object. 432 // Allocate function object.
402 Function& func = Function::ZoneHandle(Function::New()); 433 Function& func = Function::ZoneHandle(Function::New());
403 reader->AddBackwardReference(object_id, &func); 434 reader->AddBackwardReference(object_id, &func);
404 435
436 // Set the object tags.
437 func.set_tags(tags);
438
405 // Set all the non object fields. 439 // Set all the non object fields.
406 func.set_token_index(reader->Read<intptr_t>()); 440 func.set_token_index(reader->Read<intptr_t>());
407 func.set_num_fixed_parameters(reader->Read<intptr_t>()); 441 func.set_num_fixed_parameters(reader->Read<intptr_t>());
408 func.set_num_optional_parameters(reader->Read<intptr_t>()); 442 func.set_num_optional_parameters(reader->Read<intptr_t>());
409 func.set_invocation_counter(reader->Read<intptr_t>()); 443 func.set_invocation_counter(reader->Read<intptr_t>());
410 func.set_deoptimization_counter(reader->Read<intptr_t>()); 444 func.set_deoptimization_counter(reader->Read<intptr_t>());
411 func.set_kind(static_cast<RawFunction::Kind >(reader->Read<intptr_t>())); 445 func.set_kind(static_cast<RawFunction::Kind >(reader->Read<intptr_t>()));
412 func.set_is_static(reader->Read<bool>()); 446 func.set_is_static(reader->Read<bool>());
413 func.set_is_const(reader->Read<bool>()); 447 func.set_is_const(reader->Read<bool>());
414 func.set_is_optimizable(reader->Read<bool>()); 448 func.set_is_optimizable(reader->Read<bool>());
(...skipping 10 matching lines...) Expand all
425 } 459 }
426 460
427 461
428 void RawFunction::WriteTo(SnapshotWriter* writer, 462 void RawFunction::WriteTo(SnapshotWriter* writer,
429 intptr_t object_id, 463 intptr_t object_id,
430 Snapshot::Kind kind) { 464 Snapshot::Kind kind) {
431 ASSERT(writer != NULL); 465 ASSERT(writer != NULL);
432 SnapshotWriterVisitor visitor(writer); 466 SnapshotWriterVisitor visitor(writer);
433 467
434 // Write out the serialization header value for this object. 468 // Write out the serialization header value for this object.
435 writer->WriteObjectHeader(kInlined, object_id); 469 writer->WriteSerializationMarker(kInlined, object_id);
436 470
437 // Write out the class information. 471 // Write out the class and tags information.
438 writer->WriteObjectHeader(kObjectId, Object::kFunctionClass); 472 writer->WriteObjectHeader(Object::kFunctionClass, ptr()->tags_);
439 473
440 // Write out all the non object fields. 474 // Write out all the non object fields.
441 writer->Write<intptr_t>(ptr()->token_index_); 475 writer->Write<intptr_t>(ptr()->token_index_);
442 writer->Write<intptr_t>(ptr()->num_fixed_parameters_); 476 writer->Write<intptr_t>(ptr()->num_fixed_parameters_);
443 writer->Write<intptr_t>(ptr()->num_optional_parameters_); 477 writer->Write<intptr_t>(ptr()->num_optional_parameters_);
444 writer->Write<intptr_t>(ptr()->invocation_counter_); 478 writer->Write<intptr_t>(ptr()->invocation_counter_);
445 writer->Write<intptr_t>(ptr()->deoptimization_counter_); 479 writer->Write<intptr_t>(ptr()->deoptimization_counter_);
446 writer->Write<intptr_t>(ptr()->kind_); 480 writer->Write<intptr_t>(ptr()->kind_);
447 writer->Write<bool>(ptr()->is_static_); 481 writer->Write<bool>(ptr()->is_static_);
448 writer->Write<bool>(ptr()->is_const_); 482 writer->Write<bool>(ptr()->is_const_);
449 writer->Write<bool>(ptr()->is_optimizable_); 483 writer->Write<bool>(ptr()->is_optimizable_);
450 484
451 // Write out all the object pointer fields. 485 // Write out all the object pointer fields.
452 visitor.VisitPointers(from(), to()); 486 visitor.VisitPointers(from(), to());
453 } 487 }
454 488
455 489
456 RawField* Field::ReadFrom(SnapshotReader* reader, 490 RawField* Field::ReadFrom(SnapshotReader* reader,
457 intptr_t object_id, 491 intptr_t object_id,
492 intptr_t tags,
458 Snapshot::Kind kind) { 493 Snapshot::Kind kind) {
459 ASSERT(reader != NULL); 494 ASSERT(reader != NULL);
460 495
461 // Allocate field object. 496 // Allocate field object.
462 Field& field = Field::ZoneHandle(Field::New()); 497 Field& field = Field::ZoneHandle(Field::New());
463 reader->AddBackwardReference(object_id, &field); 498 reader->AddBackwardReference(object_id, &field);
464 499
500 // Set the object tags.
501 field.set_tags(tags);
502
465 // Set all non object fields. 503 // Set all non object fields.
466 field.set_token_index(reader->Read<intptr_t>()); 504 field.set_token_index(reader->Read<intptr_t>());
467 field.set_is_static(reader->Read<bool>()); 505 field.set_is_static(reader->Read<bool>());
468 field.set_is_final(reader->Read<bool>()); 506 field.set_is_final(reader->Read<bool>());
469 field.set_has_initializer(reader->Read<bool>()); 507 field.set_has_initializer(reader->Read<bool>());
470 508
471 // Set all the object fields. 509 // Set all the object fields.
472 // TODO(5411462): Need to assert No GC can happen here, even though 510 // TODO(5411462): Need to assert No GC can happen here, even though
473 // allocations may happen. 511 // allocations may happen.
474 intptr_t num_flds = (field.raw()->to() - field.raw()->from()); 512 intptr_t num_flds = (field.raw()->to() - field.raw()->from());
475 for (intptr_t i = 0; i <= num_flds; i++) { 513 for (intptr_t i = 0; i <= num_flds; i++) {
476 *(field.raw()->from() + i) = reader->ReadObject(); 514 *(field.raw()->from() + i) = reader->ReadObject();
477 } 515 }
478 516
479 return field.raw(); 517 return field.raw();
480 } 518 }
481 519
482 520
483 void RawField::WriteTo(SnapshotWriter* writer, 521 void RawField::WriteTo(SnapshotWriter* writer,
484 intptr_t object_id, 522 intptr_t object_id,
485 Snapshot::Kind kind) { 523 Snapshot::Kind kind) {
486 ASSERT(writer != NULL); 524 ASSERT(writer != NULL);
487 SnapshotWriterVisitor visitor(writer); 525 SnapshotWriterVisitor visitor(writer);
488 526
489 // Write out the serialization header value for this object. 527 // Write out the serialization header value for this object.
490 writer->WriteObjectHeader(kInlined, object_id); 528 writer->WriteSerializationMarker(kInlined, object_id);
491 529
492 // Write out the class information. 530 // Write out the class and tags information.
493 writer->WriteObjectHeader(kObjectId, Object::kFieldClass); 531 writer->WriteObjectHeader(Object::kFieldClass, ptr()->tags_);
494 532
495 writer->Write<intptr_t>(ptr()->token_index_); 533 writer->Write<intptr_t>(ptr()->token_index_);
496 writer->Write<bool>(ptr()->is_static_); 534 writer->Write<bool>(ptr()->is_static_);
497 writer->Write<bool>(ptr()->is_final_); 535 writer->Write<bool>(ptr()->is_final_);
498 writer->Write<bool>(ptr()->has_initializer_); 536 writer->Write<bool>(ptr()->has_initializer_);
499 537
500 // Write out all the object pointer fields. 538 // Write out all the object pointer fields.
501 visitor.VisitPointers(from(), to()); 539 visitor.VisitPointers(from(), to());
502 } 540 }
503 541
504 542
505 RawTokenStream* TokenStream::ReadFrom(SnapshotReader* reader, 543 RawTokenStream* TokenStream::ReadFrom(SnapshotReader* reader,
506 intptr_t object_id, 544 intptr_t object_id,
545 intptr_t tags,
507 Snapshot::Kind kind) { 546 Snapshot::Kind kind) {
508 ASSERT(reader != NULL); 547 ASSERT(reader != NULL);
509 548
510 // Read the length so that we can determine number of tokens to read. 549 // Read the length so that we can determine number of tokens to read.
511 RawSmi* smi_len = GetSmi(reader->Read<intptr_t>()); 550 RawSmi* smi_len = GetSmi(reader->Read<intptr_t>());
512 intptr_t len = Smi::Value(smi_len); 551 intptr_t len = Smi::Value(smi_len);
513 552
514 // Create the token stream object. 553 // Create the token stream object.
515 TokenStream& token_stream = TokenStream::ZoneHandle(TokenStream::New(len)); 554 TokenStream& token_stream = TokenStream::ZoneHandle(TokenStream::New(len));
516 reader->AddBackwardReference(object_id, &token_stream); 555 reader->AddBackwardReference(object_id, &token_stream);
517 556
557 // Set the object tags.
558 token_stream.set_tags(tags);
559
518 // Read the token stream into the TokenStream. 560 // Read the token stream into the TokenStream.
519 String& literal = String::Handle(); 561 String& literal = String::Handle();
520 for (intptr_t i = 0; i < len; i++) { 562 for (intptr_t i = 0; i < len; i++) {
521 Token::Kind kind = static_cast<Token::Kind>( 563 Token::Kind kind = static_cast<Token::Kind>(
522 Smi::Value(GetSmi(reader->Read<intptr_t>()))); 564 Smi::Value(GetSmi(reader->Read<intptr_t>())));
523 literal ^= reader->ReadObject(); 565 literal ^= reader->ReadObject();
524 token_stream.SetTokenAt(i, kind, literal); 566 token_stream.SetTokenAt(i, kind, literal);
525 } 567 }
526 return token_stream.raw(); 568 return token_stream.raw();
527 } 569 }
528 570
529 571
530 void RawTokenStream::WriteTo(SnapshotWriter* writer, 572 void RawTokenStream::WriteTo(SnapshotWriter* writer,
531 intptr_t object_id, 573 intptr_t object_id,
532 Snapshot::Kind kind) { 574 Snapshot::Kind kind) {
533 ASSERT(writer != NULL); 575 ASSERT(writer != NULL);
534 576
535 // Write out the serialization header value for this object. 577 // Write out the serialization header value for this object.
536 writer->WriteObjectHeader(kInlined, object_id); 578 writer->WriteSerializationMarker(kInlined, object_id);
537 579
538 // Write out the class information. 580 // Write out the class and tags information.
539 writer->WriteObjectHeader(kObjectId, Object::kTokenStreamClass); 581 writer->WriteObjectHeader(Object::kTokenStreamClass, ptr()->tags_);
540 582
541 // Write out the length field. 583 // Write out the length field.
542 writer->Write<RawObject*>(ptr()->length_); 584 writer->Write<RawObject*>(ptr()->length_);
543 585
544 // Write out the token stream (token kind and literal). 586 // Write out the token stream (token kind and literal).
545 intptr_t len = Smi::Value(ptr()->length_); 587 intptr_t len = Smi::Value(ptr()->length_);
546 for (intptr_t i = 0; i < TokenStream::StreamLength(len); i++) { 588 for (intptr_t i = 0; i < TokenStream::StreamLength(len); i++) {
547 writer->WriteObject(ptr()->data_[i]); 589 writer->WriteObject(ptr()->data_[i]);
548 } 590 }
549 } 591 }
550 592
551 593
552 RawScript* Script::ReadFrom(SnapshotReader* reader, 594 RawScript* Script::ReadFrom(SnapshotReader* reader,
553 intptr_t object_id, 595 intptr_t object_id,
596 intptr_t tags,
554 Snapshot::Kind kind) { 597 Snapshot::Kind kind) {
555 ASSERT(reader != NULL); 598 ASSERT(reader != NULL);
556 599
557 // Allocate script object. 600 // Allocate script object.
558 Script& script = Script::ZoneHandle(Script::New()); 601 Script& script = Script::ZoneHandle(Script::New());
559 reader->AddBackwardReference(object_id, &script); 602 reader->AddBackwardReference(object_id, &script);
560 603
604 // Set the object tags.
605 script.set_tags(tags);
606
561 // Set all the object fields. 607 // Set all the object fields.
562 // TODO(5411462): Need to assert No GC can happen here, even though 608 // TODO(5411462): Need to assert No GC can happen here, even though
563 // allocations may happen. 609 // allocations may happen.
564 intptr_t num_flds = (script.raw()->to() - script.raw()->from()); 610 intptr_t num_flds = (script.raw()->to() - script.raw()->from());
565 for (intptr_t i = 0; i <= num_flds; i++) { 611 for (intptr_t i = 0; i <= num_flds; i++) {
566 *(script.raw()->from() + i) = reader->ReadObject(); 612 *(script.raw()->from() + i) = reader->ReadObject();
567 } 613 }
568 614
569 return script.raw(); 615 return script.raw();
570 } 616 }
571 617
572 618
573 void RawScript::WriteTo(SnapshotWriter* writer, 619 void RawScript::WriteTo(SnapshotWriter* writer,
574 intptr_t object_id, 620 intptr_t object_id,
575 Snapshot::Kind kind) { 621 Snapshot::Kind kind) {
576 ASSERT(writer != NULL); 622 ASSERT(writer != NULL);
577 ASSERT(tokens_ != TokenStream::null()); 623 ASSERT(tokens_ != TokenStream::null());
578 SnapshotWriterVisitor visitor(writer); 624 SnapshotWriterVisitor visitor(writer);
579 625
580 // Write out the serialization header value for this object. 626 // Write out the serialization header value for this object.
581 writer->WriteObjectHeader(kInlined, object_id); 627 writer->WriteSerializationMarker(kInlined, object_id);
582 628
583 // Write out the class information. 629 // Write out the class and tags information.
584 writer->WriteObjectHeader(kObjectId, Object::kScriptClass); 630 writer->WriteObjectHeader(Object::kScriptClass, ptr()->tags_);
585 631
586 // Write out all the object pointer fields. 632 // Write out all the object pointer fields.
587 visitor.VisitPointers(from(), to()); 633 visitor.VisitPointers(from(), to());
588 } 634 }
589 635
590 636
591 RawLibrary* Library::ReadFrom(SnapshotReader* reader, 637 RawLibrary* Library::ReadFrom(SnapshotReader* reader,
592 intptr_t object_id, 638 intptr_t object_id,
639 intptr_t tags,
593 Snapshot::Kind kind) { 640 Snapshot::Kind kind) {
594 ASSERT(reader != NULL); 641 ASSERT(reader != NULL);
595 642
596 // Allocate library object. 643 // Allocate library object.
597 Library& library = Library::ZoneHandle(Library::New()); 644 Library& library = Library::ZoneHandle(Library::New());
598 reader->AddBackwardReference(object_id, &library); 645 reader->AddBackwardReference(object_id, &library);
599 646
647 // Set the object tags.
648 library.set_tags(tags);
649
600 // Set all non object fields. 650 // Set all non object fields.
601 library.raw_ptr()->num_imports_ = reader->Read<intptr_t>(); 651 library.raw_ptr()->num_imports_ = reader->Read<intptr_t>();
602 library.raw_ptr()->num_imported_into_ = reader->Read<intptr_t>(); 652 library.raw_ptr()->num_imported_into_ = reader->Read<intptr_t>();
603 library.raw_ptr()->num_anonymous_ = reader->Read<intptr_t>(); 653 library.raw_ptr()->num_anonymous_ = reader->Read<intptr_t>();
604 library.raw_ptr()->corelib_imported_ = reader->Read<bool>(); 654 library.raw_ptr()->corelib_imported_ = reader->Read<bool>();
605 library.raw_ptr()->load_state_ = reader->Read<int8_t>(); 655 library.raw_ptr()->load_state_ = reader->Read<int8_t>();
606 // The native resolver is not serialized. 656 // The native resolver is not serialized.
607 Dart_NativeEntryResolver resolver = reader->Read<Dart_NativeEntryResolver>(); 657 Dart_NativeEntryResolver resolver = reader->Read<Dart_NativeEntryResolver>();
608 ASSERT(resolver == NULL); 658 ASSERT(resolver == NULL);
609 library.set_native_entry_resolver(resolver); 659 library.set_native_entry_resolver(resolver);
(...skipping 10 matching lines...) Expand all
620 } 670 }
621 671
622 672
623 void RawLibrary::WriteTo(SnapshotWriter* writer, 673 void RawLibrary::WriteTo(SnapshotWriter* writer,
624 intptr_t object_id, 674 intptr_t object_id,
625 Snapshot::Kind kind) { 675 Snapshot::Kind kind) {
626 ASSERT(writer != NULL); 676 ASSERT(writer != NULL);
627 SnapshotWriterVisitor visitor(writer); 677 SnapshotWriterVisitor visitor(writer);
628 678
629 // Write out the serialization header value for this object. 679 // Write out the serialization header value for this object.
630 writer->WriteObjectHeader(kInlined, object_id); 680 writer->WriteSerializationMarker(kInlined, object_id);
631 681
632 // Write out the class information. 682 // Write out the class and tags information.
633 writer->WriteObjectHeader(kObjectId, Object::kLibraryClass); 683 writer->WriteObjectHeader(Object::kLibraryClass, ptr()->tags_);
634 684
635 writer->Write<intptr_t>(ptr()->num_imports_); 685 writer->Write<intptr_t>(ptr()->num_imports_);
636 writer->Write<intptr_t>(ptr()->num_imported_into_); 686 writer->Write<intptr_t>(ptr()->num_imported_into_);
637 writer->Write<intptr_t>(ptr()->num_anonymous_); 687 writer->Write<intptr_t>(ptr()->num_anonymous_);
638 writer->Write<bool>(ptr()->corelib_imported_); 688 writer->Write<bool>(ptr()->corelib_imported_);
639 writer->Write<int8_t>(ptr()->load_state_); 689 writer->Write<int8_t>(ptr()->load_state_);
640 // We do not serialize the native resolver over, this needs to be explicitly 690 // We do not serialize the native resolver over, this needs to be explicitly
641 // set after deserialization. 691 // set after deserialization.
642 writer->Write<Dart_NativeEntryResolver>(NULL); 692 writer->Write<Dart_NativeEntryResolver>(NULL);
643 693
644 // Write out all the object pointer fields. 694 // Write out all the object pointer fields.
645 visitor.VisitPointers(from(), to()); 695 visitor.VisitPointers(from(), to());
646 } 696 }
647 697
648 698
649 RawLibraryPrefix* LibraryPrefix::ReadFrom(SnapshotReader* reader, 699 RawLibraryPrefix* LibraryPrefix::ReadFrom(SnapshotReader* reader,
650 intptr_t object_id, 700 intptr_t object_id,
701 intptr_t tags,
651 Snapshot::Kind kind) { 702 Snapshot::Kind kind) {
652 ASSERT(reader != NULL); 703 ASSERT(reader != NULL);
653 704
654 // Allocate library prefix object. 705 // Allocate library prefix object.
655 LibraryPrefix& prefix = LibraryPrefix::ZoneHandle(LibraryPrefix::New()); 706 LibraryPrefix& prefix = LibraryPrefix::ZoneHandle(LibraryPrefix::New());
656 reader->AddBackwardReference(object_id, &prefix); 707 reader->AddBackwardReference(object_id, &prefix);
657 708
709 // Set the object tags.
710 prefix.set_tags(tags);
711
658 // Set all the object fields. 712 // Set all the object fields.
659 // TODO(5411462): Need to assert No GC can happen here, even though 713 // TODO(5411462): Need to assert No GC can happen here, even though
660 // allocations may happen. 714 // allocations may happen.
661 intptr_t num_flds = (prefix.raw()->to() - prefix.raw()->from()); 715 intptr_t num_flds = (prefix.raw()->to() - prefix.raw()->from());
662 for (intptr_t i = 0; i <= num_flds; i++) { 716 for (intptr_t i = 0; i <= num_flds; i++) {
663 *(prefix.raw()->from() + i) = reader->ReadObject(); 717 *(prefix.raw()->from() + i) = reader->ReadObject();
664 } 718 }
665 719
666 return prefix.raw(); 720 return prefix.raw();
667 } 721 }
668 722
669 723
670 void RawLibraryPrefix::WriteTo(SnapshotWriter* writer, 724 void RawLibraryPrefix::WriteTo(SnapshotWriter* writer,
671 intptr_t object_id, 725 intptr_t object_id,
672 Snapshot::Kind kind) { 726 Snapshot::Kind kind) {
673 ASSERT(writer != NULL); 727 ASSERT(writer != NULL);
674 SnapshotWriterVisitor visitor(writer); 728 SnapshotWriterVisitor visitor(writer);
675 729
676 // Write out the serialization header value for this object. 730 // Write out the serialization header value for this object.
677 writer->WriteObjectHeader(kInlined, object_id); 731 writer->WriteSerializationMarker(kInlined, object_id);
678 732
679 // Write out the class information. 733 // Write out the class and tags information.
680 writer->WriteObjectHeader(kObjectId, Object::kLibraryPrefixClass); 734 writer->WriteObjectHeader(Object::kLibraryPrefixClass, ptr()->tags_);
681 735
682 // Write out all the object pointer fields. 736 // Write out all the object pointer fields.
683 visitor.VisitPointers(from(), to()); 737 visitor.VisitPointers(from(), to());
684 } 738 }
685 739
686 740
687 RawCode* Code::ReadFrom(SnapshotReader* reader, 741 RawCode* Code::ReadFrom(SnapshotReader* reader,
688 intptr_t object_id, 742 intptr_t object_id,
743 intptr_t tags,
689 Snapshot::Kind kind) { 744 Snapshot::Kind kind) {
690 ASSERT(reader != NULL); 745 ASSERT(reader != NULL);
691 746
692 // Create Code object. 747 // Create Code object.
693 Code& code = Code::ZoneHandle(Code::New(0)); 748 Code& code = Code::ZoneHandle(Code::New(0));
694 reader->AddBackwardReference(object_id, &code); 749 reader->AddBackwardReference(object_id, &code);
695 return code.raw(); 750 return code.raw();
696 } 751 }
697 752
698 753
699 void RawCode::WriteTo(SnapshotWriter* writer, 754 void RawCode::WriteTo(SnapshotWriter* writer,
700 intptr_t object_id, 755 intptr_t object_id,
701 Snapshot::Kind kind) { 756 Snapshot::Kind kind) {
702 // Currently we do not serialize any code and hence we write 757 // Currently we do not serialize any code and hence we write
703 // out a null object for it. 758 // out a null object for it.
704 ASSERT(writer != NULL); 759 ASSERT(writer != NULL);
705 760
706 writer->WriteObjectHeader(kObjectId, Object::kNullObject); 761 writer->WriteIndexedObject(Object::kNullObject);
707 } 762 }
708 763
709 764
710 RawInstructions* Instructions::ReadFrom(SnapshotReader* reader, 765 RawInstructions* Instructions::ReadFrom(SnapshotReader* reader,
711 intptr_t object_id, 766 intptr_t object_id,
767 intptr_t tags,
712 Snapshot::Kind kind) { 768 Snapshot::Kind kind) {
713 UNREACHABLE(); 769 UNREACHABLE();
714 return Instructions::null(); 770 return Instructions::null();
715 } 771 }
716 772
717 773
718 void RawInstructions::WriteTo(SnapshotWriter* writer, 774 void RawInstructions::WriteTo(SnapshotWriter* writer,
719 intptr_t object_id, 775 intptr_t object_id,
720 Snapshot::Kind kind) { 776 Snapshot::Kind kind) {
721 UNREACHABLE(); 777 UNREACHABLE();
722 } 778 }
723 779
724 780
725 RawPcDescriptors* PcDescriptors::ReadFrom(SnapshotReader* reader, 781 RawPcDescriptors* PcDescriptors::ReadFrom(SnapshotReader* reader,
726 intptr_t object_id, 782 intptr_t object_id,
783 intptr_t tags,
727 Snapshot::Kind kind) { 784 Snapshot::Kind kind) {
728 UNREACHABLE(); 785 UNREACHABLE();
729 return PcDescriptors::null(); 786 return PcDescriptors::null();
730 } 787 }
731 788
732 789
733 void RawPcDescriptors::WriteTo(SnapshotWriter* writer, 790 void RawPcDescriptors::WriteTo(SnapshotWriter* writer,
734 intptr_t object_id, 791 intptr_t object_id,
735 Snapshot::Kind kind) { 792 Snapshot::Kind kind) {
736 UNREACHABLE(); 793 UNREACHABLE();
737 } 794 }
738 795
739 796
740 RawExceptionHandlers* ExceptionHandlers::ReadFrom(SnapshotReader* reader, 797 RawExceptionHandlers* ExceptionHandlers::ReadFrom(SnapshotReader* reader,
741 intptr_t object_id, 798 intptr_t object_id,
799 intptr_t tags,
742 Snapshot::Kind kind) { 800 Snapshot::Kind kind) {
743 UNREACHABLE(); 801 UNREACHABLE();
744 return ExceptionHandlers::null(); 802 return ExceptionHandlers::null();
745 } 803 }
746 804
747 805
748 void RawExceptionHandlers::WriteTo(SnapshotWriter* writer, 806 void RawExceptionHandlers::WriteTo(SnapshotWriter* writer,
749 intptr_t object_id, 807 intptr_t object_id,
750 Snapshot::Kind kind) { 808 Snapshot::Kind kind) {
751 UNREACHABLE(); 809 UNREACHABLE();
752 } 810 }
753 811
754 812
755 RawContext* Context::ReadFrom(SnapshotReader* reader, 813 RawContext* Context::ReadFrom(SnapshotReader* reader,
756 intptr_t object_id, 814 intptr_t object_id,
815 intptr_t tags,
757 Snapshot::Kind kind) { 816 Snapshot::Kind kind) {
758 ASSERT(reader != NULL); 817 ASSERT(reader != NULL);
759 818
760 // Allocate context object. 819 // Allocate context object.
761 intptr_t num_vars = reader->Read<intptr_t>(); 820 intptr_t num_vars = reader->Read<intptr_t>();
762 Context& context = Context::ZoneHandle( 821 Context& context = Context::ZoneHandle(
763 Context::New(num_vars, 822 Context::New(num_vars,
764 (kind == Snapshot::kFull) ? Heap::kOld : Heap::kNew)); 823 (kind == Snapshot::kFull) ? Heap::kOld : Heap::kNew));
765 reader->AddBackwardReference(object_id, &context); 824 reader->AddBackwardReference(object_id, &context);
766 825
826 // Set the object tags.
827 context.set_tags(tags);
828
767 // Set the isolate implicitly. 829 // Set the isolate implicitly.
768 context.set_isolate(Isolate::Current()); 830 context.set_isolate(Isolate::Current());
769 831
770 // Set all the object fields. 832 // Set all the object fields.
771 // TODO(5411462): Need to assert No GC can happen here, even though 833 // TODO(5411462): Need to assert No GC can happen here, even though
772 // allocations may happen. 834 // allocations may happen.
773 intptr_t num_flds = (context.raw()->to(num_vars) - context.raw()->from()); 835 intptr_t num_flds = (context.raw()->to(num_vars) - context.raw()->from());
774 for (intptr_t i = 0; i <= num_flds; i++) { 836 for (intptr_t i = 0; i <= num_flds; i++) {
775 *(context.raw()->from() + i) = reader->ReadObject(); 837 *(context.raw()->from() + i) = reader->ReadObject();
776 } 838 }
777 839
778 return context.raw(); 840 return context.raw();
779 } 841 }
780 842
781 843
782 void RawContext::WriteTo(SnapshotWriter* writer, 844 void RawContext::WriteTo(SnapshotWriter* writer,
783 intptr_t object_id, 845 intptr_t object_id,
784 Snapshot::Kind kind) { 846 Snapshot::Kind kind) {
785 ASSERT(writer != NULL); 847 ASSERT(writer != NULL);
786 SnapshotWriterVisitor visitor(writer); 848 SnapshotWriterVisitor visitor(writer);
787 849
788 // Write out the serialization header value for this object. 850 // Write out the serialization header value for this object.
789 writer->WriteObjectHeader(kInlined, object_id); 851 writer->WriteSerializationMarker(kInlined, object_id);
790 852
791 // Write out the class information. 853 // Write out the class and tags information.
792 writer->WriteObjectHeader(kObjectId, Object::kContextClass); 854 writer->WriteObjectHeader(Object::kContextClass, ptr()->tags_);
793 855
794 // Write out num of variables in the context. 856 // Write out num of variables in the context.
795 writer->Write<intptr_t>(ptr()->num_variables_); 857 writer->Write<intptr_t>(ptr()->num_variables_);
796 858
797 // Can't serialize the isolate pointer, we set it implicitly on read. 859 // Can't serialize the isolate pointer, we set it implicitly on read.
798 860
799 // Write out all the object pointer fields. 861 // Write out all the object pointer fields.
800 visitor.VisitPointers(from(), to(ptr()->num_variables_)); 862 visitor.VisitPointers(from(), to(ptr()->num_variables_));
801 } 863 }
802 864
803 865
804 RawContextScope* ContextScope::ReadFrom(SnapshotReader* reader, 866 RawContextScope* ContextScope::ReadFrom(SnapshotReader* reader,
805 intptr_t object_id, 867 intptr_t object_id,
868 intptr_t tags,
806 Snapshot::Kind kind) { 869 Snapshot::Kind kind) {
807 ASSERT(reader != NULL); 870 ASSERT(reader != NULL);
808 ASSERT(kind == Snapshot::kMessage); 871 ASSERT(kind == Snapshot::kMessage);
809 872
810 // Allocate context scope object. 873 // Allocate context scope object.
811 intptr_t num_vars = reader->Read<intptr_t>(); 874 intptr_t num_vars = reader->Read<intptr_t>();
812 ContextScope& scope = ContextScope::ZoneHandle(ContextScope::New(num_vars)); 875 ContextScope& scope = ContextScope::ZoneHandle(ContextScope::New(num_vars));
813 reader->AddBackwardReference(object_id, &scope); 876 reader->AddBackwardReference(object_id, &scope);
814 877
878 // Set the object tags.
879 scope.set_tags(tags);
880
815 // Set all the object fields. 881 // Set all the object fields.
816 // TODO(5411462): Need to assert No GC can happen here, even though 882 // TODO(5411462): Need to assert No GC can happen here, even though
817 // allocations may happen. 883 // allocations may happen.
818 intptr_t num_flds = (scope.raw()->to(num_vars) - scope.raw()->from()); 884 intptr_t num_flds = (scope.raw()->to(num_vars) - scope.raw()->from());
819 for (intptr_t i = 0; i <= num_flds; i++) { 885 for (intptr_t i = 0; i <= num_flds; i++) {
820 *(scope.raw()->from() + i) = reader->ReadObject(); 886 *(scope.raw()->from() + i) = reader->ReadObject();
821 } 887 }
822 888
823 return scope.raw(); 889 return scope.raw();
824 } 890 }
825 891
826 892
827 void RawContextScope::WriteTo(SnapshotWriter* writer, 893 void RawContextScope::WriteTo(SnapshotWriter* writer,
828 intptr_t object_id, 894 intptr_t object_id,
829 Snapshot::Kind kind) { 895 Snapshot::Kind kind) {
830 ASSERT(writer != NULL); 896 ASSERT(writer != NULL);
831 ASSERT(kind == Snapshot::kMessage); 897 ASSERT(kind == Snapshot::kMessage);
832 SnapshotWriterVisitor visitor(writer); 898 SnapshotWriterVisitor visitor(writer);
833 899
834 // Write out the serialization header value for this object. 900 // Write out the serialization header value for this object.
835 writer->WriteObjectHeader(kInlined, object_id); 901 writer->WriteSerializationMarker(kInlined, object_id);
836 902
837 // Write out the class information. 903 // Write out the class and tags information.
838 writer->WriteObjectHeader(kObjectId, Object::kContextScopeClass); 904 writer->WriteObjectHeader(Object::kContextScopeClass, ptr()->tags_);
839 905
840 // Serialize number of variables. 906 // Serialize number of variables.
841 writer->Write<intptr_t>(ptr()->num_variables_); 907 writer->Write<intptr_t>(ptr()->num_variables_);
842 908
843 // Write out all the object pointer fields. 909 // Write out all the object pointer fields.
844 visitor.VisitPointers(from(), to(ptr()->num_variables_)); 910 visitor.VisitPointers(from(), to(ptr()->num_variables_));
845 } 911 }
846 912
847 913
848 RawUnhandledException* UnhandledException::ReadFrom(SnapshotReader* reader, 914 RawUnhandledException* UnhandledException::ReadFrom(SnapshotReader* reader,
849 intptr_t object_id, 915 intptr_t object_id,
916 intptr_t tags,
850 Snapshot::Kind kind) { 917 Snapshot::Kind kind) {
851 UNIMPLEMENTED(); 918 UNIMPLEMENTED();
852 return UnhandledException::null(); 919 return UnhandledException::null();
853 } 920 }
854 921
855 922
856 void RawUnhandledException::WriteTo(SnapshotWriter* writer, 923 void RawUnhandledException::WriteTo(SnapshotWriter* writer,
857 intptr_t object_id, 924 intptr_t object_id,
858 Snapshot::Kind kind) { 925 Snapshot::Kind kind) {
859 UNIMPLEMENTED(); 926 UNIMPLEMENTED();
860 } 927 }
861 928
862 929
863 RawApiError* ApiError::ReadFrom(SnapshotReader* reader, 930 RawApiError* ApiError::ReadFrom(SnapshotReader* reader,
864 intptr_t object_id, 931 intptr_t object_id,
865 Snapshot::Kind kind) { 932 intptr_t tags,
933 Snapshot::Kind kind) {
866 UNIMPLEMENTED(); 934 UNIMPLEMENTED();
867 return ApiError::null(); 935 return ApiError::null();
868 } 936 }
869 937
870 938
871 void RawApiError::WriteTo(SnapshotWriter* writer, 939 void RawApiError::WriteTo(SnapshotWriter* writer,
872 intptr_t object_id, 940 intptr_t object_id,
873 Snapshot::Kind kind) { 941 Snapshot::Kind kind) {
874 UNIMPLEMENTED(); 942 UNIMPLEMENTED();
875 } 943 }
876 944
877 945
878 RawInstance* Instance::ReadFrom(SnapshotReader* reader, 946 RawInstance* Instance::ReadFrom(SnapshotReader* reader,
879 intptr_t object_id, 947 intptr_t object_id,
948 intptr_t tags,
880 Snapshot::Kind kind) { 949 Snapshot::Kind kind) {
881 UNREACHABLE(); 950 UNREACHABLE();
882 return Instance::null(); 951 return Instance::null();
883 } 952 }
884 953
885 954
886 void RawInstance::WriteTo(SnapshotWriter* writer, 955 void RawInstance::WriteTo(SnapshotWriter* writer,
887 intptr_t object_id, 956 intptr_t object_id,
888 Snapshot::Kind kind) { 957 Snapshot::Kind kind) {
889 UNREACHABLE(); 958 UNREACHABLE();
890 } 959 }
891 960
892 961
893 RawMint* Mint::ReadFrom(SnapshotReader* reader, 962 RawMint* Mint::ReadFrom(SnapshotReader* reader,
894 intptr_t object_id, 963 intptr_t object_id,
964 intptr_t tags,
895 Snapshot::Kind kind) { 965 Snapshot::Kind kind) {
896 ASSERT(reader != NULL); 966 ASSERT(reader != NULL);
897 967
898 // Read the 64 bit value for the object. 968 // Read the 64 bit value for the object.
899 int64_t value = reader->Read<int64_t>(); 969 int64_t value = reader->Read<int64_t>();
900 970
901 // Create a Mint object. 971 // Create a Mint object.
902 Mint& mint = Mint::ZoneHandle( 972 Mint& mint = Mint::ZoneHandle(
903 Mint::New(value, (kind == Snapshot::kFull) ? Heap::kOld : Heap::kNew)); 973 Mint::New(value, (kind == Snapshot::kFull) ? Heap::kOld : Heap::kNew));
904 reader->AddBackwardReference(object_id, &mint); 974 reader->AddBackwardReference(object_id, &mint);
975
976 // Set the object tags.
977 mint.set_tags(tags);
978
905 return mint.raw(); 979 return mint.raw();
906 } 980 }
907 981
908 982
909 void RawMint::WriteTo(SnapshotWriter* writer, 983 void RawMint::WriteTo(SnapshotWriter* writer,
910 intptr_t object_id, 984 intptr_t object_id,
911 Snapshot::Kind kind) { 985 Snapshot::Kind kind) {
912 ASSERT(writer != NULL); 986 ASSERT(writer != NULL);
913 987
914 // Write out the serialization header value for this object. 988 // Write out the serialization header value for this object.
915 writer->WriteObjectHeader(kInlined, object_id); 989 writer->WriteSerializationMarker(kInlined, object_id);
916 990
917 // Write out the class information. 991 // Write out the class and tags information.
918 writer->WriteObjectHeader(kObjectId, ObjectStore::kMintClass); 992 writer->WriteObjectHeader(ObjectStore::kMintClass, ptr()->tags_);
919 993
920 // Write out the 64 bit value. 994 // Write out the 64 bit value.
921 writer->Write<int64_t>(ptr()->value_); 995 writer->Write<int64_t>(ptr()->value_);
922 } 996 }
923 997
924 998
925 RawBigint* Bigint::ReadFrom(SnapshotReader* reader, 999 RawBigint* Bigint::ReadFrom(SnapshotReader* reader,
926 intptr_t object_id, 1000 intptr_t object_id,
1001 intptr_t tags,
927 Snapshot::Kind kind) { 1002 Snapshot::Kind kind) {
928 ASSERT(reader != NULL); 1003 ASSERT(reader != NULL);
929 // Read in the HexCString representation of the bigint. 1004 // Read in the HexCString representation of the bigint.
930 intptr_t len = reader->Read<intptr_t>(); 1005 intptr_t len = reader->Read<intptr_t>();
931 char* str = reinterpret_cast<char*>(ZoneAllocator(len + 1)); 1006 char* str = reinterpret_cast<char*>(ZoneAllocator(len + 1));
932 str[len] = '\0'; 1007 str[len] = '\0';
933 for (intptr_t i = 0; i < len; i++) { 1008 for (intptr_t i = 0; i < len; i++) {
934 str[i] = reader->Read<uint8_t>(); 1009 str[i] = reader->Read<uint8_t>();
935 } 1010 }
936 // Create a Bigint object from HexCString. 1011 // Create a Bigint object from HexCString.
937 Bigint& obj = Bigint::ZoneHandle(BigintOperations::FromHexCString(str)); 1012 Bigint& obj = Bigint::ZoneHandle(BigintOperations::FromHexCString(str));
938 reader->AddBackwardReference(object_id, &obj); 1013 reader->AddBackwardReference(object_id, &obj);
1014
1015 // Set the object tags.
1016 obj.set_tags(tags);
1017
939 return obj.raw(); 1018 return obj.raw();
940 } 1019 }
941 1020
942 1021
943 void RawBigint::WriteTo(SnapshotWriter* writer, 1022 void RawBigint::WriteTo(SnapshotWriter* writer,
944 intptr_t object_id, 1023 intptr_t object_id,
945 Snapshot::Kind kind) { 1024 Snapshot::Kind kind) {
946 ASSERT(writer != NULL); 1025 ASSERT(writer != NULL);
947 1026
948 // Write out the serialization header value for this object. 1027 // Write out the serialization header value for this object.
949 writer->WriteObjectHeader(kInlined, object_id); 1028 writer->WriteSerializationMarker(kInlined, object_id);
950 1029
951 // Write out the class information. 1030 // Write out the class and tags information.
952 writer->WriteObjectHeader(kObjectId, ObjectStore::kBigintClass); 1031 writer->WriteObjectHeader(ObjectStore::kBigintClass, ptr()->tags_);
953 1032
954 // Write out the bigint value as a HEXCstring. 1033 // Write out the bigint value as a HEXCstring.
955 ptr()->bn_.d = ptr()->data_; 1034 ptr()->bn_.d = ptr()->data_;
956 const char* str = BigintOperations::ToHexCString(&ptr()->bn_, &ZoneAllocator); 1035 const char* str = BigintOperations::ToHexCString(&ptr()->bn_, &ZoneAllocator);
957 intptr_t len = strlen(str); 1036 intptr_t len = strlen(str);
958 writer->Write<intptr_t>(len-2); 1037 writer->Write<intptr_t>(len-2);
959 for (intptr_t i = 2; i < len; i++) { 1038 for (intptr_t i = 2; i < len; i++) {
960 writer->Write<uint8_t>(str[i]); 1039 writer->Write<uint8_t>(str[i]);
961 } 1040 }
962 } 1041 }
963 1042
964 1043
965 RawDouble* Double::ReadFrom(SnapshotReader* reader, 1044 RawDouble* Double::ReadFrom(SnapshotReader* reader,
966 intptr_t object_id, 1045 intptr_t object_id,
1046 intptr_t tags,
967 Snapshot::Kind kind) { 1047 Snapshot::Kind kind) {
968 ASSERT(reader != NULL); 1048 ASSERT(reader != NULL);
969 // Read the double value for the object. 1049 // Read the double value for the object.
970 double value = reader->Read<double>(); 1050 double value = reader->Read<double>();
971 // Create a double object. 1051 // Create a double object.
972 Double& dbl = Double::ZoneHandle( 1052 Double& dbl = Double::ZoneHandle(
973 Double::New(value, (kind == Snapshot::kFull) ? Heap::kOld : Heap::kNew)); 1053 Double::New(value, (kind == Snapshot::kFull) ? Heap::kOld : Heap::kNew));
974 reader->AddBackwardReference(object_id, &dbl); 1054 reader->AddBackwardReference(object_id, &dbl);
1055
1056 // Set the object tags.
1057 dbl.set_tags(tags);
1058
975 return dbl.raw(); 1059 return dbl.raw();
976 } 1060 }
977 1061
978 1062
979 void RawDouble::WriteTo(SnapshotWriter* writer, 1063 void RawDouble::WriteTo(SnapshotWriter* writer,
980 intptr_t object_id, 1064 intptr_t object_id,
981 Snapshot::Kind kind) { 1065 Snapshot::Kind kind) {
982 ASSERT(writer != NULL); 1066 ASSERT(writer != NULL);
983 1067
984 // Write out the serialization header value for this object. 1068 // Write out the serialization header value for this object.
985 writer->WriteObjectHeader(kInlined, object_id); 1069 writer->WriteSerializationMarker(kInlined, object_id);
986 1070
987 // Write out the class information. 1071 // Write out the class and tags information.
988 writer->WriteObjectHeader(kObjectId, ObjectStore::kDoubleClass); 1072 writer->WriteObjectHeader(ObjectStore::kDoubleClass, ptr()->tags_);
989 1073
990 // Write out the double value. 1074 // Write out the double value.
991 writer->Write<double>(ptr()->value_); 1075 writer->Write<double>(ptr()->value_);
992 } 1076 }
993 1077
994 1078
995 RawString* String::ReadFrom(SnapshotReader* reader, 1079 RawString* String::ReadFrom(SnapshotReader* reader,
996 intptr_t object_id, 1080 intptr_t object_id,
1081 intptr_t tags,
997 Snapshot::Kind kind) { 1082 Snapshot::Kind kind) {
998 UNREACHABLE(); // String is an abstract class. 1083 UNREACHABLE(); // String is an abstract class.
999 return String::null(); 1084 return String::null();
1000 } 1085 }
1001 1086
1002 1087
1003 void RawString::WriteTo(SnapshotWriter* writer, 1088 void RawString::WriteTo(SnapshotWriter* writer,
1004 intptr_t object_id, 1089 intptr_t object_id,
1005 Snapshot::Kind kind) { 1090 Snapshot::Kind kind) {
1006 UNREACHABLE(); // String is an abstract class. 1091 UNREACHABLE(); // String is an abstract class.
1007 } 1092 }
1008 1093
1009 1094
1010 template<typename HandleType, typename CharacterType> 1095 template<typename HandleType, typename CharacterType>
1011 RawString* String::ReadFromImpl(SnapshotReader* reader, 1096 RawString* String::ReadFromImpl(SnapshotReader* reader,
1012 intptr_t object_id, 1097 intptr_t object_id,
1098 intptr_t tags,
1013 Snapshot::Kind kind) { 1099 Snapshot::Kind kind) {
1014 ASSERT(reader != NULL); 1100 ASSERT(reader != NULL);
1015 // Read the length so that we can determine instance size to allocate. 1101 // Read the length so that we can determine instance size to allocate.
1016 RawSmi* smi_len = GetSmi(reader->Read<intptr_t>()); 1102 RawSmi* smi_len = GetSmi(reader->Read<intptr_t>());
1017 intptr_t len = Smi::Value(smi_len); 1103 intptr_t len = Smi::Value(smi_len);
1018 RawSmi* smi_hash = GetSmi(reader->Read<intptr_t>()); 1104 RawSmi* smi_hash = GetSmi(reader->Read<intptr_t>());
1019 1105
1020 // Set up the string object. 1106 // Set up the string object.
1021 HandleType& str_obj = HandleType::ZoneHandle(HandleType::New( 1107 HandleType& str_obj = HandleType::ZoneHandle(HandleType::New(
1022 len, (kind == Snapshot::kFull) ? Heap::kOld : Heap::kNew)); 1108 len, (kind == Snapshot::kFull) ? Heap::kOld : Heap::kNew));
1023 for (intptr_t i = 0; i < len; i++) { 1109 for (intptr_t i = 0; i < len; i++) {
1024 *str_obj.CharAddr(i) = reader->Read<CharacterType>(); 1110 *str_obj.CharAddr(i) = reader->Read<CharacterType>();
1025 } 1111 }
1026 reader->AddBackwardReference(object_id, &str_obj); 1112 reader->AddBackwardReference(object_id, &str_obj);
1113
1114 // Set the object tags.
1115 str_obj.set_tags(tags);
1116
1117 // Set up the hash value.
1027 str_obj.SetHash(Smi::Value(smi_hash)); 1118 str_obj.SetHash(Smi::Value(smi_hash));
1119
1028 return str_obj.raw(); 1120 return str_obj.raw();
1029 } 1121 }
1030 1122
1031 1123
1032 RawOneByteString* OneByteString::ReadFrom(SnapshotReader* reader, 1124 RawOneByteString* OneByteString::ReadFrom(SnapshotReader* reader,
1033 intptr_t object_id, 1125 intptr_t object_id,
1126 intptr_t tags,
1034 Snapshot::Kind kind) { 1127 Snapshot::Kind kind) {
1035 return static_cast<RawOneByteString*>( 1128 return static_cast<RawOneByteString*>(
1036 ReadFromImpl<OneByteString, uint8_t>(reader, object_id, kind)); 1129 ReadFromImpl<OneByteString, uint8_t>(reader, object_id, tags, kind));
1037 } 1130 }
1038 1131
1039 1132
1040 RawTwoByteString* TwoByteString::ReadFrom(SnapshotReader* reader, 1133 RawTwoByteString* TwoByteString::ReadFrom(SnapshotReader* reader,
1041 intptr_t object_id, 1134 intptr_t object_id,
1135 intptr_t tags,
1042 Snapshot::Kind kind) { 1136 Snapshot::Kind kind) {
1043 return static_cast<RawTwoByteString*>( 1137 return static_cast<RawTwoByteString*>(
1044 ReadFromImpl<TwoByteString, uint16_t>(reader, object_id, kind)); 1138 ReadFromImpl<TwoByteString, uint16_t>(reader, object_id, tags, kind));
1045 } 1139 }
1046 1140
1047 1141
1048 RawFourByteString* FourByteString::ReadFrom(SnapshotReader* reader, 1142 RawFourByteString* FourByteString::ReadFrom(SnapshotReader* reader,
1049 intptr_t object_id, 1143 intptr_t object_id,
1144 intptr_t tags,
1050 Snapshot::Kind kind) { 1145 Snapshot::Kind kind) {
1051 return static_cast<RawFourByteString*>( 1146 return static_cast<RawFourByteString*>(
1052 ReadFromImpl<FourByteString, uint32_t>(reader, object_id, kind)); 1147 ReadFromImpl<FourByteString, uint32_t>(reader, object_id, tags, kind));
1053 } 1148 }
1054 1149
1055 1150
1056 template<typename T> 1151 template<typename T>
1057 static void StringWriteTo(SnapshotWriter* writer, 1152 static void StringWriteTo(SnapshotWriter* writer,
1058 intptr_t object_id, 1153 intptr_t object_id,
1154 Snapshot::Kind kind,
1059 intptr_t class_id, 1155 intptr_t class_id,
1060 Snapshot::Kind kind, 1156 intptr_t tags,
1061 RawSmi* length, 1157 RawSmi* length,
1062 RawSmi* hash, 1158 RawSmi* hash,
1063 T* data) { 1159 T* data) {
1064 ASSERT(writer != NULL); 1160 ASSERT(writer != NULL);
1065 intptr_t len = Smi::Value(length); 1161 intptr_t len = Smi::Value(length);
1066 1162
1067 // Write out the serialization header value for this object. 1163 // Write out the serialization header value for this object.
1068 writer->WriteObjectHeader(kInlined, object_id); 1164 writer->WriteSerializationMarker(kInlined, object_id);
1069 1165
1070 // Write out the class information. 1166 // Write out the class and tags information.
1071 writer->WriteObjectHeader(kObjectId, class_id); 1167 writer->WriteObjectHeader(class_id, tags);
1072 1168
1073 // Write out the length field. 1169 // Write out the length field.
1074 writer->Write<RawObject*>(length); 1170 writer->Write<RawObject*>(length);
1075 1171
1076 // Write out the hash field. 1172 // Write out the hash field.
1077 writer->Write<RawObject*>(hash); 1173 writer->Write<RawObject*>(hash);
1078 1174
1079 // Write out the string. 1175 // Write out the string.
1080 for (intptr_t i = 0; i < len; i++) { 1176 for (intptr_t i = 0; i < len; i++) {
1081 writer->Write(data[i]); 1177 writer->Write(data[i]);
1082 } 1178 }
1083 } 1179 }
1084 1180
1085 1181
1086 void RawOneByteString::WriteTo(SnapshotWriter* writer, 1182 void RawOneByteString::WriteTo(SnapshotWriter* writer,
1087 intptr_t object_id, 1183 intptr_t object_id,
1088 Snapshot::Kind kind) { 1184 Snapshot::Kind kind) {
1089 StringWriteTo(writer, 1185 StringWriteTo(writer,
1090 object_id, 1186 object_id,
1187 kind,
1091 ObjectStore::kOneByteStringClass, 1188 ObjectStore::kOneByteStringClass,
1092 kind, 1189 ptr()->tags_,
1093 ptr()->length_, 1190 ptr()->length_,
1094 ptr()->hash_, 1191 ptr()->hash_,
1095 ptr()->data_); 1192 ptr()->data_);
1096 } 1193 }
1097 1194
1098 1195
1099 void RawTwoByteString::WriteTo(SnapshotWriter* writer, 1196 void RawTwoByteString::WriteTo(SnapshotWriter* writer,
1100 intptr_t object_id, 1197 intptr_t object_id,
1101 Snapshot::Kind kind) { 1198 Snapshot::Kind kind) {
1102 StringWriteTo(writer, 1199 StringWriteTo(writer,
1103 object_id, 1200 object_id,
1201 kind,
1104 ObjectStore::kTwoByteStringClass, 1202 ObjectStore::kTwoByteStringClass,
1105 kind, 1203 ptr()->tags_,
1106 ptr()->length_, 1204 ptr()->length_,
1107 ptr()->hash_, 1205 ptr()->hash_,
1108 ptr()->data_); 1206 ptr()->data_);
1109 } 1207 }
1110 1208
1111 1209
1112 void RawFourByteString::WriteTo(SnapshotWriter* writer, 1210 void RawFourByteString::WriteTo(SnapshotWriter* writer,
1113 intptr_t object_id, 1211 intptr_t object_id,
1114 Snapshot::Kind kind) { 1212 Snapshot::Kind kind) {
1115 StringWriteTo(writer, 1213 StringWriteTo(writer,
1116 object_id, 1214 object_id,
1215 kind,
1117 ObjectStore::kFourByteStringClass, 1216 ObjectStore::kFourByteStringClass,
1118 kind, 1217 ptr()->tags_,
1119 ptr()->length_, 1218 ptr()->length_,
1120 ptr()->hash_, 1219 ptr()->hash_,
1121 ptr()->data_); 1220 ptr()->data_);
1122 } 1221 }
1123 1222
1124 1223
1125 RawExternalOneByteString* ExternalOneByteString::ReadFrom( 1224 RawExternalOneByteString* ExternalOneByteString::ReadFrom(
1126 SnapshotReader* reader, 1225 SnapshotReader* reader,
1127 intptr_t object_id, 1226 intptr_t object_id,
1227 intptr_t tags,
1128 Snapshot::Kind kind) { 1228 Snapshot::Kind kind) {
1129 UNREACHABLE(); 1229 UNREACHABLE();
1130 return ExternalOneByteString::null(); 1230 return ExternalOneByteString::null();
1131 } 1231 }
1132 1232
1133 1233
1134 RawExternalTwoByteString* ExternalTwoByteString::ReadFrom( 1234 RawExternalTwoByteString* ExternalTwoByteString::ReadFrom(
1135 SnapshotReader* reader, 1235 SnapshotReader* reader,
1136 intptr_t object_id, 1236 intptr_t object_id,
1237 intptr_t tags,
1137 Snapshot::Kind kind) { 1238 Snapshot::Kind kind) {
1138 UNREACHABLE(); 1239 UNREACHABLE();
1139 return ExternalTwoByteString::null(); 1240 return ExternalTwoByteString::null();
1140 } 1241 }
1141 1242
1142 1243
1143 RawExternalFourByteString* ExternalFourByteString::ReadFrom( 1244 RawExternalFourByteString* ExternalFourByteString::ReadFrom(
1144 SnapshotReader* reader, 1245 SnapshotReader* reader,
1145 intptr_t object_id, 1246 intptr_t object_id,
1247 intptr_t tags,
1146 Snapshot::Kind kind) { 1248 Snapshot::Kind kind) {
1147 UNREACHABLE(); 1249 UNREACHABLE();
1148 return ExternalFourByteString::null(); 1250 return ExternalFourByteString::null();
1149 } 1251 }
1150 1252
1151 1253
1152 void RawExternalOneByteString::WriteTo(SnapshotWriter* writer, 1254 void RawExternalOneByteString::WriteTo(SnapshotWriter* writer,
1153 intptr_t object_id, 1255 intptr_t object_id,
1154 Snapshot::Kind kind) { 1256 Snapshot::Kind kind) {
1155 // Serialize as a non-external one byte string. 1257 // Serialize as a non-external one byte string.
1156 StringWriteTo(writer, 1258 StringWriteTo(writer,
1157 object_id, 1259 object_id,
1260 kind,
1158 ObjectStore::kOneByteStringClass, 1261 ObjectStore::kOneByteStringClass,
1159 kind, 1262 ptr()->tags_,
1160 ptr()->length_, 1263 ptr()->length_,
1161 ptr()->hash_, 1264 ptr()->hash_,
1162 ptr()->external_data_->data_); 1265 ptr()->external_data_->data_);
1163 } 1266 }
1164 1267
1165 1268
1166 void RawExternalTwoByteString::WriteTo(SnapshotWriter* writer, 1269 void RawExternalTwoByteString::WriteTo(SnapshotWriter* writer,
1167 intptr_t object_id, 1270 intptr_t object_id,
1168 Snapshot::Kind kind) { 1271 Snapshot::Kind kind) {
1169 // Serialize as a non-external two byte string. 1272 // Serialize as a non-external two byte string.
1170 StringWriteTo(writer, 1273 StringWriteTo(writer,
1171 object_id, 1274 object_id,
1275 kind,
1172 ObjectStore::kTwoByteStringClass, 1276 ObjectStore::kTwoByteStringClass,
1173 kind, 1277 ptr()->tags_,
1174 ptr()->length_, 1278 ptr()->length_,
1175 ptr()->hash_, 1279 ptr()->hash_,
1176 ptr()->external_data_->data_); 1280 ptr()->external_data_->data_);
1177 } 1281 }
1178 1282
1179 1283
1180 void RawExternalFourByteString::WriteTo(SnapshotWriter* writer, 1284 void RawExternalFourByteString::WriteTo(SnapshotWriter* writer,
1181 intptr_t object_id, 1285 intptr_t object_id,
1182 Snapshot::Kind kind) { 1286 Snapshot::Kind kind) {
1183 // Serialize as a non-external four byte string. 1287 // Serialize as a non-external four byte string.
1184 StringWriteTo(writer, 1288 StringWriteTo(writer,
1185 object_id, 1289 object_id,
1290 kind,
1186 ObjectStore::kFourByteStringClass, 1291 ObjectStore::kFourByteStringClass,
1187 kind, 1292 ptr()->tags_,
1188 ptr()->length_, 1293 ptr()->length_,
1189 ptr()->hash_, 1294 ptr()->hash_,
1190 ptr()->external_data_->data_); 1295 ptr()->external_data_->data_);
1191 } 1296 }
1192 1297
1193 1298
1194 RawBool* Bool::ReadFrom(SnapshotReader* reader, 1299 RawBool* Bool::ReadFrom(SnapshotReader* reader,
1195 intptr_t object_id, 1300 intptr_t object_id,
1196 Snapshot::Kind kind) { 1301 intptr_t tags,
1302 Snapshot::Kind kind) {
1197 UNREACHABLE(); 1303 UNREACHABLE();
1198 return Bool::null(); 1304 return Bool::null();
1199 } 1305 }
1200 1306
1201 1307
1202 void RawBool::WriteTo(SnapshotWriter* writer, 1308 void RawBool::WriteTo(SnapshotWriter* writer,
1203 intptr_t object_id, 1309 intptr_t object_id,
1204 Snapshot::Kind kind) { 1310 Snapshot::Kind kind) {
1205 UNREACHABLE(); 1311 UNREACHABLE();
1206 } 1312 }
1207 1313
1208 1314
1209 template <class T> 1315 template <class T>
1210 static RawObject* ArrayReadFrom(SnapshotReader* reader, 1316 static RawObject* ArrayReadFrom(SnapshotReader* reader,
1211 intptr_t object_id, 1317 intptr_t object_id,
1318 intptr_t tags,
1212 Snapshot::Kind kind) { 1319 Snapshot::Kind kind) {
1213 ASSERT(reader != NULL); 1320 ASSERT(reader != NULL);
1214 1321
1215 // Read the length so that we can determine instance size to allocate. 1322 // Read the length so that we can determine instance size to allocate.
1216 RawSmi* smi_len = GetSmi(reader->Read<intptr_t>()); 1323 RawSmi* smi_len = GetSmi(reader->Read<intptr_t>());
1217 intptr_t len = Smi::Value(smi_len); 1324 intptr_t len = Smi::Value(smi_len);
1218 T& result = T::Handle( 1325 T& result = T::Handle(
1219 T::New(len, (kind == Snapshot::kFull) ? Heap::kOld : Heap::kNew)); 1326 T::New(len, (kind == Snapshot::kFull) ? Heap::kOld : Heap::kNew));
1220 reader->AddBackwardReference(object_id, &result); 1327 reader->AddBackwardReference(object_id, &result);
1221 1328
1329 // Set the object tags.
1330 result.set_tags(tags);
1331
1332 // Setup the object fields.
1222 AbstractTypeArguments& type_arguments = AbstractTypeArguments::Handle(); 1333 AbstractTypeArguments& type_arguments = AbstractTypeArguments::Handle();
1223 type_arguments ^= reader->ReadObject(); 1334 type_arguments ^= reader->ReadObject();
1224 result.SetTypeArguments(type_arguments); 1335 result.SetTypeArguments(type_arguments);
1225 1336
1226 Object& obj = Object::Handle(); 1337 Object& obj = Object::Handle();
1227 for (intptr_t i = 0; i < len; i++) { 1338 for (intptr_t i = 0; i < len; i++) {
1228 obj = reader->ReadObject(); 1339 obj = reader->ReadObject();
1229 result.SetAt(i, obj); 1340 result.SetAt(i, obj);
1230 } 1341 }
1231 return result.raw(); 1342 return result.raw();
1232 } 1343 }
1233 1344
1234 1345
1235 RawArray* Array::ReadFrom(SnapshotReader* reader, 1346 RawArray* Array::ReadFrom(SnapshotReader* reader,
1236 intptr_t object_id, 1347 intptr_t object_id,
1348 intptr_t tags,
1237 Snapshot::Kind kind) { 1349 Snapshot::Kind kind) {
1238 return reinterpret_cast<RawArray*>(ArrayReadFrom<Array>(reader, 1350 return reinterpret_cast<RawArray*>(
1239 object_id, 1351 ArrayReadFrom<Array>(reader, object_id, tags, kind));
1240 kind));
1241 } 1352 }
1242 1353
1243 1354
1244 RawImmutableArray* ImmutableArray::ReadFrom(SnapshotReader* reader, 1355 RawImmutableArray* ImmutableArray::ReadFrom(SnapshotReader* reader,
1245 intptr_t object_id, 1356 intptr_t object_id,
1357 intptr_t tags,
1246 Snapshot::Kind kind) { 1358 Snapshot::Kind kind) {
1247 return reinterpret_cast<RawImmutableArray*>( 1359 return reinterpret_cast<RawImmutableArray*>(
1248 ArrayReadFrom<ImmutableArray>(reader, object_id, kind)); 1360 ArrayReadFrom<ImmutableArray>(reader, object_id, tags, kind));
1249 } 1361 }
1250 1362
1251 1363
1252 static void ArrayWriteTo(SnapshotWriter* writer, 1364 static void ArrayWriteTo(SnapshotWriter* writer,
1253 intptr_t object_id, 1365 intptr_t object_id,
1254 Snapshot::Kind kind, 1366 Snapshot::Kind kind,
1255 intptr_t array_kind, 1367 intptr_t array_kind,
1368 intptr_t tags,
1256 RawSmi* length, 1369 RawSmi* length,
1257 RawAbstractTypeArguments* type_arguments, 1370 RawAbstractTypeArguments* type_arguments,
1258 RawObject* data[]) { 1371 RawObject* data[]) {
1259 ASSERT(writer != NULL); 1372 ASSERT(writer != NULL);
1260 intptr_t len = Smi::Value(length); 1373 intptr_t len = Smi::Value(length);
1261 1374
1262 // Write out the serialization header value for this object. 1375 // Write out the serialization header value for this object.
1263 writer->WriteObjectHeader(kInlined, object_id); 1376 writer->WriteSerializationMarker(kInlined, object_id);
1264 1377
1265 // Write out the class information. 1378 // Write out the class and tags information.
1266 writer->WriteObjectHeader(kObjectId, array_kind); 1379 writer->WriteObjectHeader(array_kind, tags);
1267 1380
1268 // Write out the length field. 1381 // Write out the length field.
1269 writer->Write<RawObject*>(length); 1382 writer->Write<RawObject*>(length);
1270 1383
1271 // Write out the type arguments. 1384 // Write out the type arguments.
1272 writer->WriteObject(type_arguments); 1385 writer->WriteObject(type_arguments);
1273 1386
1274 // Write out the individual objects. 1387 // Write out the individual objects.
1275 for (intptr_t i = 0; i < len; i++) { 1388 for (intptr_t i = 0; i < len; i++) {
1276 writer->WriteObject(data[i]); 1389 writer->WriteObject(data[i]);
1277 } 1390 }
1278 } 1391 }
1279 1392
1280 1393
1281 void RawArray::WriteTo(SnapshotWriter* writer, 1394 void RawArray::WriteTo(SnapshotWriter* writer,
1282 intptr_t object_id, 1395 intptr_t object_id,
1283 Snapshot::Kind kind) { 1396 Snapshot::Kind kind) {
1284 ArrayWriteTo(writer, 1397 ArrayWriteTo(writer,
1285 object_id, 1398 object_id,
1286 kind, 1399 kind,
1287 ObjectStore::kArrayClass, 1400 ObjectStore::kArrayClass,
1401 ptr()->tags_,
1288 ptr()->length_, 1402 ptr()->length_,
1289 ptr()->type_arguments_, 1403 ptr()->type_arguments_,
1290 ptr()->data()); 1404 ptr()->data());
1291 } 1405 }
1292 1406
1293 1407
1294 void RawImmutableArray::WriteTo(SnapshotWriter* writer, 1408 void RawImmutableArray::WriteTo(SnapshotWriter* writer,
1295 intptr_t object_id, 1409 intptr_t object_id,
1296 Snapshot::Kind kind) { 1410 Snapshot::Kind kind) {
1297 ArrayWriteTo(writer, 1411 ArrayWriteTo(writer,
1298 object_id, 1412 object_id,
1299 kind, 1413 kind,
1300 ObjectStore::kImmutableArrayClass, 1414 ObjectStore::kImmutableArrayClass,
1415 ptr()->tags_,
1301 ptr()->length_, 1416 ptr()->length_,
1302 ptr()->type_arguments_, 1417 ptr()->type_arguments_,
1303 ptr()->data()); 1418 ptr()->data());
1304 } 1419 }
1305 1420
1306 1421
1307 RawByteBuffer* ByteBuffer::ReadFrom(SnapshotReader* reader, 1422 RawByteBuffer* ByteBuffer::ReadFrom(SnapshotReader* reader,
1308 intptr_t object_id, 1423 intptr_t object_id,
1424 intptr_t tags,
1309 Snapshot::Kind kind) { 1425 Snapshot::Kind kind) {
1310 UNIMPLEMENTED(); 1426 UNIMPLEMENTED();
1311 return ByteBuffer::null(); 1427 return ByteBuffer::null();
1312 } 1428 }
1313 1429
1314 1430
1315 void RawByteBuffer::WriteTo(SnapshotWriter* writer, 1431 void RawByteBuffer::WriteTo(SnapshotWriter* writer,
1316 intptr_t object_id, 1432 intptr_t object_id,
1317 Snapshot::Kind kind) { 1433 Snapshot::Kind kind) {
1318 UNIMPLEMENTED(); 1434 UNIMPLEMENTED();
1319 } 1435 }
1320 1436
1321 1437
1322 RawClosure* Closure::ReadFrom(SnapshotReader* reader, 1438 RawClosure* Closure::ReadFrom(SnapshotReader* reader,
1323 intptr_t object_id, 1439 intptr_t object_id,
1440 intptr_t tags,
1324 Snapshot::Kind kind) { 1441 Snapshot::Kind kind) {
1325 UNIMPLEMENTED(); 1442 UNIMPLEMENTED();
1326 return Closure::null(); 1443 return Closure::null();
1327 } 1444 }
1328 1445
1329 1446
1330 void RawClosure::WriteTo(SnapshotWriter* writer, 1447 void RawClosure::WriteTo(SnapshotWriter* writer,
1331 intptr_t object_id, 1448 intptr_t object_id,
1332 Snapshot::Kind kind) { 1449 Snapshot::Kind kind) {
1333 UNIMPLEMENTED(); 1450 UNIMPLEMENTED();
1334 } 1451 }
1335 1452
1336 1453
1337 RawStacktrace* Stacktrace::ReadFrom(SnapshotReader* reader, 1454 RawStacktrace* Stacktrace::ReadFrom(SnapshotReader* reader,
1338 intptr_t object_id, 1455 intptr_t object_id,
1456 intptr_t tags,
1339 Snapshot::Kind kind) { 1457 Snapshot::Kind kind) {
1340 UNIMPLEMENTED(); 1458 UNIMPLEMENTED();
1341 return Stacktrace::null(); 1459 return Stacktrace::null();
1342 } 1460 }
1343 1461
1344 1462
1345 void RawStacktrace::WriteTo(SnapshotWriter* writer, 1463 void RawStacktrace::WriteTo(SnapshotWriter* writer,
1346 intptr_t object_id, 1464 intptr_t object_id,
1347 Snapshot::Kind kind) { 1465 Snapshot::Kind kind) {
1348 UNIMPLEMENTED(); 1466 UNIMPLEMENTED();
1349 } 1467 }
1350 1468
1351 1469
1352 RawJSRegExp* JSRegExp::ReadFrom(SnapshotReader* reader, 1470 RawJSRegExp* JSRegExp::ReadFrom(SnapshotReader* reader,
1353 intptr_t object_id, 1471 intptr_t object_id,
1472 intptr_t tags,
1354 Snapshot::Kind kind) { 1473 Snapshot::Kind kind) {
1355 ASSERT(reader != NULL); 1474 ASSERT(reader != NULL);
1356 ASSERT(kind == Snapshot::kMessage); 1475 ASSERT(kind == Snapshot::kMessage);
1357 1476
1358 // Read the length so that we can determine instance size to allocate. 1477 // Read the length so that we can determine instance size to allocate.
1359 RawSmi* smi_len = GetSmi(reader->Read<intptr_t>()); 1478 RawSmi* smi_len = GetSmi(reader->Read<intptr_t>());
1360 intptr_t len = Smi::Value(smi_len); 1479 intptr_t len = Smi::Value(smi_len);
1361 1480
1362 // Allocate JSRegExp object. 1481 // Allocate JSRegExp object.
1363 JSRegExp& regex = JSRegExp::ZoneHandle( 1482 JSRegExp& regex = JSRegExp::ZoneHandle(
1364 JSRegExp::New(len, (kind == Snapshot::kFull) ? Heap::kOld : Heap::kNew)); 1483 JSRegExp::New(len, (kind == Snapshot::kFull) ? Heap::kOld : Heap::kNew));
1365 reader->AddBackwardReference(object_id, &regex); 1484 reader->AddBackwardReference(object_id, &regex);
1366 1485
1486 // Set the object tags.
1487 regex.set_tags(tags);
1488
1367 // Read and Set all the other fields. 1489 // Read and Set all the other fields.
1368 regex.raw_ptr()->num_bracket_expressions_ = GetSmi(reader->Read<intptr_t>()); 1490 regex.raw_ptr()->num_bracket_expressions_ = GetSmi(reader->Read<intptr_t>());
1369 String& pattern = String::Handle(); 1491 String& pattern = String::Handle();
1370 pattern ^= reader->ReadObject(); 1492 pattern ^= reader->ReadObject();
1371 regex.raw_ptr()->pattern_ = pattern.raw(); 1493 regex.raw_ptr()->pattern_ = pattern.raw();
1372 regex.raw_ptr()->type_ = reader->Read<intptr_t>(); 1494 regex.raw_ptr()->type_ = reader->Read<intptr_t>();
1373 regex.raw_ptr()->flags_ = reader->Read<intptr_t>(); 1495 regex.raw_ptr()->flags_ = reader->Read<intptr_t>();
1374 1496
1375 // TODO(5411462): Need to implement a way of recompiling the regex. 1497 // TODO(5411462): Need to implement a way of recompiling the regex.
1376 1498
1377 return regex.raw(); 1499 return regex.raw();
1378 } 1500 }
1379 1501
1380 1502
1381 void RawJSRegExp::WriteTo(SnapshotWriter* writer, 1503 void RawJSRegExp::WriteTo(SnapshotWriter* writer,
1382 intptr_t object_id, 1504 intptr_t object_id,
1383 Snapshot::Kind kind) { 1505 Snapshot::Kind kind) {
1384 ASSERT(writer != NULL); 1506 ASSERT(writer != NULL);
1385 ASSERT(kind == Snapshot::kMessage); 1507 ASSERT(kind == Snapshot::kMessage);
1386 1508
1387 // Write out the serialization header value for this object. 1509 // Write out the serialization header value for this object.
1388 writer->WriteObjectHeader(kInlined, object_id); 1510 writer->WriteSerializationMarker(kInlined, object_id);
1389 1511
1390 // Write out the class information. 1512 // Write out the class and tags information.
1391 writer->WriteObjectHeader(kObjectId, ObjectStore::kJSRegExpClass); 1513 writer->WriteObjectHeader(ObjectStore::kJSRegExpClass, ptr()->tags_);
1392 1514
1393 // Write out the data length field. 1515 // Write out the data length field.
1394 writer->Write<RawObject*>(ptr()->data_length_); 1516 writer->Write<RawObject*>(ptr()->data_length_);
1395 1517
1396 // Write out all the other fields. 1518 // Write out all the other fields.
1397 writer->Write<RawObject*>(ptr()->num_bracket_expressions_); 1519 writer->Write<RawObject*>(ptr()->num_bracket_expressions_);
1398 writer->WriteObject(ptr()->pattern_); 1520 writer->WriteObject(ptr()->pattern_);
1399 writer->Write<intptr_t>(ptr()->type_); 1521 writer->Write<intptr_t>(ptr()->type_);
1400 writer->Write<intptr_t>(ptr()->flags_); 1522 writer->Write<intptr_t>(ptr()->flags_);
1401 1523
1402 // Do not write out the data part which is native. 1524 // Do not write out the data part which is native.
1403 } 1525 }
1404 1526
1405 } // namespace dart 1527 } // namespace dart
OLDNEW
« no previous file with comments | « vm/raw_object.h ('k') | vm/snapshot.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698