Chromium Code Reviews| 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/object.h" | 5 #include "vm/object.h" |
| 6 #include "vm/object_store.h" | 6 #include "vm/object_store.h" |
| 7 #include "vm/snapshot.h" | 7 #include "vm/snapshot.h" |
| 8 #include "vm/stub_code.h" | 8 #include "vm/stub_code.h" |
| 9 #include "vm/symbols.h" | 9 #include "vm/symbols.h" |
| 10 #include "vm/visitor.h" | 10 #include "vm/visitor.h" |
| (...skipping 2200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2211 Snapshot::Kind kind) { | 2211 Snapshot::Kind kind) { |
| 2212 ASSERT(reader != NULL); | 2212 ASSERT(reader != NULL); |
| 2213 | 2213 |
| 2214 LinkedHashMap& map = LinkedHashMap::ZoneHandle( | 2214 LinkedHashMap& map = LinkedHashMap::ZoneHandle( |
| 2215 reader->zone(), LinkedHashMap::null()); | 2215 reader->zone(), LinkedHashMap::null()); |
| 2216 if (kind == Snapshot::kFull || kind == Snapshot::kScript) { | 2216 if (kind == Snapshot::kFull || kind == Snapshot::kScript) { |
| 2217 // The immutable maps that seed map literals are not yet VM-internal, so | 2217 // The immutable maps that seed map literals are not yet VM-internal, so |
| 2218 // we don't reach this. | 2218 // we don't reach this. |
| 2219 UNREACHABLE(); | 2219 UNREACHABLE(); |
| 2220 } else { | 2220 } else { |
| 2221 map = LinkedHashMap::New(HEAP_SPACE(kind)); | 2221 // Since the map might contain itself as a key or value, allocate first. |
| 2222 map = LinkedHashMap::NewUninitialized(HEAP_SPACE(kind)); | |
| 2222 } | 2223 } |
| 2223 reader->AddBackRef(object_id, &map, kIsDeserialized); | 2224 reader->AddBackRef(object_id, &map, kIsDeserialized); |
| 2225 *(reader->TypeArgumentsHandle()) ^= reader->ReadObjectImpl(); | |
| 2226 map.SetTypeArguments(*(reader->TypeArgumentsHandle())); | |
| 2227 // Note: If the map is too big for a 32-bit VM, then Array::New will FATAL. | |
| 2224 *(reader->ArrayHandle()) ^= reader->ReadObjectImpl(); | 2228 *(reader->ArrayHandle()) ^= reader->ReadObjectImpl(); |
| 2225 map.SetData(*(reader->ArrayHandle())); | 2229 map.SetData(*(reader->ArrayHandle())); |
| 2226 *(reader->TypeArgumentsHandle()) = reader->ArrayHandle()->GetTypeArguments(); | 2230 *(reader->TypedDataHandle()) ^= reader->ReadObjectImpl(); |
| 2227 map.SetTypeArguments(*(reader->TypeArgumentsHandle())); | 2231 map.SetIndex(*(reader->TypedDataHandle())); |
| 2232 map.SetHashMask(reader->ReadSmiValue()); | |
| 2233 map.SetUsedData(reader->ReadSmiValue()); | |
| 2234 map.SetDeletedKeys(reader->ReadSmiValue()); | |
| 2235 /* | |
| 2236 *(reader->SmiHandle()) ^= reader->ReadObjectImpl(); | |
| 2237 map.SetHashMask(reader->SmiHandle()->Value()); | |
| 2238 *(reader->SmiHandle()) ^= reader->ReadObjectImpl(); | |
| 2239 map.SetUsedData(reader->SmiHandle()->Value()); | |
| 2240 *(reader->SmiHandle()) ^= reader->ReadObjectImpl(); | |
| 2241 map.SetDeletedKeys(reader->SmiHandle()->Value()); | |
| 2242 */ | |
|
siva
2015/05/22 16:27:11
Why is this done this way and not using the from/t
koda
2015/05/26 12:22:05
Done.
| |
| 2228 return map.raw(); | 2243 return map.raw(); |
| 2229 } | 2244 } |
| 2230 | 2245 |
| 2231 | 2246 |
| 2232 void RawLinkedHashMap::WriteTo(SnapshotWriter* writer, | 2247 void RawLinkedHashMap::WriteTo(SnapshotWriter* writer, |
| 2233 intptr_t object_id, | 2248 intptr_t object_id, |
| 2234 Snapshot::Kind kind) { | 2249 Snapshot::Kind kind) { |
| 2235 if (kind == Snapshot::kFull || kind == Snapshot::kScript) { | 2250 if (kind == Snapshot::kFull || kind == Snapshot::kScript) { |
| 2236 // The immutable maps that seed map literals are not yet VM-internal, so | 2251 // The immutable maps that seed map literals are not yet VM-internal, so |
| 2237 // we don't reach this. | 2252 // we don't reach this. |
| 2238 UNREACHABLE(); | 2253 UNREACHABLE(); |
| 2239 } | 2254 } |
| 2240 ASSERT(writer != NULL); | 2255 ASSERT(writer != NULL); |
| 2241 | 2256 |
| 2242 // Write out the serialization header value for this object. | 2257 // Write out the serialization header value for this object. |
| 2243 writer->WriteInlinedObjectHeader(object_id); | 2258 writer->WriteInlinedObjectHeader(object_id); |
| 2244 | 2259 |
| 2245 // Write out the class and tags information. | 2260 // Write out the class and tags information. |
| 2246 writer->WriteIndexedObject(kLinkedHashMapCid); | 2261 writer->WriteIndexedObject(kLinkedHashMapCid); |
| 2247 writer->WriteTags(writer->GetObjectTags(this)); | 2262 writer->WriteTags(writer->GetObjectTags(this)); |
| 2248 | 2263 |
| 2249 // Write out the backing array. | 2264 // Write out the fields. |
| 2250 // TODO(koda): Serialize as pairs (like ToArray) instead, to reduce space and | 2265 // TODO(koda): Serialize only used parts of data_ (after compaction), to |
| 2251 // support per-isolate salted hash codes. | 2266 // reduce space and support per-isolate salted hash codes. All allowed keys |
| 2267 // have types for which we can rehash without running Dart code. | |
| 2268 writer->WriteObjectImpl(ptr()->type_arguments_); | |
| 2252 writer->WriteObjectImpl(ptr()->data_); | 2269 writer->WriteObjectImpl(ptr()->data_); |
| 2270 writer->WriteObjectImpl(ptr()->index_); | |
| 2271 writer->Write<RawObject*>(ptr()->hash_mask_); | |
| 2272 writer->Write<RawObject*>(ptr()->used_data_); | |
| 2273 writer->Write<RawObject*>(ptr()->deleted_keys_); | |
|
siva
2015/05/22 16:27:11
Ditto question.
koda
2015/05/26 12:22:05
Done.
| |
| 2253 } | 2274 } |
| 2254 | 2275 |
| 2255 | 2276 |
| 2256 RawFloat32x4* Float32x4::ReadFrom(SnapshotReader* reader, | 2277 RawFloat32x4* Float32x4::ReadFrom(SnapshotReader* reader, |
| 2257 intptr_t object_id, | 2278 intptr_t object_id, |
| 2258 intptr_t tags, | 2279 intptr_t tags, |
| 2259 Snapshot::Kind kind) { | 2280 Snapshot::Kind kind) { |
| 2260 ASSERT(reader != NULL); | 2281 ASSERT(reader != NULL); |
| 2261 // Read the values. | 2282 // Read the values. |
| 2262 float value0 = reader->Read<float>(); | 2283 float value0 = reader->Read<float>(); |
| (...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2878 // We do not allow objects with native fields in an isolate message. | 2899 // We do not allow objects with native fields in an isolate message. |
| 2879 writer->SetWriteException(Exceptions::kArgument, | 2900 writer->SetWriteException(Exceptions::kArgument, |
| 2880 "Illegal argument in isolate message" | 2901 "Illegal argument in isolate message" |
| 2881 " : (object is a UserTag)"); | 2902 " : (object is a UserTag)"); |
| 2882 } else { | 2903 } else { |
| 2883 UNREACHABLE(); | 2904 UNREACHABLE(); |
| 2884 } | 2905 } |
| 2885 } | 2906 } |
| 2886 | 2907 |
| 2887 } // namespace dart | 2908 } // namespace dart |
| OLD | NEW |