OLD | NEW |
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/symbols.h" | 9 #include "vm/symbols.h" |
10 #include "vm/visitor.h" | 10 #include "vm/visitor.h" |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 UNREACHABLE(); // AbstractType is an abstract class. | 179 UNREACHABLE(); // AbstractType is an abstract class. |
180 } | 180 } |
181 | 181 |
182 | 182 |
183 RawType* Type::ReadFrom(SnapshotReader* reader, | 183 RawType* Type::ReadFrom(SnapshotReader* reader, |
184 intptr_t object_id, | 184 intptr_t object_id, |
185 intptr_t tags, | 185 intptr_t tags, |
186 Snapshot::Kind kind) { | 186 Snapshot::Kind kind) { |
187 ASSERT(reader != NULL); | 187 ASSERT(reader != NULL); |
188 | 188 |
189 // Allocate parameterized type object. | 189 // Allocate type object. |
190 Type& parameterized_type = Type::ZoneHandle( | 190 Type& type = Type::ZoneHandle(reader->isolate(), NEW_OBJECT(Type)); |
191 reader->isolate(), NEW_OBJECT(Type)); | 191 reader->AddBackRef(object_id, &type, kIsDeserialized); |
192 reader->AddBackRef(object_id, ¶meterized_type, kIsDeserialized); | |
193 | 192 |
194 // Set the object tags. | 193 // Set the object tags. |
195 parameterized_type.set_tags(tags); | 194 type.set_tags(tags); |
196 | 195 |
197 // Set all non object fields. | 196 // Set all non object fields. |
198 parameterized_type.set_token_pos(reader->ReadIntptrValue()); | 197 type.set_token_pos(reader->ReadIntptrValue()); |
199 parameterized_type.set_type_state(reader->Read<int8_t>()); | 198 type.set_type_state(reader->Read<int8_t>()); |
200 | 199 |
201 // Set all the object fields. | 200 // Set all the object fields. |
202 // TODO(5411462): Need to assert No GC can happen here, even though | 201 // TODO(5411462): Need to assert No GC can happen here, even though |
203 // allocations may happen. | 202 // allocations may happen. |
204 intptr_t num_flds = (parameterized_type.raw()->to() - | 203 intptr_t num_flds = (type.raw()->to() - type.raw()->from()); |
205 parameterized_type.raw()->from()); | |
206 for (intptr_t i = 0; i <= num_flds; i++) { | 204 for (intptr_t i = 0; i <= num_flds; i++) { |
207 *(parameterized_type.raw()->from() + i) = reader->ReadObjectImpl(); | 205 *(type.raw()->from() + i) = reader->ReadObjectRef(); |
208 } | 206 } |
209 | 207 |
210 // If object needs to be a canonical object, Canonicalize it. | 208 // If object needs to be a canonical object, Canonicalize it. |
211 if ((kind != Snapshot::kFull) && parameterized_type.IsCanonical()) { | 209 if ((kind != Snapshot::kFull) && type.IsCanonical()) { |
212 parameterized_type ^= parameterized_type.Canonicalize(); | 210 type ^= type.Canonicalize(); |
213 } | 211 } |
214 return parameterized_type.raw(); | 212 return type.raw(); |
215 } | 213 } |
216 | 214 |
217 | 215 |
218 void RawType::WriteTo(SnapshotWriter* writer, | 216 void RawType::WriteTo(SnapshotWriter* writer, |
219 intptr_t object_id, | 217 intptr_t object_id, |
220 Snapshot::Kind kind) { | 218 Snapshot::Kind kind) { |
221 ASSERT(writer != NULL); | 219 ASSERT(writer != NULL); |
222 | 220 |
223 // Write out the serialization header value for this object. | 221 // Write out the serialization header value for this object. |
224 writer->WriteInlinedObjectHeader(object_id); | 222 writer->WriteInlinedObjectHeader(object_id); |
225 | 223 |
226 // Write out the class and tags information. | 224 // Write out the class and tags information. |
227 writer->WriteVMIsolateObject(kTypeCid); | 225 writer->WriteVMIsolateObject(kTypeCid); |
228 writer->WriteIntptrValue(writer->GetObjectTags(this)); | 226 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
229 | 227 |
230 // Write out all the non object pointer fields. | 228 // Write out all the non object pointer fields. |
231 writer->WriteIntptrValue(ptr()->token_pos_); | 229 writer->WriteIntptrValue(ptr()->token_pos_); |
232 writer->Write<int8_t>(ptr()->type_state_); | 230 writer->Write<int8_t>(ptr()->type_state_); |
233 | 231 |
234 // Write out all the object pointer fields. | 232 // Write out all the object pointer fields. |
235 SnapshotWriterVisitor visitor(writer, false); | 233 SnapshotWriterVisitor visitor(writer); |
236 visitor.VisitPointers(from(), to()); | 234 visitor.VisitPointers(from(), to()); |
237 } | 235 } |
238 | 236 |
239 | 237 |
240 RawTypeParameter* TypeParameter::ReadFrom(SnapshotReader* reader, | 238 RawTypeParameter* TypeParameter::ReadFrom(SnapshotReader* reader, |
241 intptr_t object_id, | 239 intptr_t object_id, |
242 intptr_t tags, | 240 intptr_t tags, |
243 Snapshot::Kind kind) { | 241 Snapshot::Kind kind) { |
244 ASSERT(reader != NULL); | 242 ASSERT(reader != NULL); |
245 | 243 |
246 // Allocate type parameter object. | 244 // Allocate type parameter object. |
247 TypeParameter& type_parameter = TypeParameter::ZoneHandle( | 245 TypeParameter& type_parameter = TypeParameter::ZoneHandle( |
248 reader->isolate(), NEW_OBJECT(TypeParameter)); | 246 reader->isolate(), NEW_OBJECT(TypeParameter)); |
249 reader->AddBackRef(object_id, &type_parameter, kIsDeserialized); | 247 reader->AddBackRef(object_id, &type_parameter, kIsDeserialized); |
250 | 248 |
251 // Set the object tags. | 249 // Set the object tags. |
252 type_parameter.set_tags(tags); | 250 type_parameter.set_tags(tags); |
253 | 251 |
254 // Set all non object fields. | 252 // Set all non object fields. |
255 type_parameter.set_index(reader->ReadIntptrValue()); | 253 type_parameter.set_index(reader->ReadIntptrValue()); |
256 type_parameter.set_token_pos(reader->ReadIntptrValue()); | 254 type_parameter.set_token_pos(reader->ReadIntptrValue()); |
257 type_parameter.set_type_state(reader->Read<int8_t>()); | 255 type_parameter.set_type_state(reader->Read<int8_t>()); |
258 | 256 |
259 // Set all the object fields. | 257 // Set all the object fields. |
260 // TODO(5411462): Need to assert No GC can happen here, even though | 258 // TODO(5411462): Need to assert No GC can happen here, even though |
261 // allocations may happen. | 259 // allocations may happen. |
262 intptr_t num_flds = (type_parameter.raw()->to() - | 260 intptr_t num_flds = (type_parameter.raw()->to() - |
263 type_parameter.raw()->from()); | 261 type_parameter.raw()->from()); |
264 for (intptr_t i = 0; i <= num_flds; i++) { | 262 for (intptr_t i = 0; i <= num_flds; i++) { |
265 *(type_parameter.raw()->from() + i) = reader->ReadObjectImpl(); | 263 *(type_parameter.raw()->from() + i) = reader->ReadObjectRef(); |
266 } | 264 } |
267 | 265 |
268 return type_parameter.raw(); | 266 return type_parameter.raw(); |
269 } | 267 } |
270 | 268 |
271 | 269 |
272 void RawTypeParameter::WriteTo(SnapshotWriter* writer, | 270 void RawTypeParameter::WriteTo(SnapshotWriter* writer, |
273 intptr_t object_id, | 271 intptr_t object_id, |
274 Snapshot::Kind kind) { | 272 Snapshot::Kind kind) { |
275 ASSERT(writer != NULL); | 273 ASSERT(writer != NULL); |
276 | 274 |
277 // Write out the serialization header value for this object. | 275 // Write out the serialization header value for this object. |
278 writer->WriteInlinedObjectHeader(object_id); | 276 writer->WriteInlinedObjectHeader(object_id); |
279 | 277 |
280 // Write out the class and tags information. | 278 // Write out the class and tags information. |
281 writer->WriteVMIsolateObject(kTypeParameterCid); | 279 writer->WriteVMIsolateObject(kTypeParameterCid); |
282 writer->WriteIntptrValue(writer->GetObjectTags(this)); | 280 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
283 | 281 |
284 // Write out all the non object pointer fields. | 282 // Write out all the non object pointer fields. |
285 writer->WriteIntptrValue(ptr()->index_); | 283 writer->WriteIntptrValue(ptr()->index_); |
286 writer->WriteIntptrValue(ptr()->token_pos_); | 284 writer->WriteIntptrValue(ptr()->token_pos_); |
287 writer->Write<int8_t>(ptr()->type_state_); | 285 writer->Write<int8_t>(ptr()->type_state_); |
288 | 286 |
289 // Write out all the object pointer fields. | 287 // Write out all the object pointer fields. |
290 SnapshotWriterVisitor visitor(writer, false); | 288 SnapshotWriterVisitor visitor(writer); |
291 visitor.VisitPointers(from(), to()); | 289 visitor.VisitPointers(from(), to()); |
292 } | 290 } |
293 | 291 |
294 | 292 |
295 RawAbstractTypeArguments* AbstractTypeArguments::ReadFrom( | 293 RawAbstractTypeArguments* AbstractTypeArguments::ReadFrom( |
296 SnapshotReader* reader, | 294 SnapshotReader* reader, |
297 intptr_t object_id, | 295 intptr_t object_id, |
298 intptr_t tags, | 296 intptr_t tags, |
299 Snapshot::Kind kind) { | 297 Snapshot::Kind kind) { |
300 UNREACHABLE(); // AbstractTypeArguments is an abstract class. | 298 UNREACHABLE(); // AbstractTypeArguments is an abstract class. |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 | 378 |
381 // Set the object tags. | 379 // Set the object tags. |
382 instantiated_type_arguments.set_tags(tags); | 380 instantiated_type_arguments.set_tags(tags); |
383 | 381 |
384 // Set all the object fields. | 382 // Set all the object fields. |
385 // TODO(5411462): Need to assert No GC can happen here, even though | 383 // TODO(5411462): Need to assert No GC can happen here, even though |
386 // allocations may happen. | 384 // allocations may happen. |
387 intptr_t num_flds = (instantiated_type_arguments.raw()->to() - | 385 intptr_t num_flds = (instantiated_type_arguments.raw()->to() - |
388 instantiated_type_arguments.raw()->from()); | 386 instantiated_type_arguments.raw()->from()); |
389 for (intptr_t i = 0; i <= num_flds; i++) { | 387 for (intptr_t i = 0; i <= num_flds; i++) { |
390 *(instantiated_type_arguments.raw()->from() + i) = reader->ReadObjectImpl(); | 388 *(instantiated_type_arguments.raw()->from() + i) = reader->ReadObjectRef(); |
391 } | 389 } |
392 return instantiated_type_arguments.raw(); | 390 return instantiated_type_arguments.raw(); |
393 } | 391 } |
394 | 392 |
395 | 393 |
396 void RawInstantiatedTypeArguments::WriteTo(SnapshotWriter* writer, | 394 void RawInstantiatedTypeArguments::WriteTo(SnapshotWriter* writer, |
397 intptr_t object_id, | 395 intptr_t object_id, |
398 Snapshot::Kind kind) { | 396 Snapshot::Kind kind) { |
399 ASSERT(writer != NULL); | 397 ASSERT(writer != NULL); |
400 ASSERT(kind == Snapshot::kMessage); | 398 ASSERT(kind == Snapshot::kMessage); |
401 | 399 |
402 // Write out the serialization header value for this object. | 400 // Write out the serialization header value for this object. |
403 writer->WriteInlinedObjectHeader(object_id); | 401 writer->WriteInlinedObjectHeader(object_id); |
404 | 402 |
405 // Write out the class and tags information. | 403 // Write out the class and tags information. |
406 writer->WriteVMIsolateObject(kInstantiatedTypeArgumentsCid); | 404 writer->WriteVMIsolateObject(kInstantiatedTypeArgumentsCid); |
407 writer->WriteIntptrValue(writer->GetObjectTags(this)); | 405 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
408 | 406 |
409 // Write out all the object pointer fields. | 407 // Write out all the object pointer fields. |
410 SnapshotWriterVisitor visitor(writer, false); | 408 SnapshotWriterVisitor visitor(writer); |
411 visitor.VisitPointers(from(), to()); | 409 visitor.VisitPointers(from(), to()); |
412 } | 410 } |
413 | 411 |
414 | 412 |
415 RawPatchClass* PatchClass::ReadFrom(SnapshotReader* reader, | 413 RawPatchClass* PatchClass::ReadFrom(SnapshotReader* reader, |
416 intptr_t object_id, | 414 intptr_t object_id, |
417 intptr_t tags, | 415 intptr_t tags, |
418 Snapshot::Kind kind) { | 416 Snapshot::Kind kind) { |
419 ASSERT(reader != NULL); | 417 ASSERT(reader != NULL); |
420 ASSERT(kind != Snapshot::kMessage && !RawObject::IsCreatedFromSnapshot(tags)); | 418 ASSERT((kind != Snapshot::kMessage) && |
| 419 !RawObject::IsCreatedFromSnapshot(tags)); |
421 | 420 |
422 // Allocate function object. | 421 // Allocate function object. |
423 PatchClass& cls = PatchClass::ZoneHandle(reader->isolate(), | 422 PatchClass& cls = PatchClass::ZoneHandle(reader->isolate(), |
424 NEW_OBJECT(PatchClass)); | 423 NEW_OBJECT(PatchClass)); |
425 reader->AddBackRef(object_id, &cls, kIsDeserialized); | 424 reader->AddBackRef(object_id, &cls, kIsDeserialized); |
426 | 425 |
427 // Set the object tags. | 426 // Set the object tags. |
428 cls.set_tags(tags); | 427 cls.set_tags(tags); |
429 | 428 |
430 // Set all the object fields. | 429 // Set all the object fields. |
431 // TODO(5411462): Need to assert No GC can happen here, even though | 430 // TODO(5411462): Need to assert No GC can happen here, even though |
432 // allocations may happen. | 431 // allocations may happen. |
433 intptr_t num_flds = (cls.raw()->to() - cls.raw()->from()); | 432 intptr_t num_flds = (cls.raw()->to() - cls.raw()->from()); |
434 for (intptr_t i = 0; i <= num_flds; i++) { | 433 for (intptr_t i = 0; i <= num_flds; i++) { |
435 *(cls.raw()->from() + i) = reader->ReadObjectRef(); | 434 *(cls.raw()->from() + i) = reader->ReadObjectRef(); |
436 } | 435 } |
437 | 436 |
438 return cls.raw(); | 437 return cls.raw(); |
439 } | 438 } |
440 | 439 |
441 | 440 |
442 void RawPatchClass::WriteTo(SnapshotWriter* writer, | 441 void RawPatchClass::WriteTo(SnapshotWriter* writer, |
443 intptr_t object_id, | 442 intptr_t object_id, |
444 Snapshot::Kind kind) { | 443 Snapshot::Kind kind) { |
445 ASSERT(writer != NULL); | 444 ASSERT(writer != NULL); |
446 ASSERT(kind != Snapshot::kMessage && | 445 ASSERT((kind != Snapshot::kMessage) && |
447 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))); | 446 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))); |
448 | 447 |
449 // Write out the serialization header value for this object. | 448 // Write out the serialization header value for this object. |
450 writer->WriteInlinedObjectHeader(object_id); | 449 writer->WriteInlinedObjectHeader(object_id); |
451 | 450 |
452 // Write out the class and tags information. | 451 // Write out the class and tags information. |
453 writer->WriteVMIsolateObject(kPatchClassCid); | 452 writer->WriteVMIsolateObject(kPatchClassCid); |
454 writer->WriteIntptrValue(writer->GetObjectTags(this)); | 453 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
455 // Write out all the object pointer fields. | 454 // Write out all the object pointer fields. |
456 SnapshotWriterVisitor visitor(writer); | 455 SnapshotWriterVisitor visitor(writer); |
457 visitor.VisitPointers(from(), to()); | 456 visitor.VisitPointers(from(), to()); |
458 } | 457 } |
459 | 458 |
460 | 459 |
461 RawFunction* Function::ReadFrom(SnapshotReader* reader, | 460 RawFunction* Function::ReadFrom(SnapshotReader* reader, |
462 intptr_t object_id, | 461 intptr_t object_id, |
463 intptr_t tags, | 462 intptr_t tags, |
464 Snapshot::Kind kind) { | 463 Snapshot::Kind kind) { |
465 ASSERT(reader != NULL); | 464 ASSERT(reader != NULL); |
466 ASSERT(kind != Snapshot::kMessage && !RawObject::IsCreatedFromSnapshot(tags)); | 465 ASSERT((kind != Snapshot::kMessage) && |
| 466 !RawObject::IsCreatedFromSnapshot(tags)); |
467 | 467 |
468 // Allocate function object. | 468 // Allocate function object. |
469 Function& func = Function::ZoneHandle( | 469 Function& func = Function::ZoneHandle( |
470 reader->isolate(), NEW_OBJECT(Function)); | 470 reader->isolate(), NEW_OBJECT(Function)); |
471 reader->AddBackRef(object_id, &func, kIsDeserialized); | 471 reader->AddBackRef(object_id, &func, kIsDeserialized); |
472 | 472 |
473 // Set the object tags. | 473 // Set the object tags. |
474 func.set_tags(tags); | 474 func.set_tags(tags); |
475 | 475 |
476 // Set all the non object fields. | 476 // Set all the non object fields. |
(...skipping 14 matching lines...) Expand all Loading... |
491 } | 491 } |
492 | 492 |
493 return func.raw(); | 493 return func.raw(); |
494 } | 494 } |
495 | 495 |
496 | 496 |
497 void RawFunction::WriteTo(SnapshotWriter* writer, | 497 void RawFunction::WriteTo(SnapshotWriter* writer, |
498 intptr_t object_id, | 498 intptr_t object_id, |
499 Snapshot::Kind kind) { | 499 Snapshot::Kind kind) { |
500 ASSERT(writer != NULL); | 500 ASSERT(writer != NULL); |
501 ASSERT(kind != Snapshot::kMessage && | 501 ASSERT((kind != Snapshot::kMessage) && |
502 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))); | 502 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))); |
503 | 503 |
504 // Write out the serialization header value for this object. | 504 // Write out the serialization header value for this object. |
505 writer->WriteInlinedObjectHeader(object_id); | 505 writer->WriteInlinedObjectHeader(object_id); |
506 | 506 |
507 // Write out the class and tags information. | 507 // Write out the class and tags information. |
508 writer->WriteVMIsolateObject(kFunctionCid); | 508 writer->WriteVMIsolateObject(kFunctionCid); |
509 writer->WriteIntptrValue(writer->GetObjectTags(this)); | 509 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
510 | 510 |
511 // Write out all the non object fields. | 511 // Write out all the non object fields. |
512 writer->WriteIntptrValue(ptr()->token_pos_); | 512 writer->WriteIntptrValue(ptr()->token_pos_); |
513 writer->WriteIntptrValue(ptr()->end_token_pos_); | 513 writer->WriteIntptrValue(ptr()->end_token_pos_); |
514 writer->WriteIntptrValue(ptr()->num_fixed_parameters_); | 514 writer->WriteIntptrValue(ptr()->num_fixed_parameters_); |
515 writer->WriteIntptrValue(ptr()->num_optional_parameters_); | 515 writer->WriteIntptrValue(ptr()->num_optional_parameters_); |
516 writer->WriteIntptrValue(ptr()->usage_counter_); | 516 writer->WriteIntptrValue(ptr()->usage_counter_); |
517 writer->WriteIntptrValue(ptr()->deoptimization_counter_); | 517 writer->WriteIntptrValue(ptr()->deoptimization_counter_); |
518 writer->WriteIntptrValue(ptr()->kind_tag_); | 518 writer->WriteIntptrValue(ptr()->kind_tag_); |
519 | 519 |
520 // Write out all the object pointer fields. | 520 // Write out all the object pointer fields. |
521 SnapshotWriterVisitor visitor(writer); | 521 SnapshotWriterVisitor visitor(writer); |
522 visitor.VisitPointers(from(), to()); | 522 visitor.VisitPointers(from(), to()); |
523 } | 523 } |
524 | 524 |
525 | 525 |
526 RawField* Field::ReadFrom(SnapshotReader* reader, | 526 RawField* Field::ReadFrom(SnapshotReader* reader, |
527 intptr_t object_id, | 527 intptr_t object_id, |
528 intptr_t tags, | 528 intptr_t tags, |
529 Snapshot::Kind kind) { | 529 Snapshot::Kind kind) { |
530 ASSERT(reader != NULL); | 530 ASSERT(reader != NULL); |
531 ASSERT(kind != Snapshot::kMessage && !RawObject::IsCreatedFromSnapshot(tags)); | 531 ASSERT((kind != Snapshot::kMessage) && |
| 532 !RawObject::IsCreatedFromSnapshot(tags)); |
532 | 533 |
533 // Allocate field object. | 534 // Allocate field object. |
534 Field& field = Field::ZoneHandle(reader->isolate(), NEW_OBJECT(Field)); | 535 Field& field = Field::ZoneHandle(reader->isolate(), NEW_OBJECT(Field)); |
535 reader->AddBackRef(object_id, &field, kIsDeserialized); | 536 reader->AddBackRef(object_id, &field, kIsDeserialized); |
536 | 537 |
537 // Set the object tags. | 538 // Set the object tags. |
538 field.set_tags(tags); | 539 field.set_tags(tags); |
539 | 540 |
540 // Set all non object fields. | 541 // Set all non object fields. |
541 field.set_token_pos(reader->ReadIntptrValue()); | 542 field.set_token_pos(reader->ReadIntptrValue()); |
542 field.set_kind_bits(reader->Read<uint8_t>()); | 543 field.set_kind_bits(reader->Read<uint8_t>()); |
543 | 544 |
544 // Set all the object fields. | 545 // Set all the object fields. |
545 // TODO(5411462): Need to assert No GC can happen here, even though | 546 // TODO(5411462): Need to assert No GC can happen here, even though |
546 // allocations may happen. | 547 // allocations may happen. |
547 intptr_t num_flds = (field.raw()->to() - field.raw()->from()); | 548 intptr_t num_flds = (field.raw()->to() - field.raw()->from()); |
548 for (intptr_t i = 0; i <= num_flds; i++) { | 549 for (intptr_t i = 0; i <= num_flds; i++) { |
549 *(field.raw()->from() + i) = reader->ReadObjectRef(); | 550 *(field.raw()->from() + i) = reader->ReadObjectRef(); |
550 } | 551 } |
551 | 552 |
552 return field.raw(); | 553 return field.raw(); |
553 } | 554 } |
554 | 555 |
555 | 556 |
556 void RawField::WriteTo(SnapshotWriter* writer, | 557 void RawField::WriteTo(SnapshotWriter* writer, |
557 intptr_t object_id, | 558 intptr_t object_id, |
558 Snapshot::Kind kind) { | 559 Snapshot::Kind kind) { |
559 ASSERT(writer != NULL); | 560 ASSERT(writer != NULL); |
560 ASSERT(kind != Snapshot::kMessage && | 561 ASSERT((kind != Snapshot::kMessage) && |
561 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))); | 562 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))); |
562 | 563 |
563 // Write out the serialization header value for this object. | 564 // Write out the serialization header value for this object. |
564 writer->WriteInlinedObjectHeader(object_id); | 565 writer->WriteInlinedObjectHeader(object_id); |
565 | 566 |
566 // Write out the class and tags information. | 567 // Write out the class and tags information. |
567 writer->WriteVMIsolateObject(kFieldCid); | 568 writer->WriteVMIsolateObject(kFieldCid); |
568 writer->WriteIntptrValue(writer->GetObjectTags(this)); | 569 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
569 | 570 |
570 // Write out all the non object fields. | 571 // Write out all the non object fields. |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 writer->WriteObjectImpl(ptr()->literal_); | 625 writer->WriteObjectImpl(ptr()->literal_); |
625 writer->WriteObjectImpl(ptr()->value_); | 626 writer->WriteObjectImpl(ptr()->value_); |
626 } | 627 } |
627 | 628 |
628 | 629 |
629 RawTokenStream* TokenStream::ReadFrom(SnapshotReader* reader, | 630 RawTokenStream* TokenStream::ReadFrom(SnapshotReader* reader, |
630 intptr_t object_id, | 631 intptr_t object_id, |
631 intptr_t tags, | 632 intptr_t tags, |
632 Snapshot::Kind kind) { | 633 Snapshot::Kind kind) { |
633 ASSERT(reader != NULL); | 634 ASSERT(reader != NULL); |
634 ASSERT(kind != Snapshot::kMessage && !RawObject::IsCreatedFromSnapshot(tags)); | 635 ASSERT((kind != Snapshot::kMessage) |
| 636 && !RawObject::IsCreatedFromSnapshot(tags)); |
635 | 637 |
636 // Read the length so that we can determine number of tokens to read. | 638 // Read the length so that we can determine number of tokens to read. |
637 intptr_t len = reader->ReadSmiValue(); | 639 intptr_t len = reader->ReadSmiValue(); |
638 | 640 |
639 // Create the token stream object. | 641 // Create the token stream object. |
640 TokenStream& token_stream = TokenStream::ZoneHandle( | 642 TokenStream& token_stream = TokenStream::ZoneHandle( |
641 reader->isolate(), NEW_OBJECT_WITH_LEN(TokenStream, len)); | 643 reader->isolate(), NEW_OBJECT_WITH_LEN(TokenStream, len)); |
642 reader->AddBackRef(object_id, &token_stream, kIsDeserialized); | 644 reader->AddBackRef(object_id, &token_stream, kIsDeserialized); |
643 | 645 |
644 // Set the object tags. | 646 // Set the object tags. |
(...skipping 14 matching lines...) Expand all Loading... |
659 token_stream.SetPrivateKey(*(reader->StringHandle())); | 661 token_stream.SetPrivateKey(*(reader->StringHandle())); |
660 | 662 |
661 return token_stream.raw(); | 663 return token_stream.raw(); |
662 } | 664 } |
663 | 665 |
664 | 666 |
665 void RawTokenStream::WriteTo(SnapshotWriter* writer, | 667 void RawTokenStream::WriteTo(SnapshotWriter* writer, |
666 intptr_t object_id, | 668 intptr_t object_id, |
667 Snapshot::Kind kind) { | 669 Snapshot::Kind kind) { |
668 ASSERT(writer != NULL); | 670 ASSERT(writer != NULL); |
669 ASSERT(kind != Snapshot::kMessage && | 671 ASSERT((kind != Snapshot::kMessage) && |
670 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))); | 672 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))); |
671 | 673 |
672 // Write out the serialization header value for this object. | 674 // Write out the serialization header value for this object. |
673 writer->WriteInlinedObjectHeader(object_id); | 675 writer->WriteInlinedObjectHeader(object_id); |
674 | 676 |
675 // Write out the class and tags information. | 677 // Write out the class and tags information. |
676 writer->WriteVMIsolateObject(kTokenStreamCid); | 678 writer->WriteVMIsolateObject(kTokenStreamCid); |
677 writer->WriteIntptrValue(writer->GetObjectTags(this)); | 679 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
678 | 680 |
679 // Write out the length field and the token stream. | 681 // Write out the length field and the token stream. |
680 intptr_t len = Smi::Value(ptr()->length_); | 682 intptr_t len = Smi::Value(ptr()->length_); |
681 writer->Write<RawObject*>(ptr()->length_); | 683 writer->Write<RawObject*>(ptr()->length_); |
682 writer->WriteBytes(reinterpret_cast<uint8_t*>(ptr()->data_), len); | 684 writer->WriteBytes(reinterpret_cast<uint8_t*>(ptr()->data_), len); |
683 | 685 |
684 // Write out the literal/identifier token array. | 686 // Write out the literal/identifier token array. |
685 writer->WriteObjectImpl(ptr()->token_objects_); | 687 writer->WriteObjectImpl(ptr()->token_objects_); |
686 // Write out the private key in use by the token stream. | 688 // Write out the private key in use by the token stream. |
687 writer->WriteObjectImpl(ptr()->private_key_); | 689 writer->WriteObjectImpl(ptr()->private_key_); |
688 } | 690 } |
689 | 691 |
690 | 692 |
691 RawScript* Script::ReadFrom(SnapshotReader* reader, | 693 RawScript* Script::ReadFrom(SnapshotReader* reader, |
692 intptr_t object_id, | 694 intptr_t object_id, |
693 intptr_t tags, | 695 intptr_t tags, |
694 Snapshot::Kind kind) { | 696 Snapshot::Kind kind) { |
695 ASSERT(reader != NULL); | 697 ASSERT(reader != NULL); |
696 ASSERT(kind != Snapshot::kMessage && !RawObject::IsCreatedFromSnapshot(tags)); | 698 ASSERT((kind != Snapshot::kMessage) && |
| 699 !RawObject::IsCreatedFromSnapshot(tags)); |
697 | 700 |
698 // Allocate script object. | 701 // Allocate script object. |
699 Script& script = Script::ZoneHandle(reader->isolate(), NEW_OBJECT(Script)); | 702 Script& script = Script::ZoneHandle(reader->isolate(), NEW_OBJECT(Script)); |
700 reader->AddBackRef(object_id, &script, kIsDeserialized); | 703 reader->AddBackRef(object_id, &script, kIsDeserialized); |
701 | 704 |
702 // Set the object tags. | 705 // Set the object tags. |
703 script.set_tags(tags); | 706 script.set_tags(tags); |
704 | 707 |
705 // Set all the object fields. | 708 // Set all the object fields. |
706 // TODO(5411462): Need to assert No GC can happen here, even though | 709 // TODO(5411462): Need to assert No GC can happen here, even though |
707 // allocations may happen. | 710 // allocations may happen. |
708 *reader->StringHandle() ^= reader->ReadObjectImpl(); | 711 *reader->StringHandle() ^= reader->ReadObjectImpl(); |
709 script.set_url(*reader->StringHandle()); | 712 script.set_url(*reader->StringHandle()); |
710 *reader->StringHandle() ^= String::null(); | 713 *reader->StringHandle() ^= String::null(); |
711 script.set_source(*reader->StringHandle()); | 714 script.set_source(*reader->StringHandle()); |
712 TokenStream& stream = TokenStream::Handle(); | 715 TokenStream& stream = TokenStream::Handle(); |
713 stream ^= reader->ReadObjectImpl(); | 716 stream ^= reader->ReadObjectImpl(); |
714 script.set_tokens(stream); | 717 script.set_tokens(stream); |
715 | 718 |
716 return script.raw(); | 719 return script.raw(); |
717 } | 720 } |
718 | 721 |
719 | 722 |
720 void RawScript::WriteTo(SnapshotWriter* writer, | 723 void RawScript::WriteTo(SnapshotWriter* writer, |
721 intptr_t object_id, | 724 intptr_t object_id, |
722 Snapshot::Kind kind) { | 725 Snapshot::Kind kind) { |
723 ASSERT(writer != NULL); | 726 ASSERT(writer != NULL); |
724 ASSERT(tokens_ != TokenStream::null()); | 727 ASSERT(tokens_ != TokenStream::null()); |
725 ASSERT(kind != Snapshot::kMessage && | 728 ASSERT((kind != Snapshot::kMessage) && |
726 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))); | 729 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))); |
727 | 730 |
728 // Write out the serialization header value for this object. | 731 // Write out the serialization header value for this object. |
729 writer->WriteInlinedObjectHeader(object_id); | 732 writer->WriteInlinedObjectHeader(object_id); |
730 | 733 |
731 // Write out the class and tags information. | 734 // Write out the class and tags information. |
732 writer->WriteVMIsolateObject(kScriptCid); | 735 writer->WriteVMIsolateObject(kScriptCid); |
733 writer->WriteIntptrValue(writer->GetObjectTags(this)); | 736 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
734 | 737 |
735 // Write out all the object pointer fields. | 738 // Write out all the object pointer fields. |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
827 visitor.VisitPointers(from(), to()); | 830 visitor.VisitPointers(from(), to()); |
828 } | 831 } |
829 } | 832 } |
830 | 833 |
831 | 834 |
832 RawLibraryPrefix* LibraryPrefix::ReadFrom(SnapshotReader* reader, | 835 RawLibraryPrefix* LibraryPrefix::ReadFrom(SnapshotReader* reader, |
833 intptr_t object_id, | 836 intptr_t object_id, |
834 intptr_t tags, | 837 intptr_t tags, |
835 Snapshot::Kind kind) { | 838 Snapshot::Kind kind) { |
836 ASSERT(reader != NULL); | 839 ASSERT(reader != NULL); |
837 ASSERT(kind != Snapshot::kMessage && !RawObject::IsCreatedFromSnapshot(tags)); | 840 ASSERT((kind != Snapshot::kMessage) && |
| 841 !RawObject::IsCreatedFromSnapshot(tags)); |
838 | 842 |
839 // Allocate library prefix object. | 843 // Allocate library prefix object. |
840 LibraryPrefix& prefix = LibraryPrefix::ZoneHandle( | 844 LibraryPrefix& prefix = LibraryPrefix::ZoneHandle( |
841 reader->isolate(), NEW_OBJECT(LibraryPrefix)); | 845 reader->isolate(), NEW_OBJECT(LibraryPrefix)); |
842 reader->AddBackRef(object_id, &prefix, kIsDeserialized); | 846 reader->AddBackRef(object_id, &prefix, kIsDeserialized); |
843 | 847 |
844 // Set the object tags. | 848 // Set the object tags. |
845 prefix.set_tags(tags); | 849 prefix.set_tags(tags); |
846 | 850 |
847 // Set all non object fields. | 851 // Set all non object fields. |
848 prefix.raw_ptr()->num_libs_ = reader->ReadIntptrValue(); | 852 prefix.raw_ptr()->num_libs_ = reader->ReadIntptrValue(); |
849 | 853 |
850 // Set all the object fields. | 854 // Set all the object fields. |
851 // TODO(5411462): Need to assert No GC can happen here, even though | 855 // TODO(5411462): Need to assert No GC can happen here, even though |
852 // allocations may happen. | 856 // allocations may happen. |
853 intptr_t num_flds = (prefix.raw()->to() - prefix.raw()->from()); | 857 intptr_t num_flds = (prefix.raw()->to() - prefix.raw()->from()); |
854 for (intptr_t i = 0; i <= num_flds; i++) { | 858 for (intptr_t i = 0; i <= num_flds; i++) { |
855 *(prefix.raw()->from() + i) = reader->ReadObjectRef(); | 859 *(prefix.raw()->from() + i) = reader->ReadObjectRef(); |
856 } | 860 } |
857 | 861 |
858 return prefix.raw(); | 862 return prefix.raw(); |
859 } | 863 } |
860 | 864 |
861 | 865 |
862 void RawLibraryPrefix::WriteTo(SnapshotWriter* writer, | 866 void RawLibraryPrefix::WriteTo(SnapshotWriter* writer, |
863 intptr_t object_id, | 867 intptr_t object_id, |
864 Snapshot::Kind kind) { | 868 Snapshot::Kind kind) { |
865 ASSERT(writer != NULL); | 869 ASSERT(writer != NULL); |
866 ASSERT(kind != Snapshot::kMessage && | 870 ASSERT((kind != Snapshot::kMessage) && |
867 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))); | 871 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))); |
868 | 872 |
869 // Write out the serialization header value for this object. | 873 // Write out the serialization header value for this object. |
870 writer->WriteInlinedObjectHeader(object_id); | 874 writer->WriteInlinedObjectHeader(object_id); |
871 | 875 |
872 // Write out the class and tags information. | 876 // Write out the class and tags information. |
873 writer->WriteVMIsolateObject(kLibraryPrefixCid); | 877 writer->WriteVMIsolateObject(kLibraryPrefixCid); |
874 writer->WriteIntptrValue(writer->GetObjectTags(this)); | 878 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
875 | 879 |
876 // Write out all non object fields. | 880 // Write out all non object fields. |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1133 Snapshot::Kind kind) { | 1137 Snapshot::Kind kind) { |
1134 UNREACHABLE(); | 1138 UNREACHABLE(); |
1135 } | 1139 } |
1136 | 1140 |
1137 | 1141 |
1138 RawError* Error::ReadFrom(SnapshotReader* reader, | 1142 RawError* Error::ReadFrom(SnapshotReader* reader, |
1139 intptr_t object_id, | 1143 intptr_t object_id, |
1140 intptr_t tags, | 1144 intptr_t tags, |
1141 Snapshot::Kind kind) { | 1145 Snapshot::Kind kind) { |
1142 UNREACHABLE(); | 1146 UNREACHABLE(); |
1143 return Error::null(); | 1147 return Error::null(); // Error is an abstract class. |
1144 } | 1148 } |
1145 | 1149 |
1146 | 1150 |
1147 void RawError::WriteTo(SnapshotWriter* writer, | 1151 void RawError::WriteTo(SnapshotWriter* writer, |
1148 intptr_t object_id, | 1152 intptr_t object_id, |
1149 Snapshot::Kind kind) { | 1153 Snapshot::Kind kind) { |
1150 UNREACHABLE(); | 1154 UNREACHABLE(); // Error is an abstract class. |
1151 } | 1155 } |
1152 | 1156 |
1153 | 1157 |
1154 RawApiError* ApiError::ReadFrom(SnapshotReader* reader, | 1158 RawApiError* ApiError::ReadFrom(SnapshotReader* reader, |
1155 intptr_t object_id, | 1159 intptr_t object_id, |
1156 intptr_t tags, | 1160 intptr_t tags, |
1157 Snapshot::Kind kind) { | 1161 Snapshot::Kind kind) { |
1158 UNREACHABLE(); | 1162 ASSERT(reader != NULL); |
1159 return ApiError::null(); | 1163 |
| 1164 // Allocate ApiError object. |
| 1165 ApiError& api_error = |
| 1166 ApiError::ZoneHandle(reader->isolate(), NEW_OBJECT(ApiError)); |
| 1167 reader->AddBackRef(object_id, &api_error, kIsDeserialized); |
| 1168 |
| 1169 // Set the object tags. |
| 1170 api_error.set_tags(tags); |
| 1171 |
| 1172 // Set all the object fields. |
| 1173 // TODO(5411462): Need to assert No GC can happen here, even though |
| 1174 // allocations may happen. |
| 1175 intptr_t num_flds = (api_error.raw()->to() - api_error.raw()->from()); |
| 1176 for (intptr_t i = 0; i <= num_flds; i++) { |
| 1177 *(api_error.raw()->from() + i) = reader->ReadObjectRef(); |
| 1178 } |
| 1179 |
| 1180 return api_error.raw(); |
1160 } | 1181 } |
1161 | 1182 |
1162 | 1183 |
1163 void RawApiError::WriteTo(SnapshotWriter* writer, | 1184 void RawApiError::WriteTo(SnapshotWriter* writer, |
1164 intptr_t object_id, | 1185 intptr_t object_id, |
1165 Snapshot::Kind kind) { | 1186 Snapshot::Kind kind) { |
1166 UNREACHABLE(); | 1187 ASSERT(writer != NULL); |
| 1188 |
| 1189 // Write out the serialization header value for this object. |
| 1190 writer->WriteInlinedObjectHeader(object_id); |
| 1191 |
| 1192 // Write out the class and tags information. |
| 1193 writer->WriteVMIsolateObject(kApiErrorCid); |
| 1194 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
| 1195 |
| 1196 // Write out all the object pointer fields. |
| 1197 SnapshotWriterVisitor visitor(writer); |
| 1198 visitor.VisitPointers(from(), to()); |
1167 } | 1199 } |
1168 | 1200 |
1169 | 1201 |
1170 RawLanguageError* LanguageError::ReadFrom(SnapshotReader* reader, | 1202 RawLanguageError* LanguageError::ReadFrom(SnapshotReader* reader, |
1171 intptr_t object_id, | 1203 intptr_t object_id, |
1172 intptr_t tags, | 1204 intptr_t tags, |
1173 Snapshot::Kind kind) { | 1205 Snapshot::Kind kind) { |
1174 UNREACHABLE(); | 1206 ASSERT(reader != NULL); |
1175 return LanguageError::null(); | 1207 |
| 1208 // Allocate LanguageError object. |
| 1209 LanguageError& language_error = |
| 1210 LanguageError::ZoneHandle(reader->isolate(), NEW_OBJECT(LanguageError)); |
| 1211 reader->AddBackRef(object_id, &language_error, kIsDeserialized); |
| 1212 |
| 1213 // Set the object tags. |
| 1214 language_error.set_tags(tags); |
| 1215 |
| 1216 // Set all the object fields. |
| 1217 // TODO(5411462): Need to assert No GC can happen here, even though |
| 1218 // allocations may happen. |
| 1219 intptr_t num_flds = |
| 1220 (language_error.raw()->to() - language_error.raw()->from()); |
| 1221 for (intptr_t i = 0; i <= num_flds; i++) { |
| 1222 *(language_error.raw()->from() + i) = reader->ReadObjectRef(); |
| 1223 } |
| 1224 |
| 1225 return language_error.raw(); |
1176 } | 1226 } |
1177 | 1227 |
1178 | 1228 |
1179 void RawLanguageError::WriteTo(SnapshotWriter* writer, | 1229 void RawLanguageError::WriteTo(SnapshotWriter* writer, |
1180 intptr_t object_id, | 1230 intptr_t object_id, |
1181 Snapshot::Kind kind) { | 1231 Snapshot::Kind kind) { |
1182 UNREACHABLE(); | 1232 ASSERT(writer != NULL); |
| 1233 |
| 1234 // Write out the serialization header value for this object. |
| 1235 writer->WriteInlinedObjectHeader(object_id); |
| 1236 |
| 1237 // Write out the class and tags information. |
| 1238 writer->WriteVMIsolateObject(kLanguageErrorCid); |
| 1239 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
| 1240 |
| 1241 // Write out all the object pointer fields. |
| 1242 SnapshotWriterVisitor visitor(writer); |
| 1243 visitor.VisitPointers(from(), to()); |
1183 } | 1244 } |
1184 | 1245 |
1185 | 1246 |
1186 RawUnhandledException* UnhandledException::ReadFrom(SnapshotReader* reader, | 1247 RawUnhandledException* UnhandledException::ReadFrom(SnapshotReader* reader, |
1187 intptr_t object_id, | 1248 intptr_t object_id, |
1188 intptr_t tags, | 1249 intptr_t tags, |
1189 Snapshot::Kind kind) { | 1250 Snapshot::Kind kind) { |
1190 UNREACHABLE(); | 1251 UNREACHABLE(); |
1191 return UnhandledException::null(); | 1252 return UnhandledException::null(); |
1192 } | 1253 } |
(...skipping 899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2092 // Write out the class and tags information. | 2153 // Write out the class and tags information. |
2093 writer->WriteIndexedObject(kWeakPropertyCid); | 2154 writer->WriteIndexedObject(kWeakPropertyCid); |
2094 writer->WriteIntptrValue(writer->GetObjectTags(this)); | 2155 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
2095 | 2156 |
2096 // Write out all the other fields. | 2157 // Write out all the other fields. |
2097 writer->Write<RawObject*>(ptr()->key_); | 2158 writer->Write<RawObject*>(ptr()->key_); |
2098 writer->Write<RawObject*>(ptr()->value_); | 2159 writer->Write<RawObject*>(ptr()->value_); |
2099 } | 2160 } |
2100 | 2161 |
2101 } // namespace dart | 2162 } // namespace dart |
OLD | NEW |