OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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/clustered_snapshot.h" | 5 #include "vm/clustered_snapshot.h" |
6 | 6 |
7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
8 #include "vm/bootstrap.h" | 8 #include "vm/bootstrap.h" |
9 #include "vm/class_finalizer.h" | 9 #include "vm/class_finalizer.h" |
10 #include "vm/dart.h" | 10 #include "vm/dart.h" |
(...skipping 2071 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2082 RawObject** to = scope->to(length); | 2082 RawObject** to = scope->to(length); |
2083 for (RawObject** p = from; p <= to; p++) { | 2083 for (RawObject** p = from; p <= to; p++) { |
2084 *p = d->ReadRef(); | 2084 *p = d->ReadRef(); |
2085 } | 2085 } |
2086 } | 2086 } |
2087 } | 2087 } |
2088 }; | 2088 }; |
2089 | 2089 |
2090 | 2090 |
2091 #if !defined(DART_PRECOMPILED_RUNTIME) | 2091 #if !defined(DART_PRECOMPILED_RUNTIME) |
| 2092 class UnlinkedCallSerializationCluster : public SerializationCluster { |
| 2093 public: |
| 2094 UnlinkedCallSerializationCluster() { } |
| 2095 virtual ~UnlinkedCallSerializationCluster() { } |
| 2096 |
| 2097 void Trace(Serializer* s, RawObject* object) { |
| 2098 RawUnlinkedCall* unlinked = UnlinkedCall::RawCast(object); |
| 2099 objects_.Add(unlinked); |
| 2100 |
| 2101 RawObject** from = unlinked->from(); |
| 2102 RawObject** to = unlinked->to(); |
| 2103 for (RawObject** p = from; p <= to; p++) { |
| 2104 s->Push(*p); |
| 2105 } |
| 2106 } |
| 2107 |
| 2108 void WriteAlloc(Serializer* s) { |
| 2109 s->WriteCid(kUnlinkedCallCid); |
| 2110 intptr_t count = objects_.length(); |
| 2111 s->Write<int32_t>(count); |
| 2112 for (intptr_t i = 0; i < count; i++) { |
| 2113 RawUnlinkedCall* unlinked = objects_[i]; |
| 2114 s->AssignRef(unlinked); |
| 2115 } |
| 2116 } |
| 2117 |
| 2118 void WriteFill(Serializer* s) { |
| 2119 intptr_t count = objects_.length(); |
| 2120 for (intptr_t i = 0; i < count; i++) { |
| 2121 RawUnlinkedCall* unlinked = objects_[i]; |
| 2122 RawObject** from = unlinked->from(); |
| 2123 RawObject** to = unlinked->to(); |
| 2124 for (RawObject** p = from; p <= to; p++) { |
| 2125 s->WriteRef(*p); |
| 2126 } |
| 2127 } |
| 2128 } |
| 2129 |
| 2130 private: |
| 2131 GrowableArray<RawUnlinkedCall*> objects_; |
| 2132 }; |
| 2133 #endif // !DART_PRECOMPILED_RUNTIME |
| 2134 |
| 2135 |
| 2136 class UnlinkedCallDeserializationCluster : public DeserializationCluster { |
| 2137 public: |
| 2138 UnlinkedCallDeserializationCluster() { } |
| 2139 virtual ~UnlinkedCallDeserializationCluster() { } |
| 2140 |
| 2141 void ReadAlloc(Deserializer* d) { |
| 2142 start_index_ = d->next_index(); |
| 2143 PageSpace* old_space = d->heap()->old_space(); |
| 2144 intptr_t count = d->Read<int32_t>(); |
| 2145 for (intptr_t i = 0; i < count; i++) { |
| 2146 d->AssignRef(AllocateUninitialized(old_space, |
| 2147 UnlinkedCall::InstanceSize())); |
| 2148 } |
| 2149 stop_index_ = d->next_index(); |
| 2150 } |
| 2151 |
| 2152 void ReadFill(Deserializer* d) { |
| 2153 bool is_vm_object = d->isolate() == Dart::vm_isolate(); |
| 2154 |
| 2155 for (intptr_t id = start_index_; id < stop_index_; id++) { |
| 2156 RawUnlinkedCall* unlinked = |
| 2157 reinterpret_cast<RawUnlinkedCall*>(d->Ref(id)); |
| 2158 Deserializer::InitializeHeader(unlinked, kUnlinkedCallCid, |
| 2159 UnlinkedCall::InstanceSize(), |
| 2160 is_vm_object); |
| 2161 RawObject** from = unlinked->from(); |
| 2162 RawObject** to = unlinked->to(); |
| 2163 for (RawObject** p = from; p <= to; p++) { |
| 2164 *p = d->ReadRef(); |
| 2165 } |
| 2166 } |
| 2167 } |
| 2168 }; |
| 2169 |
| 2170 |
| 2171 #if !defined(DART_PRECOMPILED_RUNTIME) |
2092 class ICDataSerializationCluster : public SerializationCluster { | 2172 class ICDataSerializationCluster : public SerializationCluster { |
2093 public: | 2173 public: |
2094 ICDataSerializationCluster() { } | 2174 ICDataSerializationCluster() { } |
2095 virtual ~ICDataSerializationCluster() { } | 2175 virtual ~ICDataSerializationCluster() { } |
2096 | 2176 |
2097 void Trace(Serializer* s, RawObject* object) { | 2177 void Trace(Serializer* s, RawObject* object) { |
2098 RawICData* ic = ICData::RawCast(object); | 2178 RawICData* ic = ICData::RawCast(object); |
2099 objects_.Add(ic); | 2179 objects_.Add(ic); |
2100 | 2180 |
2101 RawObject** from = ic->from(); | 2181 RawObject** from = ic->from(); |
(...skipping 2162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4264 case kCodeCid: return new (Z) CodeSerializationCluster(); | 4344 case kCodeCid: return new (Z) CodeSerializationCluster(); |
4265 case kObjectPoolCid: return new (Z) ObjectPoolSerializationCluster(); | 4345 case kObjectPoolCid: return new (Z) ObjectPoolSerializationCluster(); |
4266 case kPcDescriptorsCid: | 4346 case kPcDescriptorsCid: |
4267 return new (Z) RODataSerializationCluster(kPcDescriptorsCid); | 4347 return new (Z) RODataSerializationCluster(kPcDescriptorsCid); |
4268 case kStackmapCid: | 4348 case kStackmapCid: |
4269 return new (Z) RODataSerializationCluster(kStackmapCid); | 4349 return new (Z) RODataSerializationCluster(kStackmapCid); |
4270 case kExceptionHandlersCid: | 4350 case kExceptionHandlersCid: |
4271 return new (Z) ExceptionHandlersSerializationCluster(); | 4351 return new (Z) ExceptionHandlersSerializationCluster(); |
4272 case kContextCid: return new (Z) ContextSerializationCluster(); | 4352 case kContextCid: return new (Z) ContextSerializationCluster(); |
4273 case kContextScopeCid: return new (Z) ContextScopeSerializationCluster(); | 4353 case kContextScopeCid: return new (Z) ContextScopeSerializationCluster(); |
| 4354 case kUnlinkedCallCid: return new (Z) UnlinkedCallSerializationCluster(); |
4274 case kICDataCid: return new (Z) ICDataSerializationCluster(); | 4355 case kICDataCid: return new (Z) ICDataSerializationCluster(); |
4275 case kMegamorphicCacheCid: | 4356 case kMegamorphicCacheCid: |
4276 return new (Z) MegamorphicCacheSerializationCluster(); | 4357 return new (Z) MegamorphicCacheSerializationCluster(); |
4277 case kSubtypeTestCacheCid: | 4358 case kSubtypeTestCacheCid: |
4278 return new (Z) SubtypeTestCacheSerializationCluster(); | 4359 return new (Z) SubtypeTestCacheSerializationCluster(); |
4279 case kLanguageErrorCid: | 4360 case kLanguageErrorCid: |
4280 return new (Z) LanguageErrorSerializationCluster(); | 4361 return new (Z) LanguageErrorSerializationCluster(); |
4281 case kUnhandledExceptionCid: | 4362 case kUnhandledExceptionCid: |
4282 return new (Z) UnhandledExceptionSerializationCluster(); | 4363 return new (Z) UnhandledExceptionSerializationCluster(); |
4283 case kLibraryPrefixCid: return new (Z) LibraryPrefixSerializationCluster(); | 4364 case kLibraryPrefixCid: return new (Z) LibraryPrefixSerializationCluster(); |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4429 AddBaseObject(Object::empty_exception_handlers().raw()); | 4510 AddBaseObject(Object::empty_exception_handlers().raw()); |
4430 | 4511 |
4431 for (intptr_t i = 0; i < ArgumentsDescriptor::kCachedDescriptorCount; i++) { | 4512 for (intptr_t i = 0; i < ArgumentsDescriptor::kCachedDescriptorCount; i++) { |
4432 AddBaseObject(ArgumentsDescriptor::cached_args_descriptors_[i]); | 4513 AddBaseObject(ArgumentsDescriptor::cached_args_descriptors_[i]); |
4433 } | 4514 } |
4434 for (intptr_t i = 0; i < ICData::kCachedICDataArrayCount; i++) { | 4515 for (intptr_t i = 0; i < ICData::kCachedICDataArrayCount; i++) { |
4435 AddBaseObject(ICData::cached_icdata_arrays_[i]); | 4516 AddBaseObject(ICData::cached_icdata_arrays_[i]); |
4436 } | 4517 } |
4437 | 4518 |
4438 ClassTable* table = isolate()->class_table(); | 4519 ClassTable* table = isolate()->class_table(); |
4439 for (intptr_t cid = kClassCid; cid <= kUnwindErrorCid; cid++) { | 4520 for (intptr_t cid = kClassCid; cid < kInstanceCid; cid++) { |
4440 // Error has no class object. | 4521 // Error has no class object. |
4441 if (cid != kErrorCid) { | 4522 if (cid != kErrorCid) { |
4442 ASSERT(table->HasValidClassAt(cid)); | 4523 ASSERT(table->HasValidClassAt(cid)); |
4443 AddBaseObject(table->At(cid)); | 4524 AddBaseObject(table->At(cid)); |
4444 } | 4525 } |
4445 } | 4526 } |
4446 AddBaseObject(table->At(kDynamicCid)); | 4527 AddBaseObject(table->At(kDynamicCid)); |
4447 AddBaseObject(table->At(kVoidCid)); | 4528 AddBaseObject(table->At(kVoidCid)); |
4448 } | 4529 } |
4449 | 4530 |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4586 case kNamespaceCid: return new (Z) NamespaceDeserializationCluster(); | 4667 case kNamespaceCid: return new (Z) NamespaceDeserializationCluster(); |
4587 case kCodeCid: return new (Z) CodeDeserializationCluster(); | 4668 case kCodeCid: return new (Z) CodeDeserializationCluster(); |
4588 case kObjectPoolCid: return new (Z) ObjectPoolDeserializationCluster(); | 4669 case kObjectPoolCid: return new (Z) ObjectPoolDeserializationCluster(); |
4589 case kPcDescriptorsCid: | 4670 case kPcDescriptorsCid: |
4590 case kStackmapCid: | 4671 case kStackmapCid: |
4591 return new (Z) RODataDeserializationCluster(); | 4672 return new (Z) RODataDeserializationCluster(); |
4592 case kExceptionHandlersCid: | 4673 case kExceptionHandlersCid: |
4593 return new (Z) ExceptionHandlersDeserializationCluster(); | 4674 return new (Z) ExceptionHandlersDeserializationCluster(); |
4594 case kContextCid: return new (Z) ContextDeserializationCluster(); | 4675 case kContextCid: return new (Z) ContextDeserializationCluster(); |
4595 case kContextScopeCid: return new (Z) ContextScopeDeserializationCluster(); | 4676 case kContextScopeCid: return new (Z) ContextScopeDeserializationCluster(); |
| 4677 case kUnlinkedCallCid: return new (Z) UnlinkedCallDeserializationCluster(); |
4596 case kICDataCid: return new (Z) ICDataDeserializationCluster(); | 4678 case kICDataCid: return new (Z) ICDataDeserializationCluster(); |
4597 case kMegamorphicCacheCid: | 4679 case kMegamorphicCacheCid: |
4598 return new (Z) MegamorphicCacheDeserializationCluster(); | 4680 return new (Z) MegamorphicCacheDeserializationCluster(); |
4599 case kSubtypeTestCacheCid: | 4681 case kSubtypeTestCacheCid: |
4600 return new (Z) SubtypeTestCacheDeserializationCluster(); | 4682 return new (Z) SubtypeTestCacheDeserializationCluster(); |
4601 case kLanguageErrorCid: | 4683 case kLanguageErrorCid: |
4602 return new (Z) LanguageErrorDeserializationCluster(); | 4684 return new (Z) LanguageErrorDeserializationCluster(); |
4603 case kUnhandledExceptionCid: | 4685 case kUnhandledExceptionCid: |
4604 return new (Z) UnhandledExceptionDeserializationCluster(); | 4686 return new (Z) UnhandledExceptionDeserializationCluster(); |
4605 case kLibraryPrefixCid: | 4687 case kLibraryPrefixCid: |
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5127 | 5209 |
5128 deserializer.ReadVMSnapshot(); | 5210 deserializer.ReadVMSnapshot(); |
5129 | 5211 |
5130 Dart::set_instructions_snapshot_buffer(instructions_buffer_); | 5212 Dart::set_instructions_snapshot_buffer(instructions_buffer_); |
5131 Dart::set_data_snapshot_buffer(data_buffer_); | 5213 Dart::set_data_snapshot_buffer(data_buffer_); |
5132 | 5214 |
5133 return ApiError::null(); | 5215 return ApiError::null(); |
5134 } | 5216 } |
5135 | 5217 |
5136 } // namespace dart | 5218 } // namespace dart |
OLD | NEW |