| 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 } else { | 109 } else { |
| 110 writer->WriteClassId(this); | 110 writer->WriteClassId(this); |
| 111 } | 111 } |
| 112 } | 112 } |
| 113 | 113 |
| 114 | 114 |
| 115 RawUnresolvedClass* UnresolvedClass::ReadFrom(SnapshotReader* reader, | 115 RawUnresolvedClass* UnresolvedClass::ReadFrom(SnapshotReader* reader, |
| 116 intptr_t object_id, | 116 intptr_t object_id, |
| 117 intptr_t tags, | 117 intptr_t tags, |
| 118 Snapshot::Kind kind) { | 118 Snapshot::Kind kind) { |
| 119 UNREACHABLE(); // Only finalized types are written to a snapshot. | 119 ASSERT(reader != NULL); |
| 120 return NULL; | 120 |
| 121 // Allocate parameterized type object. |
| 122 UnresolvedClass& unresolved_class = UnresolvedClass::ZoneHandle( |
| 123 reader->isolate(), NEW_OBJECT(UnresolvedClass)); |
| 124 reader->AddBackRef(object_id, &unresolved_class, kIsDeserialized); |
| 125 |
| 126 // Set the object tags. |
| 127 unresolved_class.set_tags(tags); |
| 128 |
| 129 // Set all non object fields. |
| 130 unresolved_class.set_token_pos(reader->ReadIntptrValue()); |
| 131 |
| 132 // Set all the object fields. |
| 133 // TODO(5411462): Need to assert No GC can happen here, even though |
| 134 // allocations may happen. |
| 135 intptr_t num_flds = (unresolved_class.raw()->to() - |
| 136 unresolved_class.raw()->from()); |
| 137 for (intptr_t i = 0; i <= num_flds; i++) { |
| 138 unresolved_class.StorePointer((unresolved_class.raw()->from() + i), |
| 139 reader->ReadObjectRef()); |
| 140 } |
| 141 return unresolved_class.raw(); |
| 121 } | 142 } |
| 122 | 143 |
| 123 | 144 |
| 124 void RawUnresolvedClass::WriteTo(SnapshotWriter* writer, | 145 void RawUnresolvedClass::WriteTo(SnapshotWriter* writer, |
| 125 intptr_t object_id, | 146 intptr_t object_id, |
| 126 Snapshot::Kind kind) { | 147 Snapshot::Kind kind) { |
| 127 UNREACHABLE(); // Only finalized types are written to a snapshot. | 148 ASSERT(writer != NULL); |
| 128 // Specify --error_on_malformed_type flag for details. | 149 |
| 150 // Write out the serialization header value for this object. |
| 151 writer->WriteInlinedObjectHeader(object_id); |
| 152 |
| 153 // Write out the class and tags information. |
| 154 writer->WriteVMIsolateObject(kUnresolvedClassCid); |
| 155 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
| 156 |
| 157 // Write out all the non object pointer fields. |
| 158 writer->WriteIntptrValue(ptr()->token_pos_); |
| 159 |
| 160 // Write out all the object pointer fields. |
| 161 SnapshotWriterVisitor visitor(writer); |
| 162 visitor.VisitPointers(from(), to()); |
| 129 } | 163 } |
| 130 | 164 |
| 131 | 165 |
| 132 RawAbstractType* AbstractType::ReadFrom(SnapshotReader* reader, | 166 RawAbstractType* AbstractType::ReadFrom(SnapshotReader* reader, |
| 133 intptr_t object_id, | 167 intptr_t object_id, |
| 134 intptr_t tags, | 168 intptr_t tags, |
| 135 Snapshot::Kind kind) { | 169 Snapshot::Kind kind) { |
| 136 UNREACHABLE(); // AbstractType is an abstract class. | 170 UNREACHABLE(); // AbstractType is an abstract class. |
| 137 return NULL; | 171 return NULL; |
| 138 } | 172 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 | 212 |
| 179 return type.raw(); | 213 return type.raw(); |
| 180 } | 214 } |
| 181 | 215 |
| 182 | 216 |
| 183 void RawType::WriteTo(SnapshotWriter* writer, | 217 void RawType::WriteTo(SnapshotWriter* writer, |
| 184 intptr_t object_id, | 218 intptr_t object_id, |
| 185 Snapshot::Kind kind) { | 219 Snapshot::Kind kind) { |
| 186 ASSERT(writer != NULL); | 220 ASSERT(writer != NULL); |
| 187 | 221 |
| 188 // Check that the type is finalized. | |
| 189 // Specify --error_on_malformed_type flag for details in case of error. | |
| 190 ASSERT((ptr()->type_state_ == RawType::kFinalizedInstantiated) || | |
| 191 (ptr()->type_state_ == RawType::kFinalizedUninstantiated)); | |
| 192 | |
| 193 // Write out the serialization header value for this object. | 222 // Write out the serialization header value for this object. |
| 194 writer->WriteInlinedObjectHeader(object_id); | 223 writer->WriteInlinedObjectHeader(object_id); |
| 195 | 224 |
| 196 // Write out the class and tags information. | 225 // Write out the class and tags information. |
| 197 writer->WriteIndexedObject(kTypeCid); | 226 writer->WriteIndexedObject(kTypeCid); |
| 198 writer->WriteIntptrValue(writer->GetObjectTags(this)); | 227 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
| 199 | 228 |
| 200 // Write out all the non object pointer fields. | 229 // Write out all the non object pointer fields. |
| 201 writer->WriteIntptrValue(ptr()->token_pos_); | 230 writer->WriteIntptrValue(ptr()->token_pos_); |
| 202 writer->Write<int8_t>(ptr()->type_state_); | 231 writer->Write<int8_t>(ptr()->type_state_); |
| 203 | 232 |
| 204 // Write out all the object pointer fields. | 233 // Write out all the object pointer fields. |
| 205 SnapshotWriterVisitor visitor(writer); | 234 SnapshotWriterVisitor visitor(writer); |
| 206 visitor.VisitPointers(from(), to()); | 235 visitor.VisitPointers(from(), to()); |
| 207 } | 236 } |
| 208 | 237 |
| 209 | 238 |
| 210 RawTypeParameter* TypeParameter::ReadFrom(SnapshotReader* reader, | 239 RawTypeParameter* TypeParameter::ReadFrom(SnapshotReader* reader, |
| 211 intptr_t object_id, | 240 intptr_t object_id, |
| 212 intptr_t tags, | 241 intptr_t tags, |
| 213 Snapshot::Kind kind) { | 242 Snapshot::Kind kind) { |
| 214 ASSERT(reader != NULL); | 243 ASSERT(reader != NULL); |
| 215 | 244 |
| 216 // Allocate type parameter object. | 245 // Allocate type parameter object. |
| 217 TypeParameter& type_parameter = TypeParameter::ZoneHandle( | 246 TypeParameter& type_parameter = TypeParameter::ZoneHandle( |
| 218 reader->isolate(), NEW_OBJECT(TypeParameter)); | 247 reader->isolate(), NEW_OBJECT(TypeParameter)); |
| 219 reader->AddBackRef(object_id, &type_parameter, kIsDeserialized); | 248 reader->AddBackRef(object_id, &type_parameter, kIsDeserialized); |
| 220 | 249 |
| 221 // Set the object tags. | 250 // Set the object tags. |
| 222 type_parameter.set_tags(tags); | 251 type_parameter.set_tags(tags); |
| 223 | 252 |
| 224 // Set all non object fields. | 253 // Set all non object fields. |
| 225 type_parameter.set_index(reader->ReadIntptrValue()); | 254 type_parameter.set_index(reader->ReadIntptrValue()); |
| 226 type_parameter.set_token_pos(reader->ReadIntptrValue()); | 255 type_parameter.set_token_pos(reader->ReadIntptrValue()); |
| 227 type_parameter.set_type_state(reader->Read<int8_t>()); | 256 type_parameter.set_type_state(reader->Read<int8_t>()); |
| 228 | 257 |
| 229 // Set all the object fields. | 258 // Set all the object fields. |
| 230 // TODO(5411462): Need to assert No GC can happen here, even though | 259 // TODO(5411462): Need to assert No GC can happen here, even though |
| 231 // allocations may happen. | 260 // allocations may happen. |
| 232 intptr_t num_flds = (type_parameter.raw()->to() - | 261 intptr_t num_flds = (type_parameter.raw()->to() - |
| 233 type_parameter.raw()->from()); | 262 type_parameter.raw()->from()); |
| 234 for (intptr_t i = 0; i <= num_flds; i++) { | 263 for (intptr_t i = 0; i <= num_flds; i++) { |
| 235 type_parameter.StorePointer((type_parameter.raw()->from() + i), | 264 type_parameter.StorePointer((type_parameter.raw()->from() + i), |
| 236 reader->ReadObjectRef()); | 265 reader->ReadObjectRef()); |
| 237 } | 266 } |
| 238 | 267 |
| 239 return type_parameter.raw(); | 268 return type_parameter.raw(); |
| 240 } | 269 } |
| 241 | 270 |
| 242 | 271 |
| 243 void RawTypeParameter::WriteTo(SnapshotWriter* writer, | 272 void RawTypeParameter::WriteTo(SnapshotWriter* writer, |
| 244 intptr_t object_id, | 273 intptr_t object_id, |
| 245 Snapshot::Kind kind) { | 274 Snapshot::Kind kind) { |
| 246 ASSERT(writer != NULL); | 275 ASSERT(writer != NULL); |
| 247 | 276 |
| 248 // Check that the type parameter is finalized. | |
| 249 // Specify --error_on_malformed_type flag for details in case of error. | |
| 250 ASSERT(ptr()->type_state_ == RawTypeParameter::kFinalizedUninstantiated); | |
| 251 | |
| 252 // Write out the serialization header value for this object. | 277 // Write out the serialization header value for this object. |
| 253 writer->WriteInlinedObjectHeader(object_id); | 278 writer->WriteInlinedObjectHeader(object_id); |
| 254 | 279 |
| 255 // Write out the class and tags information. | 280 // Write out the class and tags information. |
| 256 writer->WriteIndexedObject(kTypeParameterCid); | 281 writer->WriteIndexedObject(kTypeParameterCid); |
| 257 writer->WriteIntptrValue(writer->GetObjectTags(this)); | 282 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
| 258 | 283 |
| 259 // Write out all the non object pointer fields. | 284 // Write out all the non object pointer fields. |
| 260 writer->WriteIntptrValue(ptr()->index_); | 285 writer->WriteIntptrValue(ptr()->index_); |
| 261 writer->WriteIntptrValue(ptr()->token_pos_); | 286 writer->WriteIntptrValue(ptr()->token_pos_); |
| (...skipping 1957 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2219 // Write out the class and tags information. | 2244 // Write out the class and tags information. |
| 2220 writer->WriteIndexedObject(kWeakPropertyCid); | 2245 writer->WriteIndexedObject(kWeakPropertyCid); |
| 2221 writer->WriteIntptrValue(writer->GetObjectTags(this)); | 2246 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
| 2222 | 2247 |
| 2223 // Write out all the other fields. | 2248 // Write out all the other fields. |
| 2224 writer->Write<RawObject*>(ptr()->key_); | 2249 writer->Write<RawObject*>(ptr()->key_); |
| 2225 writer->Write<RawObject*>(ptr()->value_); | 2250 writer->Write<RawObject*>(ptr()->value_); |
| 2226 } | 2251 } |
| 2227 | 2252 |
| 2228 } // namespace dart | 2253 } // namespace dart |
| OLD | NEW |