| OLD | NEW |
| 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 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 ObjectKind kind = reader->Read<ObjectKind>(); | 35 ObjectKind kind = reader->Read<ObjectKind>(); |
| 36 | 36 |
| 37 // Allocate class object of specified kind. | 37 // Allocate class object of specified kind. |
| 38 cls = Class::GetClass(kind); | 38 cls = Class::GetClass(kind); |
| 39 reader->AddBackwardReference(object_id, &cls); | 39 reader->AddBackwardReference(object_id, &cls); |
| 40 | 40 |
| 41 // Set the object tags. | 41 // Set the object tags. |
| 42 cls.set_tags(tags); | 42 cls.set_tags(tags); |
| 43 | 43 |
| 44 // Set all non object fields. | 44 // Set all non object fields. |
| 45 cls.set_instance_size(reader->Read<intptr_t>()); | 45 cls.set_instance_size(reader->ReadIntptrValue()); |
| 46 cls.set_type_arguments_instance_field_offset(reader->Read<intptr_t>()); | 46 cls.set_type_arguments_instance_field_offset(reader->ReadIntptrValue()); |
| 47 cls.set_next_field_offset(reader->Read<intptr_t>()); | 47 cls.set_next_field_offset(reader->ReadIntptrValue()); |
| 48 cls.set_num_native_fields(reader->Read<intptr_t>()); | 48 cls.set_num_native_fields(reader->ReadIntptrValue()); |
| 49 cls.set_class_state(reader->Read<int8_t>()); | 49 cls.set_class_state(reader->Read<int8_t>()); |
| 50 if (reader->Read<bool>()) { | 50 if (reader->Read<bool>()) { |
| 51 cls.set_is_const(); | 51 cls.set_is_const(); |
| 52 } | 52 } |
| 53 if (reader->Read<bool>()) { | 53 if (reader->Read<bool>()) { |
| 54 cls.set_is_interface(); | 54 cls.set_is_interface(); |
| 55 } | 55 } |
| 56 | 56 |
| 57 // Set all the object fields. | 57 // Set all the object fields. |
| 58 // TODO(5411462): Need to assert No GC can happen here, even though | 58 // TODO(5411462): Need to assert No GC can happen here, even though |
| (...skipping 18 matching lines...) Expand all Loading... |
| 77 writer->WriteSerializationMarker(kInlined, object_id); | 77 writer->WriteSerializationMarker(kInlined, object_id); |
| 78 | 78 |
| 79 if ((kind == Snapshot::kFull) || | 79 if ((kind == Snapshot::kFull) || |
| 80 (kind == Snapshot::kScript && !IsCreatedFromSnapshot())) { | 80 (kind == Snapshot::kScript && !IsCreatedFromSnapshot())) { |
| 81 // Write out the class and tags information. | 81 // Write out the class and tags information. |
| 82 writer->WriteObjectHeader(Object::kClassClass, ptr()->tags_); | 82 writer->WriteObjectHeader(Object::kClassClass, ptr()->tags_); |
| 83 | 83 |
| 84 // Write out all the non object pointer fields. | 84 // Write out all the non object pointer fields. |
| 85 // NOTE: cpp_vtable_ is not written. | 85 // NOTE: cpp_vtable_ is not written. |
| 86 writer->Write<ObjectKind>(ptr()->instance_kind_); | 86 writer->Write<ObjectKind>(ptr()->instance_kind_); |
| 87 writer->Write<intptr_t>(ptr()->instance_size_); | 87 writer->WriteIntptrValue(ptr()->instance_size_); |
| 88 writer->Write<intptr_t>(ptr()->type_arguments_instance_field_offset_); | 88 writer->WriteIntptrValue(ptr()->type_arguments_instance_field_offset_); |
| 89 writer->Write<intptr_t>(ptr()->next_field_offset_); | 89 writer->WriteIntptrValue(ptr()->next_field_offset_); |
| 90 writer->Write<intptr_t>(ptr()->num_native_fields_); | 90 writer->WriteIntptrValue(ptr()->num_native_fields_); |
| 91 writer->Write<int8_t>(ptr()->class_state_); | 91 writer->Write<int8_t>(ptr()->class_state_); |
| 92 writer->Write<bool>(ptr()->is_const_); | 92 writer->Write<bool>(ptr()->is_const_); |
| 93 writer->Write<bool>(ptr()->is_interface_); | 93 writer->Write<bool>(ptr()->is_interface_); |
| 94 | 94 |
| 95 // Write out all the object pointer fields. | 95 // Write out all the object pointer fields. |
| 96 SnapshotWriterVisitor visitor(writer); | 96 SnapshotWriterVisitor visitor(writer); |
| 97 visitor.VisitPointers(from(), to()); | 97 visitor.VisitPointers(from(), to()); |
| 98 } else { | 98 } else { |
| 99 writer->WriteClassId(this); | 99 writer->WriteClassId(this); |
| 100 } | 100 } |
| 101 } | 101 } |
| 102 | 102 |
| 103 | 103 |
| 104 RawUnresolvedClass* UnresolvedClass::ReadFrom(SnapshotReader* reader, | 104 RawUnresolvedClass* UnresolvedClass::ReadFrom(SnapshotReader* reader, |
| 105 intptr_t object_id, | 105 intptr_t object_id, |
| 106 intptr_t tags, | 106 intptr_t tags, |
| 107 Snapshot::Kind kind) { | 107 Snapshot::Kind kind) { |
| 108 ASSERT(reader != NULL); | 108 ASSERT(reader != NULL); |
| 109 | 109 |
| 110 // Allocate parameterized type object. | 110 // Allocate parameterized type object. |
| 111 UnresolvedClass& unresolved_class = | 111 UnresolvedClass& unresolved_class = |
| 112 UnresolvedClass::ZoneHandle(UnresolvedClass::New()); | 112 UnresolvedClass::ZoneHandle(UnresolvedClass::New()); |
| 113 reader->AddBackwardReference(object_id, &unresolved_class); | 113 reader->AddBackwardReference(object_id, &unresolved_class); |
| 114 | 114 |
| 115 // Set the object tags. | 115 // Set the object tags. |
| 116 unresolved_class.set_tags(tags); | 116 unresolved_class.set_tags(tags); |
| 117 | 117 |
| 118 // Set all non object fields. | 118 // Set all non object fields. |
| 119 unresolved_class.set_token_index(reader->Read<intptr_t>()); | 119 unresolved_class.set_token_index(reader->ReadIntptrValue()); |
| 120 | 120 |
| 121 // Set all the object fields. | 121 // Set all the object fields. |
| 122 // TODO(5411462): Need to assert No GC can happen here, even though | 122 // TODO(5411462): Need to assert No GC can happen here, even though |
| 123 // allocations may happen. | 123 // allocations may happen. |
| 124 intptr_t num_flds = (unresolved_class.raw()->to() - | 124 intptr_t num_flds = (unresolved_class.raw()->to() - |
| 125 unresolved_class.raw()->from()); | 125 unresolved_class.raw()->from()); |
| 126 for (intptr_t i = 0; i <= num_flds; i++) { | 126 for (intptr_t i = 0; i <= num_flds; i++) { |
| 127 *(unresolved_class.raw()->from() + i) = reader->ReadObject(); | 127 *(unresolved_class.raw()->from() + i) = reader->ReadObject(); |
| 128 } | 128 } |
| 129 return unresolved_class.raw(); | 129 return unresolved_class.raw(); |
| 130 } | 130 } |
| 131 | 131 |
| 132 | 132 |
| 133 void RawUnresolvedClass::WriteTo(SnapshotWriter* writer, | 133 void RawUnresolvedClass::WriteTo(SnapshotWriter* writer, |
| 134 intptr_t object_id, | 134 intptr_t object_id, |
| 135 Snapshot::Kind kind) { | 135 Snapshot::Kind kind) { |
| 136 ASSERT(writer != NULL); | 136 ASSERT(writer != NULL); |
| 137 | 137 |
| 138 // Write out the serialization header value for this object. | 138 // Write out the serialization header value for this object. |
| 139 writer->WriteSerializationMarker(kInlined, object_id); | 139 writer->WriteSerializationMarker(kInlined, object_id); |
| 140 | 140 |
| 141 // Write out the class and tags information. | 141 // Write out the class and tags information. |
| 142 writer->WriteObjectHeader(Object::kUnresolvedClassClass, ptr()->tags_); | 142 writer->WriteObjectHeader(Object::kUnresolvedClassClass, ptr()->tags_); |
| 143 | 143 |
| 144 // Write out all the non object pointer fields. | 144 // Write out all the non object pointer fields. |
| 145 writer->Write<intptr_t>(ptr()->token_index_); | 145 writer->WriteIntptrValue(ptr()->token_index_); |
| 146 | 146 |
| 147 // Write out all the object pointer fields. | 147 // Write out all the object pointer fields. |
| 148 SnapshotWriterVisitor visitor(writer); | 148 SnapshotWriterVisitor visitor(writer); |
| 149 visitor.VisitPointers(from(), to()); | 149 visitor.VisitPointers(from(), to()); |
| 150 } | 150 } |
| 151 | 151 |
| 152 | 152 |
| 153 RawAbstractType* AbstractType::ReadFrom(SnapshotReader* reader, | 153 RawAbstractType* AbstractType::ReadFrom(SnapshotReader* reader, |
| 154 intptr_t object_id, | 154 intptr_t object_id, |
| 155 intptr_t tags, | 155 intptr_t tags, |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 | 227 |
| 228 // Allocate type parameter object. | 228 // Allocate type parameter object. |
| 229 TypeParameter& type_parameter = | 229 TypeParameter& type_parameter = |
| 230 TypeParameter::ZoneHandle(TypeParameter::New()); | 230 TypeParameter::ZoneHandle(TypeParameter::New()); |
| 231 reader->AddBackwardReference(object_id, &type_parameter); | 231 reader->AddBackwardReference(object_id, &type_parameter); |
| 232 | 232 |
| 233 // Set the object tags. | 233 // Set the object tags. |
| 234 type_parameter.set_tags(tags); | 234 type_parameter.set_tags(tags); |
| 235 | 235 |
| 236 // Set all non object fields. | 236 // Set all non object fields. |
| 237 type_parameter.set_index(reader->Read<intptr_t>()); | 237 type_parameter.set_index(reader->ReadIntptrValue()); |
| 238 type_parameter.set_type_state(reader->Read<int8_t>()); | 238 type_parameter.set_type_state(reader->Read<int8_t>()); |
| 239 | 239 |
| 240 // Set all the object fields. | 240 // Set all the object fields. |
| 241 // TODO(5411462): Need to assert No GC can happen here, even though | 241 // TODO(5411462): Need to assert No GC can happen here, even though |
| 242 // allocations may happen. | 242 // allocations may happen. |
| 243 intptr_t num_flds = (type_parameter.raw()->to() - | 243 intptr_t num_flds = (type_parameter.raw()->to() - |
| 244 type_parameter.raw()->from()); | 244 type_parameter.raw()->from()); |
| 245 for (intptr_t i = 0; i <= num_flds; i++) { | 245 for (intptr_t i = 0; i <= num_flds; i++) { |
| 246 *(type_parameter.raw()->from() + i) = reader->ReadObject(); | 246 *(type_parameter.raw()->from() + i) = reader->ReadObject(); |
| 247 } | 247 } |
| 248 | 248 |
| 249 return type_parameter.raw(); | 249 return type_parameter.raw(); |
| 250 } | 250 } |
| 251 | 251 |
| 252 | 252 |
| 253 void RawTypeParameter::WriteTo(SnapshotWriter* writer, | 253 void RawTypeParameter::WriteTo(SnapshotWriter* writer, |
| 254 intptr_t object_id, | 254 intptr_t object_id, |
| 255 Snapshot::Kind kind) { | 255 Snapshot::Kind kind) { |
| 256 ASSERT(writer != NULL); | 256 ASSERT(writer != NULL); |
| 257 | 257 |
| 258 // Write out the serialization header value for this object. | 258 // Write out the serialization header value for this object. |
| 259 writer->WriteSerializationMarker(kInlined, object_id); | 259 writer->WriteSerializationMarker(kInlined, object_id); |
| 260 | 260 |
| 261 // Write out the class and tags information. | 261 // Write out the class and tags information. |
| 262 writer->WriteObjectHeader(Object::kTypeParameterClass, ptr()->tags_); | 262 writer->WriteObjectHeader(Object::kTypeParameterClass, ptr()->tags_); |
| 263 | 263 |
| 264 // Write out all the non object pointer fields. | 264 // Write out all the non object pointer fields. |
| 265 writer->Write<intptr_t>(ptr()->index_); | 265 writer->WriteIntptrValue(ptr()->index_); |
| 266 writer->Write<int8_t>(ptr()->type_state_); | 266 writer->Write<int8_t>(ptr()->type_state_); |
| 267 | 267 |
| 268 // Write out all the object pointer fields. | 268 // Write out all the object pointer fields. |
| 269 SnapshotWriterVisitor visitor(writer); | 269 SnapshotWriterVisitor visitor(writer); |
| 270 visitor.VisitPointers(from(), to()); | 270 visitor.VisitPointers(from(), to()); |
| 271 } | 271 } |
| 272 | 272 |
| 273 | 273 |
| 274 RawInstantiatedType* InstantiatedType::ReadFrom(SnapshotReader* reader, | 274 RawInstantiatedType* InstantiatedType::ReadFrom(SnapshotReader* reader, |
| 275 intptr_t object_id, | 275 intptr_t object_id, |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 } | 333 } |
| 334 | 334 |
| 335 | 335 |
| 336 RawTypeArguments* TypeArguments::ReadFrom(SnapshotReader* reader, | 336 RawTypeArguments* TypeArguments::ReadFrom(SnapshotReader* reader, |
| 337 intptr_t object_id, | 337 intptr_t object_id, |
| 338 intptr_t tags, | 338 intptr_t tags, |
| 339 Snapshot::Kind kind) { | 339 Snapshot::Kind kind) { |
| 340 ASSERT(reader != NULL); | 340 ASSERT(reader != NULL); |
| 341 | 341 |
| 342 // Read the length so that we can determine instance size to allocate. | 342 // Read the length so that we can determine instance size to allocate. |
| 343 RawSmi* smi_len = GetSmi(reader->Read<intptr_t>()); | 343 RawSmi* smi_len = GetSmi(reader->ReadIntptrValue()); |
| 344 intptr_t len = Smi::Value(smi_len); | 344 intptr_t len = Smi::Value(smi_len); |
| 345 | 345 |
| 346 TypeArguments& type_arguments = | 346 TypeArguments& type_arguments = |
| 347 TypeArguments::Handle(TypeArguments::New(len)); | 347 TypeArguments::Handle(TypeArguments::New(len)); |
| 348 reader->AddBackwardReference(object_id, &type_arguments); | 348 reader->AddBackwardReference(object_id, &type_arguments); |
| 349 | 349 |
| 350 // Now set all the object fields. | 350 // Now set all the object fields. |
| 351 AbstractType& type = AbstractType::Handle(); | 351 AbstractType& type = AbstractType::Handle(); |
| 352 for (intptr_t i = 0; i < len; i++) { | 352 for (intptr_t i = 0; i < len; i++) { |
| 353 type ^= reader->ReadObject(); | 353 type ^= reader->ReadObject(); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 ASSERT(kind != Snapshot::kMessage && !RawObject::IsCreatedFromSnapshot(tags)); | 444 ASSERT(kind != Snapshot::kMessage && !RawObject::IsCreatedFromSnapshot(tags)); |
| 445 | 445 |
| 446 // Allocate function object. | 446 // Allocate function object. |
| 447 Function& func = Function::ZoneHandle(Function::New()); | 447 Function& func = Function::ZoneHandle(Function::New()); |
| 448 reader->AddBackwardReference(object_id, &func); | 448 reader->AddBackwardReference(object_id, &func); |
| 449 | 449 |
| 450 // Set the object tags. | 450 // Set the object tags. |
| 451 func.set_tags(tags); | 451 func.set_tags(tags); |
| 452 | 452 |
| 453 // Set all the non object fields. | 453 // Set all the non object fields. |
| 454 func.set_token_index(reader->Read<intptr_t>()); | 454 func.set_token_index(reader->ReadIntptrValue()); |
| 455 func.set_num_fixed_parameters(reader->Read<intptr_t>()); | 455 func.set_num_fixed_parameters(reader->ReadIntptrValue()); |
| 456 func.set_num_optional_parameters(reader->Read<intptr_t>()); | 456 func.set_num_optional_parameters(reader->ReadIntptrValue()); |
| 457 func.set_invocation_counter(reader->Read<intptr_t>()); | 457 func.set_invocation_counter(reader->ReadIntptrValue()); |
| 458 func.set_deoptimization_counter(reader->Read<intptr_t>()); | 458 func.set_deoptimization_counter(reader->ReadIntptrValue()); |
| 459 func.set_kind(static_cast<RawFunction::Kind >(reader->Read<intptr_t>())); | 459 func.set_kind(static_cast<RawFunction::Kind >(reader->ReadIntptrValue())); |
| 460 func.set_is_static(reader->Read<bool>()); | 460 func.set_is_static(reader->Read<bool>()); |
| 461 func.set_is_const(reader->Read<bool>()); | 461 func.set_is_const(reader->Read<bool>()); |
| 462 func.set_is_optimizable(reader->Read<bool>()); | 462 func.set_is_optimizable(reader->Read<bool>()); |
| 463 | 463 |
| 464 // Set all the object fields. | 464 // Set all the object fields. |
| 465 // TODO(5411462): Need to assert No GC can happen here, even though | 465 // TODO(5411462): Need to assert No GC can happen here, even though |
| 466 // allocations may happen. | 466 // allocations may happen. |
| 467 intptr_t num_flds = (func.raw()->to() - func.raw()->from()); | 467 intptr_t num_flds = (func.raw()->to() - func.raw()->from()); |
| 468 for (intptr_t i = 0; i <= num_flds; i++) { | 468 for (intptr_t i = 0; i <= num_flds; i++) { |
| 469 *(func.raw()->from() + i) = reader->ReadObject(); | 469 *(func.raw()->from() + i) = reader->ReadObject(); |
| 470 } | 470 } |
| 471 | 471 |
| 472 return func.raw(); | 472 return func.raw(); |
| 473 } | 473 } |
| 474 | 474 |
| 475 | 475 |
| 476 void RawFunction::WriteTo(SnapshotWriter* writer, | 476 void RawFunction::WriteTo(SnapshotWriter* writer, |
| 477 intptr_t object_id, | 477 intptr_t object_id, |
| 478 Snapshot::Kind kind) { | 478 Snapshot::Kind kind) { |
| 479 ASSERT(writer != NULL); | 479 ASSERT(writer != NULL); |
| 480 ASSERT(kind != Snapshot::kMessage && !IsCreatedFromSnapshot()); | 480 ASSERT(kind != Snapshot::kMessage && !IsCreatedFromSnapshot()); |
| 481 | 481 |
| 482 // Write out the serialization header value for this object. | 482 // Write out the serialization header value for this object. |
| 483 writer->WriteSerializationMarker(kInlined, object_id); | 483 writer->WriteSerializationMarker(kInlined, object_id); |
| 484 | 484 |
| 485 // Write out the class and tags information. | 485 // Write out the class and tags information. |
| 486 writer->WriteObjectHeader(Object::kFunctionClass, ptr()->tags_); | 486 writer->WriteObjectHeader(Object::kFunctionClass, ptr()->tags_); |
| 487 | 487 |
| 488 // Write out all the non object fields. | 488 // Write out all the non object fields. |
| 489 writer->Write<intptr_t>(ptr()->token_index_); | 489 writer->WriteIntptrValue(ptr()->token_index_); |
| 490 writer->Write<intptr_t>(ptr()->num_fixed_parameters_); | 490 writer->WriteIntptrValue(ptr()->num_fixed_parameters_); |
| 491 writer->Write<intptr_t>(ptr()->num_optional_parameters_); | 491 writer->WriteIntptrValue(ptr()->num_optional_parameters_); |
| 492 writer->Write<intptr_t>(ptr()->invocation_counter_); | 492 writer->WriteIntptrValue(ptr()->invocation_counter_); |
| 493 writer->Write<intptr_t>(ptr()->deoptimization_counter_); | 493 writer->WriteIntptrValue(ptr()->deoptimization_counter_); |
| 494 writer->Write<intptr_t>(ptr()->kind_); | 494 writer->WriteIntptrValue(ptr()->kind_); |
| 495 writer->Write<bool>(ptr()->is_static_); | 495 writer->Write<bool>(ptr()->is_static_); |
| 496 writer->Write<bool>(ptr()->is_const_); | 496 writer->Write<bool>(ptr()->is_const_); |
| 497 writer->Write<bool>(ptr()->is_optimizable_); | 497 writer->Write<bool>(ptr()->is_optimizable_); |
| 498 | 498 |
| 499 // Write out all the object pointer fields. | 499 // Write out all the object pointer fields. |
| 500 SnapshotWriterVisitor visitor(writer); | 500 SnapshotWriterVisitor visitor(writer); |
| 501 visitor.VisitPointers(from(), to()); | 501 visitor.VisitPointers(from(), to()); |
| 502 } | 502 } |
| 503 | 503 |
| 504 | 504 |
| 505 RawField* Field::ReadFrom(SnapshotReader* reader, | 505 RawField* Field::ReadFrom(SnapshotReader* reader, |
| 506 intptr_t object_id, | 506 intptr_t object_id, |
| 507 intptr_t tags, | 507 intptr_t tags, |
| 508 Snapshot::Kind kind) { | 508 Snapshot::Kind kind) { |
| 509 ASSERT(reader != NULL); | 509 ASSERT(reader != NULL); |
| 510 ASSERT(kind != Snapshot::kMessage && !RawObject::IsCreatedFromSnapshot(tags)); | 510 ASSERT(kind != Snapshot::kMessage && !RawObject::IsCreatedFromSnapshot(tags)); |
| 511 | 511 |
| 512 // Allocate field object. | 512 // Allocate field object. |
| 513 Field& field = Field::ZoneHandle(Field::New()); | 513 Field& field = Field::ZoneHandle(Field::New()); |
| 514 reader->AddBackwardReference(object_id, &field); | 514 reader->AddBackwardReference(object_id, &field); |
| 515 | 515 |
| 516 // Set the object tags. | 516 // Set the object tags. |
| 517 field.set_tags(tags); | 517 field.set_tags(tags); |
| 518 | 518 |
| 519 // Set all non object fields. | 519 // Set all non object fields. |
| 520 field.set_token_index(reader->Read<intptr_t>()); | 520 field.set_token_index(reader->ReadIntptrValue()); |
| 521 field.set_is_static(reader->Read<bool>()); | 521 field.set_is_static(reader->Read<bool>()); |
| 522 field.set_is_final(reader->Read<bool>()); | 522 field.set_is_final(reader->Read<bool>()); |
| 523 field.set_has_initializer(reader->Read<bool>()); | 523 field.set_has_initializer(reader->Read<bool>()); |
| 524 | 524 |
| 525 // Set all the object fields. | 525 // Set all the object fields. |
| 526 // TODO(5411462): Need to assert No GC can happen here, even though | 526 // TODO(5411462): Need to assert No GC can happen here, even though |
| 527 // allocations may happen. | 527 // allocations may happen. |
| 528 intptr_t num_flds = (field.raw()->to() - field.raw()->from()); | 528 intptr_t num_flds = (field.raw()->to() - field.raw()->from()); |
| 529 for (intptr_t i = 0; i <= num_flds; i++) { | 529 for (intptr_t i = 0; i <= num_flds; i++) { |
| 530 *(field.raw()->from() + i) = reader->ReadObject(); | 530 *(field.raw()->from() + i) = reader->ReadObject(); |
| 531 } | 531 } |
| 532 | 532 |
| 533 return field.raw(); | 533 return field.raw(); |
| 534 } | 534 } |
| 535 | 535 |
| 536 | 536 |
| 537 void RawField::WriteTo(SnapshotWriter* writer, | 537 void RawField::WriteTo(SnapshotWriter* writer, |
| 538 intptr_t object_id, | 538 intptr_t object_id, |
| 539 Snapshot::Kind kind) { | 539 Snapshot::Kind kind) { |
| 540 ASSERT(writer != NULL); | 540 ASSERT(writer != NULL); |
| 541 ASSERT(kind != Snapshot::kMessage && !IsCreatedFromSnapshot()); | 541 ASSERT(kind != Snapshot::kMessage && !IsCreatedFromSnapshot()); |
| 542 | 542 |
| 543 // Write out the serialization header value for this object. | 543 // Write out the serialization header value for this object. |
| 544 writer->WriteSerializationMarker(kInlined, object_id); | 544 writer->WriteSerializationMarker(kInlined, object_id); |
| 545 | 545 |
| 546 // Write out the class and tags information. | 546 // Write out the class and tags information. |
| 547 writer->WriteObjectHeader(Object::kFieldClass, ptr()->tags_); | 547 writer->WriteObjectHeader(Object::kFieldClass, ptr()->tags_); |
| 548 | 548 |
| 549 // Write out all the non object fields. | 549 // Write out all the non object fields. |
| 550 writer->Write<intptr_t>(ptr()->token_index_); | 550 writer->WriteIntptrValue(ptr()->token_index_); |
| 551 writer->Write<bool>(ptr()->is_static_); | 551 writer->Write<bool>(ptr()->is_static_); |
| 552 writer->Write<bool>(ptr()->is_final_); | 552 writer->Write<bool>(ptr()->is_final_); |
| 553 writer->Write<bool>(ptr()->has_initializer_); | 553 writer->Write<bool>(ptr()->has_initializer_); |
| 554 | 554 |
| 555 // Write out all the object pointer fields. | 555 // Write out all the object pointer fields. |
| 556 SnapshotWriterVisitor visitor(writer); | 556 SnapshotWriterVisitor visitor(writer); |
| 557 visitor.VisitPointers(from(), to()); | 557 visitor.VisitPointers(from(), to()); |
| 558 } | 558 } |
| 559 | 559 |
| 560 | 560 |
| 561 RawTokenStream* TokenStream::ReadFrom(SnapshotReader* reader, | 561 RawTokenStream* TokenStream::ReadFrom(SnapshotReader* reader, |
| 562 intptr_t object_id, | 562 intptr_t object_id, |
| 563 intptr_t tags, | 563 intptr_t tags, |
| 564 Snapshot::Kind kind) { | 564 Snapshot::Kind kind) { |
| 565 ASSERT(reader != NULL); | 565 ASSERT(reader != NULL); |
| 566 ASSERT(kind != Snapshot::kMessage && !RawObject::IsCreatedFromSnapshot(tags)); | 566 ASSERT(kind != Snapshot::kMessage && !RawObject::IsCreatedFromSnapshot(tags)); |
| 567 | 567 |
| 568 // Read the length so that we can determine number of tokens to read. | 568 // Read the length so that we can determine number of tokens to read. |
| 569 RawSmi* smi_len = GetSmi(reader->Read<intptr_t>()); | 569 RawSmi* smi_len = GetSmi(reader->ReadIntptrValue()); |
| 570 intptr_t len = Smi::Value(smi_len); | 570 intptr_t len = Smi::Value(smi_len); |
| 571 | 571 |
| 572 // Create the token stream object. | 572 // Create the token stream object. |
| 573 TokenStream& token_stream = TokenStream::ZoneHandle(TokenStream::New(len)); | 573 TokenStream& token_stream = TokenStream::ZoneHandle(TokenStream::New(len)); |
| 574 reader->AddBackwardReference(object_id, &token_stream); | 574 reader->AddBackwardReference(object_id, &token_stream); |
| 575 | 575 |
| 576 // Set the object tags. | 576 // Set the object tags. |
| 577 token_stream.set_tags(tags); | 577 token_stream.set_tags(tags); |
| 578 | 578 |
| 579 // Read the token stream into the TokenStream. | 579 // Read the token stream into the TokenStream. |
| 580 String& literal = String::Handle(); | 580 String& literal = String::Handle(); |
| 581 for (intptr_t i = 0; i < len; i++) { | 581 for (intptr_t i = 0; i < len; i++) { |
| 582 Token::Kind kind = static_cast<Token::Kind>( | 582 Token::Kind kind = static_cast<Token::Kind>( |
| 583 Smi::Value(GetSmi(reader->Read<intptr_t>()))); | 583 Smi::Value(GetSmi(reader->ReadIntptrValue()))); |
| 584 literal ^= reader->ReadObject(); | 584 literal ^= reader->ReadObject(); |
| 585 token_stream.SetTokenAt(i, kind, literal); | 585 token_stream.SetTokenAt(i, kind, literal); |
| 586 } | 586 } |
| 587 return token_stream.raw(); | 587 return token_stream.raw(); |
| 588 } | 588 } |
| 589 | 589 |
| 590 | 590 |
| 591 void RawTokenStream::WriteTo(SnapshotWriter* writer, | 591 void RawTokenStream::WriteTo(SnapshotWriter* writer, |
| 592 intptr_t object_id, | 592 intptr_t object_id, |
| 593 Snapshot::Kind kind) { | 593 Snapshot::Kind kind) { |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 673 library_url ^= reader->ReadObject(); | 673 library_url ^= reader->ReadObject(); |
| 674 library = Library::LookupLibrary(library_url); | 674 library = Library::LookupLibrary(library_url); |
| 675 } else { | 675 } else { |
| 676 // Allocate library object. | 676 // Allocate library object. |
| 677 library = Library::New(); | 677 library = Library::New(); |
| 678 | 678 |
| 679 // Set the object tags. | 679 // Set the object tags. |
| 680 library.set_tags(tags); | 680 library.set_tags(tags); |
| 681 | 681 |
| 682 // Set all non object fields. | 682 // Set all non object fields. |
| 683 library.raw_ptr()->num_imports_ = reader->Read<intptr_t>(); | 683 library.raw_ptr()->num_imports_ = reader->ReadIntptrValue(); |
| 684 library.raw_ptr()->num_imported_into_ = reader->Read<intptr_t>(); | 684 library.raw_ptr()->num_imported_into_ = reader->ReadIntptrValue(); |
| 685 library.raw_ptr()->num_anonymous_ = reader->Read<intptr_t>(); | 685 library.raw_ptr()->num_anonymous_ = reader->ReadIntptrValue(); |
| 686 library.raw_ptr()->corelib_imported_ = reader->Read<bool>(); | 686 library.raw_ptr()->corelib_imported_ = reader->Read<bool>(); |
| 687 library.raw_ptr()->load_state_ = reader->Read<int8_t>(); | 687 library.raw_ptr()->load_state_ = reader->Read<int8_t>(); |
| 688 // The native resolver is not serialized. | 688 // The native resolver is not serialized. |
| 689 Dart_NativeEntryResolver resolver = | 689 Dart_NativeEntryResolver resolver = |
| 690 reader->Read<Dart_NativeEntryResolver>(); | 690 reader->Read<Dart_NativeEntryResolver>(); |
| 691 ASSERT(resolver == NULL); | 691 ASSERT(resolver == NULL); |
| 692 library.set_native_entry_resolver(resolver); | 692 library.set_native_entry_resolver(resolver); |
| 693 | 693 |
| 694 // Set all the object fields. | 694 // Set all the object fields. |
| 695 // TODO(5411462): Need to assert No GC can happen here, even though | 695 // TODO(5411462): Need to assert No GC can happen here, even though |
| (...skipping 18 matching lines...) Expand all Loading... |
| 714 | 714 |
| 715 // Write out the class and tags information. | 715 // Write out the class and tags information. |
| 716 writer->WriteObjectHeader(Object::kLibraryClass, ptr()->tags_); | 716 writer->WriteObjectHeader(Object::kLibraryClass, ptr()->tags_); |
| 717 | 717 |
| 718 if (IsCreatedFromSnapshot()) { | 718 if (IsCreatedFromSnapshot()) { |
| 719 ASSERT(kind != Snapshot::kFull); | 719 ASSERT(kind != Snapshot::kFull); |
| 720 // Write out library URL so that it can be looked up when reading. | 720 // Write out library URL so that it can be looked up when reading. |
| 721 writer->WriteObject(ptr()->url_); | 721 writer->WriteObject(ptr()->url_); |
| 722 } else { | 722 } else { |
| 723 // Write out all non object fields. | 723 // Write out all non object fields. |
| 724 writer->Write<intptr_t>(ptr()->num_imports_); | 724 writer->WriteIntptrValue(ptr()->num_imports_); |
| 725 writer->Write<intptr_t>(ptr()->num_imported_into_); | 725 writer->WriteIntptrValue(ptr()->num_imported_into_); |
| 726 writer->Write<intptr_t>(ptr()->num_anonymous_); | 726 writer->WriteIntptrValue(ptr()->num_anonymous_); |
| 727 writer->Write<bool>(ptr()->corelib_imported_); | 727 writer->Write<bool>(ptr()->corelib_imported_); |
| 728 writer->Write<int8_t>(ptr()->load_state_); | 728 writer->Write<int8_t>(ptr()->load_state_); |
| 729 // We do not serialize the native resolver over, this needs to be explicitly | 729 // We do not serialize the native resolver over, this needs to be explicitly |
| 730 // set after deserialization. | 730 // set after deserialization. |
| 731 writer->Write<Dart_NativeEntryResolver>(NULL); | 731 writer->Write<Dart_NativeEntryResolver>(NULL); |
| 732 | 732 |
| 733 // Write out all the object pointer fields. | 733 // Write out all the object pointer fields. |
| 734 SnapshotWriterVisitor visitor(writer); | 734 SnapshotWriterVisitor visitor(writer); |
| 735 visitor.VisitPointers(from(), to()); | 735 visitor.VisitPointers(from(), to()); |
| 736 } | 736 } |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 871 } | 871 } |
| 872 | 872 |
| 873 | 873 |
| 874 RawContext* Context::ReadFrom(SnapshotReader* reader, | 874 RawContext* Context::ReadFrom(SnapshotReader* reader, |
| 875 intptr_t object_id, | 875 intptr_t object_id, |
| 876 intptr_t tags, | 876 intptr_t tags, |
| 877 Snapshot::Kind kind) { | 877 Snapshot::Kind kind) { |
| 878 ASSERT(reader != NULL); | 878 ASSERT(reader != NULL); |
| 879 | 879 |
| 880 // Allocate context object. | 880 // Allocate context object. |
| 881 intptr_t num_vars = reader->Read<intptr_t>(); | 881 intptr_t num_vars = reader->ReadIntptrValue(); |
| 882 Context& context = Context::ZoneHandle( | 882 Context& context = Context::ZoneHandle( |
| 883 Context::New(num_vars, | 883 Context::New(num_vars, |
| 884 (kind == Snapshot::kFull) ? Heap::kOld : Heap::kNew)); | 884 (kind == Snapshot::kFull) ? Heap::kOld : Heap::kNew)); |
| 885 reader->AddBackwardReference(object_id, &context); | 885 reader->AddBackwardReference(object_id, &context); |
| 886 | 886 |
| 887 // Set the object tags. | 887 // Set the object tags. |
| 888 context.set_tags(tags); | 888 context.set_tags(tags); |
| 889 | 889 |
| 890 // Set the isolate implicitly. | 890 // Set the isolate implicitly. |
| 891 context.set_isolate(Isolate::Current()); | 891 context.set_isolate(Isolate::Current()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 907 Snapshot::Kind kind) { | 907 Snapshot::Kind kind) { |
| 908 ASSERT(writer != NULL); | 908 ASSERT(writer != NULL); |
| 909 | 909 |
| 910 // Write out the serialization header value for this object. | 910 // Write out the serialization header value for this object. |
| 911 writer->WriteSerializationMarker(kInlined, object_id); | 911 writer->WriteSerializationMarker(kInlined, object_id); |
| 912 | 912 |
| 913 // Write out the class and tags information. | 913 // Write out the class and tags information. |
| 914 writer->WriteObjectHeader(Object::kContextClass, ptr()->tags_); | 914 writer->WriteObjectHeader(Object::kContextClass, ptr()->tags_); |
| 915 | 915 |
| 916 // Write out num of variables in the context. | 916 // Write out num of variables in the context. |
| 917 writer->Write<intptr_t>(ptr()->num_variables_); | 917 writer->WriteIntptrValue(ptr()->num_variables_); |
| 918 | 918 |
| 919 // Can't serialize the isolate pointer, we set it implicitly on read. | 919 // Can't serialize the isolate pointer, we set it implicitly on read. |
| 920 | 920 |
| 921 // Write out all the object pointer fields. | 921 // Write out all the object pointer fields. |
| 922 SnapshotWriterVisitor visitor(writer); | 922 SnapshotWriterVisitor visitor(writer); |
| 923 visitor.VisitPointers(from(), to(ptr()->num_variables_)); | 923 visitor.VisitPointers(from(), to(ptr()->num_variables_)); |
| 924 } | 924 } |
| 925 | 925 |
| 926 | 926 |
| 927 RawContextScope* ContextScope::ReadFrom(SnapshotReader* reader, | 927 RawContextScope* ContextScope::ReadFrom(SnapshotReader* reader, |
| 928 intptr_t object_id, | 928 intptr_t object_id, |
| 929 intptr_t tags, | 929 intptr_t tags, |
| 930 Snapshot::Kind kind) { | 930 Snapshot::Kind kind) { |
| 931 ASSERT(reader != NULL); | 931 ASSERT(reader != NULL); |
| 932 ASSERT(kind == Snapshot::kMessage); | 932 ASSERT(kind == Snapshot::kMessage); |
| 933 | 933 |
| 934 // Allocate context scope object. | 934 // Allocate context scope object. |
| 935 intptr_t num_vars = reader->Read<intptr_t>(); | 935 intptr_t num_vars = reader->ReadIntptrValue(); |
| 936 ContextScope& scope = ContextScope::ZoneHandle(ContextScope::New(num_vars)); | 936 ContextScope& scope = ContextScope::ZoneHandle(ContextScope::New(num_vars)); |
| 937 reader->AddBackwardReference(object_id, &scope); | 937 reader->AddBackwardReference(object_id, &scope); |
| 938 | 938 |
| 939 // Set the object tags. | 939 // Set the object tags. |
| 940 scope.set_tags(tags); | 940 scope.set_tags(tags); |
| 941 | 941 |
| 942 // Set all the object fields. | 942 // Set all the object fields. |
| 943 // TODO(5411462): Need to assert No GC can happen here, even though | 943 // TODO(5411462): Need to assert No GC can happen here, even though |
| 944 // allocations may happen. | 944 // allocations may happen. |
| 945 intptr_t num_flds = (scope.raw()->to(num_vars) - scope.raw()->from()); | 945 intptr_t num_flds = (scope.raw()->to(num_vars) - scope.raw()->from()); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 957 ASSERT(writer != NULL); | 957 ASSERT(writer != NULL); |
| 958 ASSERT(kind == Snapshot::kMessage); | 958 ASSERT(kind == Snapshot::kMessage); |
| 959 | 959 |
| 960 // Write out the serialization header value for this object. | 960 // Write out the serialization header value for this object. |
| 961 writer->WriteSerializationMarker(kInlined, object_id); | 961 writer->WriteSerializationMarker(kInlined, object_id); |
| 962 | 962 |
| 963 // Write out the class and tags information. | 963 // Write out the class and tags information. |
| 964 writer->WriteObjectHeader(Object::kContextScopeClass, ptr()->tags_); | 964 writer->WriteObjectHeader(Object::kContextScopeClass, ptr()->tags_); |
| 965 | 965 |
| 966 // Serialize number of variables. | 966 // Serialize number of variables. |
| 967 writer->Write<intptr_t>(ptr()->num_variables_); | 967 writer->WriteIntptrValue(ptr()->num_variables_); |
| 968 | 968 |
| 969 // Write out all the object pointer fields. | 969 // Write out all the object pointer fields. |
| 970 SnapshotWriterVisitor visitor(writer); | 970 SnapshotWriterVisitor visitor(writer); |
| 971 visitor.VisitPointers(from(), to(ptr()->num_variables_)); | 971 visitor.VisitPointers(from(), to(ptr()->num_variables_)); |
| 972 } | 972 } |
| 973 | 973 |
| 974 | 974 |
| 975 RawUnhandledException* UnhandledException::ReadFrom(SnapshotReader* reader, | 975 RawUnhandledException* UnhandledException::ReadFrom(SnapshotReader* reader, |
| 976 intptr_t object_id, | 976 intptr_t object_id, |
| 977 intptr_t tags, | 977 intptr_t tags, |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1062 } | 1062 } |
| 1063 | 1063 |
| 1064 | 1064 |
| 1065 RawBigint* Bigint::ReadFrom(SnapshotReader* reader, | 1065 RawBigint* Bigint::ReadFrom(SnapshotReader* reader, |
| 1066 intptr_t object_id, | 1066 intptr_t object_id, |
| 1067 intptr_t tags, | 1067 intptr_t tags, |
| 1068 Snapshot::Kind kind) { | 1068 Snapshot::Kind kind) { |
| 1069 ASSERT(reader != NULL); | 1069 ASSERT(reader != NULL); |
| 1070 | 1070 |
| 1071 // Read in the HexCString representation of the bigint. | 1071 // Read in the HexCString representation of the bigint. |
| 1072 intptr_t len = reader->Read<intptr_t>(); | 1072 intptr_t len = reader->ReadIntptrValue(); |
| 1073 char* str = reinterpret_cast<char*>(ZoneAllocator(len + 1)); | 1073 char* str = reinterpret_cast<char*>(ZoneAllocator(len + 1)); |
| 1074 str[len] = '\0'; | 1074 str[len] = '\0'; |
| 1075 for (intptr_t i = 0; i < len; i++) { | 1075 for (intptr_t i = 0; i < len; i++) { |
| 1076 str[i] = reader->Read<uint8_t>(); | 1076 str[i] = reader->Read<uint8_t>(); |
| 1077 } | 1077 } |
| 1078 | 1078 |
| 1079 // Create a Bigint object from HexCString. | 1079 // Create a Bigint object from HexCString. |
| 1080 Bigint& obj = Bigint::ZoneHandle(BigintOperations::FromHexCString(str)); | 1080 Bigint& obj = Bigint::ZoneHandle(BigintOperations::FromHexCString(str)); |
| 1081 | 1081 |
| 1082 // If it is a canonical constant make it one. | 1082 // If it is a canonical constant make it one. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1100 // Write out the serialization header value for this object. | 1100 // Write out the serialization header value for this object. |
| 1101 writer->WriteSerializationMarker(kInlined, object_id); | 1101 writer->WriteSerializationMarker(kInlined, object_id); |
| 1102 | 1102 |
| 1103 // Write out the class and tags information. | 1103 // Write out the class and tags information. |
| 1104 writer->WriteObjectHeader(ObjectStore::kBigintClass, ptr()->tags_); | 1104 writer->WriteObjectHeader(ObjectStore::kBigintClass, ptr()->tags_); |
| 1105 | 1105 |
| 1106 // Write out the bigint value as a HEXCstring. | 1106 // Write out the bigint value as a HEXCstring. |
| 1107 ptr()->bn_.d = ptr()->data_; | 1107 ptr()->bn_.d = ptr()->data_; |
| 1108 const char* str = BigintOperations::ToHexCString(&ptr()->bn_, &ZoneAllocator); | 1108 const char* str = BigintOperations::ToHexCString(&ptr()->bn_, &ZoneAllocator); |
| 1109 intptr_t len = strlen(str); | 1109 intptr_t len = strlen(str); |
| 1110 writer->Write<intptr_t>(len-2); | 1110 writer->WriteIntptrValue(len-2); |
| 1111 for (intptr_t i = 2; i < len; i++) { | 1111 for (intptr_t i = 2; i < len; i++) { |
| 1112 writer->Write<uint8_t>(str[i]); | 1112 writer->Write<uint8_t>(str[i]); |
| 1113 } | 1113 } |
| 1114 } | 1114 } |
| 1115 | 1115 |
| 1116 | 1116 |
| 1117 RawDouble* Double::ReadFrom(SnapshotReader* reader, | 1117 RawDouble* Double::ReadFrom(SnapshotReader* reader, |
| 1118 intptr_t object_id, | 1118 intptr_t object_id, |
| 1119 intptr_t tags, | 1119 intptr_t tags, |
| 1120 Snapshot::Kind kind) { | 1120 Snapshot::Kind kind) { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1171 } | 1171 } |
| 1172 | 1172 |
| 1173 | 1173 |
| 1174 template<typename HandleType, typename CharacterType> | 1174 template<typename HandleType, typename CharacterType> |
| 1175 RawString* String::ReadFromImpl(SnapshotReader* reader, | 1175 RawString* String::ReadFromImpl(SnapshotReader* reader, |
| 1176 intptr_t object_id, | 1176 intptr_t object_id, |
| 1177 intptr_t tags, | 1177 intptr_t tags, |
| 1178 Snapshot::Kind kind) { | 1178 Snapshot::Kind kind) { |
| 1179 ASSERT(reader != NULL); | 1179 ASSERT(reader != NULL); |
| 1180 // Read the length so that we can determine instance size to allocate. | 1180 // Read the length so that we can determine instance size to allocate. |
| 1181 RawSmi* smi_len = GetSmi(reader->Read<intptr_t>()); | 1181 RawSmi* smi_len = GetSmi(reader->ReadIntptrValue()); |
| 1182 intptr_t len = Smi::Value(smi_len); | 1182 intptr_t len = Smi::Value(smi_len); |
| 1183 RawSmi* smi_hash = GetSmi(reader->Read<intptr_t>()); | 1183 RawSmi* smi_hash = GetSmi(reader->ReadIntptrValue()); |
| 1184 | 1184 |
| 1185 HandleType& str_obj = HandleType::ZoneHandle(); | 1185 HandleType& str_obj = HandleType::ZoneHandle(); |
| 1186 if (kind != Snapshot::kFull && RawObject::IsCanonical(tags)) { | 1186 if (kind != Snapshot::kFull && RawObject::IsCanonical(tags)) { |
| 1187 CharacterType* ptr = reinterpret_cast<CharacterType*>(ZoneAllocator(len)); | 1187 CharacterType* ptr = reinterpret_cast<CharacterType*>(ZoneAllocator(len)); |
| 1188 for (intptr_t i = 0; i < len; i++) { | 1188 for (intptr_t i = 0; i < len; i++) { |
| 1189 ptr[i] = reader->Read<CharacterType>(); | 1189 ptr[i] = reader->Read<CharacterType>(); |
| 1190 } | 1190 } |
| 1191 str_obj ^= String::NewSymbol(ptr, len); | 1191 str_obj ^= String::NewSymbol(ptr, len); |
| 1192 } else { | 1192 } else { |
| 1193 // Set up the string object. | 1193 // Set up the string object. |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1397 | 1397 |
| 1398 | 1398 |
| 1399 template <class T> | 1399 template <class T> |
| 1400 static RawObject* ArrayReadFrom(SnapshotReader* reader, | 1400 static RawObject* ArrayReadFrom(SnapshotReader* reader, |
| 1401 intptr_t object_id, | 1401 intptr_t object_id, |
| 1402 intptr_t tags, | 1402 intptr_t tags, |
| 1403 Snapshot::Kind kind) { | 1403 Snapshot::Kind kind) { |
| 1404 ASSERT(reader != NULL); | 1404 ASSERT(reader != NULL); |
| 1405 | 1405 |
| 1406 // Read the length so that we can determine instance size to allocate. | 1406 // Read the length so that we can determine instance size to allocate. |
| 1407 RawSmi* smi_len = GetSmi(reader->Read<intptr_t>()); | 1407 RawSmi* smi_len = GetSmi(reader->ReadIntptrValue()); |
| 1408 intptr_t len = Smi::Value(smi_len); | 1408 intptr_t len = Smi::Value(smi_len); |
| 1409 T& result = T::Handle( | 1409 T& result = T::Handle( |
| 1410 T::New(len, (kind == Snapshot::kFull) ? Heap::kOld : Heap::kNew)); | 1410 T::New(len, (kind == Snapshot::kFull) ? Heap::kOld : Heap::kNew)); |
| 1411 reader->AddBackwardReference(object_id, &result); | 1411 reader->AddBackwardReference(object_id, &result); |
| 1412 | 1412 |
| 1413 // Set the object tags. | 1413 // Set the object tags. |
| 1414 result.set_tags(tags); | 1414 result.set_tags(tags); |
| 1415 | 1415 |
| 1416 // Setup the object fields. | 1416 // Setup the object fields. |
| 1417 AbstractTypeArguments& type_arguments = AbstractTypeArguments::Handle(); | 1417 AbstractTypeArguments& type_arguments = AbstractTypeArguments::Handle(); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1552 | 1552 |
| 1553 | 1553 |
| 1554 RawJSRegExp* JSRegExp::ReadFrom(SnapshotReader* reader, | 1554 RawJSRegExp* JSRegExp::ReadFrom(SnapshotReader* reader, |
| 1555 intptr_t object_id, | 1555 intptr_t object_id, |
| 1556 intptr_t tags, | 1556 intptr_t tags, |
| 1557 Snapshot::Kind kind) { | 1557 Snapshot::Kind kind) { |
| 1558 ASSERT(reader != NULL); | 1558 ASSERT(reader != NULL); |
| 1559 ASSERT(kind == Snapshot::kMessage); | 1559 ASSERT(kind == Snapshot::kMessage); |
| 1560 | 1560 |
| 1561 // Read the length so that we can determine instance size to allocate. | 1561 // Read the length so that we can determine instance size to allocate. |
| 1562 RawSmi* smi_len = GetSmi(reader->Read<intptr_t>()); | 1562 RawSmi* smi_len = GetSmi(reader->ReadIntptrValue()); |
| 1563 intptr_t len = Smi::Value(smi_len); | 1563 intptr_t len = Smi::Value(smi_len); |
| 1564 | 1564 |
| 1565 // Allocate JSRegExp object. | 1565 // Allocate JSRegExp object. |
| 1566 JSRegExp& regex = JSRegExp::ZoneHandle( | 1566 JSRegExp& regex = JSRegExp::ZoneHandle( |
| 1567 JSRegExp::New(len, (kind == Snapshot::kFull) ? Heap::kOld : Heap::kNew)); | 1567 JSRegExp::New(len, (kind == Snapshot::kFull) ? Heap::kOld : Heap::kNew)); |
| 1568 reader->AddBackwardReference(object_id, ®ex); | 1568 reader->AddBackwardReference(object_id, ®ex); |
| 1569 | 1569 |
| 1570 // Set the object tags. | 1570 // Set the object tags. |
| 1571 regex.set_tags(tags); | 1571 regex.set_tags(tags); |
| 1572 | 1572 |
| 1573 // Read and Set all the other fields. | 1573 // Read and Set all the other fields. |
| 1574 regex.raw_ptr()->num_bracket_expressions_ = GetSmi(reader->Read<intptr_t>()); | 1574 regex.raw_ptr()->num_bracket_expressions_ = GetSmi(reader->ReadIntptrValue()); |
| 1575 String& pattern = String::Handle(); | 1575 String& pattern = String::Handle(); |
| 1576 pattern ^= reader->ReadObject(); | 1576 pattern ^= reader->ReadObject(); |
| 1577 regex.raw_ptr()->pattern_ = pattern.raw(); | 1577 regex.raw_ptr()->pattern_ = pattern.raw(); |
| 1578 regex.raw_ptr()->type_ = reader->Read<intptr_t>(); | 1578 regex.raw_ptr()->type_ = reader->ReadIntptrValue(); |
| 1579 regex.raw_ptr()->flags_ = reader->Read<intptr_t>(); | 1579 regex.raw_ptr()->flags_ = reader->ReadIntptrValue(); |
| 1580 | 1580 |
| 1581 // TODO(5411462): Need to implement a way of recompiling the regex. | 1581 // TODO(5411462): Need to implement a way of recompiling the regex. |
| 1582 | 1582 |
| 1583 return regex.raw(); | 1583 return regex.raw(); |
| 1584 } | 1584 } |
| 1585 | 1585 |
| 1586 | 1586 |
| 1587 void RawJSRegExp::WriteTo(SnapshotWriter* writer, | 1587 void RawJSRegExp::WriteTo(SnapshotWriter* writer, |
| 1588 intptr_t object_id, | 1588 intptr_t object_id, |
| 1589 Snapshot::Kind kind) { | 1589 Snapshot::Kind kind) { |
| 1590 ASSERT(writer != NULL); | 1590 ASSERT(writer != NULL); |
| 1591 ASSERT(kind == Snapshot::kMessage); | 1591 ASSERT(kind == Snapshot::kMessage); |
| 1592 | 1592 |
| 1593 // Write out the serialization header value for this object. | 1593 // Write out the serialization header value for this object. |
| 1594 writer->WriteSerializationMarker(kInlined, object_id); | 1594 writer->WriteSerializationMarker(kInlined, object_id); |
| 1595 | 1595 |
| 1596 // Write out the class and tags information. | 1596 // Write out the class and tags information. |
| 1597 writer->WriteObjectHeader(ObjectStore::kJSRegExpClass, ptr()->tags_); | 1597 writer->WriteObjectHeader(ObjectStore::kJSRegExpClass, ptr()->tags_); |
| 1598 | 1598 |
| 1599 // Write out the data length field. | 1599 // Write out the data length field. |
| 1600 writer->Write<RawObject*>(ptr()->data_length_); | 1600 writer->Write<RawObject*>(ptr()->data_length_); |
| 1601 | 1601 |
| 1602 // Write out all the other fields. | 1602 // Write out all the other fields. |
| 1603 writer->Write<RawObject*>(ptr()->num_bracket_expressions_); | 1603 writer->Write<RawObject*>(ptr()->num_bracket_expressions_); |
| 1604 writer->WriteObject(ptr()->pattern_); | 1604 writer->WriteObject(ptr()->pattern_); |
| 1605 writer->Write<intptr_t>(ptr()->type_); | 1605 writer->WriteIntptrValue(ptr()->type_); |
| 1606 writer->Write<intptr_t>(ptr()->flags_); | 1606 writer->WriteIntptrValue(ptr()->flags_); |
| 1607 | 1607 |
| 1608 // Do not write out the data part which is native. | 1608 // Do not write out the data part which is native. |
| 1609 } | 1609 } |
| 1610 | 1610 |
| 1611 } // namespace dart | 1611 } // namespace dart |
| OLD | NEW |