| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 782 void Deserializer::Deserialize(Isolate* isolate) { | 782 void Deserializer::Deserialize(Isolate* isolate) { |
| 783 isolate_ = isolate; | 783 isolate_ = isolate; |
| 784 ASSERT(isolate_ != NULL); | 784 ASSERT(isolate_ != NULL); |
| 785 isolate_->heap()->ReserveSpace(reservations_, &high_water_[0]); | 785 isolate_->heap()->ReserveSpace(reservations_, &high_water_[0]); |
| 786 // No active threads. | 786 // No active threads. |
| 787 ASSERT_EQ(NULL, isolate_->thread_manager()->FirstThreadStateInUse()); | 787 ASSERT_EQ(NULL, isolate_->thread_manager()->FirstThreadStateInUse()); |
| 788 // No active handles. | 788 // No active handles. |
| 789 ASSERT(isolate_->handle_scope_implementer()->blocks()->is_empty()); | 789 ASSERT(isolate_->handle_scope_implementer()->blocks()->is_empty()); |
| 790 ASSERT_EQ(NULL, external_reference_decoder_); | 790 ASSERT_EQ(NULL, external_reference_decoder_); |
| 791 external_reference_decoder_ = new ExternalReferenceDecoder(isolate); | 791 external_reference_decoder_ = new ExternalReferenceDecoder(isolate); |
| 792 isolate_->heap()->IterateRootSmis(this); |
| 792 isolate_->heap()->IterateStrongRoots(this, VISIT_ONLY_STRONG); | 793 isolate_->heap()->IterateStrongRoots(this, VISIT_ONLY_STRONG); |
| 793 isolate_->heap()->RepairFreeListsAfterBoot(); | 794 isolate_->heap()->RepairFreeListsAfterBoot(); |
| 794 isolate_->heap()->IterateWeakRoots(this, VISIT_ALL); | 795 isolate_->heap()->IterateWeakRoots(this, VISIT_ALL); |
| 795 | 796 |
| 796 isolate_->heap()->set_native_contexts_list( | 797 isolate_->heap()->set_native_contexts_list( |
| 797 isolate_->heap()->undefined_value()); | 798 isolate_->heap()->undefined_value()); |
| 798 isolate_->heap()->set_array_buffers_list( | 799 isolate_->heap()->set_array_buffers_list( |
| 799 isolate_->heap()->undefined_value()); | 800 isolate_->heap()->undefined_value()); |
| 800 | 801 |
| 801 // The allocation site list is build during root iteration, but if no sites | 802 // The allocation site list is build during root iteration, but if no sites |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1246 integer |= bytes; | 1247 integer |= bytes; |
| 1247 Put(static_cast<int>(integer & 0xff), "IntPart1"); | 1248 Put(static_cast<int>(integer & 0xff), "IntPart1"); |
| 1248 if (bytes > 1) Put(static_cast<int>((integer >> 8) & 0xff), "IntPart2"); | 1249 if (bytes > 1) Put(static_cast<int>((integer >> 8) & 0xff), "IntPart2"); |
| 1249 if (bytes > 2) Put(static_cast<int>((integer >> 16) & 0xff), "IntPart3"); | 1250 if (bytes > 2) Put(static_cast<int>((integer >> 16) & 0xff), "IntPart3"); |
| 1250 } | 1251 } |
| 1251 | 1252 |
| 1252 | 1253 |
| 1253 Serializer::Serializer(Isolate* isolate, SnapshotByteSink* sink) | 1254 Serializer::Serializer(Isolate* isolate, SnapshotByteSink* sink) |
| 1254 : isolate_(isolate), | 1255 : isolate_(isolate), |
| 1255 sink_(sink), | 1256 sink_(sink), |
| 1256 current_root_index_(0), | |
| 1257 external_reference_encoder_(new ExternalReferenceEncoder(isolate)), | 1257 external_reference_encoder_(new ExternalReferenceEncoder(isolate)), |
| 1258 root_index_wave_front_(0) { | 1258 root_index_wave_front_(0) { |
| 1259 // The serializer is meant to be used only to generate initial heap images | 1259 // The serializer is meant to be used only to generate initial heap images |
| 1260 // from a context in which there is only one isolate. | 1260 // from a context in which there is only one isolate. |
| 1261 for (int i = 0; i <= LAST_SPACE; i++) { | 1261 for (int i = 0; i <= LAST_SPACE; i++) { |
| 1262 fullness_[i] = 0; | 1262 fullness_[i] = 0; |
| 1263 } | 1263 } |
| 1264 } | 1264 } |
| 1265 | 1265 |
| 1266 | 1266 |
| 1267 Serializer::~Serializer() { | 1267 Serializer::~Serializer() { |
| 1268 delete external_reference_encoder_; | 1268 delete external_reference_encoder_; |
| 1269 } | 1269 } |
| 1270 | 1270 |
| 1271 | 1271 |
| 1272 void StartupSerializer::SerializeStrongReferences() { | 1272 void StartupSerializer::SerializeStrongReferences() { |
| 1273 Isolate* isolate = this->isolate(); | 1273 Isolate* isolate = this->isolate(); |
| 1274 // No active threads. | 1274 // No active threads. |
| 1275 CHECK_EQ(NULL, isolate->thread_manager()->FirstThreadStateInUse()); | 1275 CHECK_EQ(NULL, isolate->thread_manager()->FirstThreadStateInUse()); |
| 1276 // No active or weak handles. | 1276 // No active or weak handles. |
| 1277 CHECK(isolate->handle_scope_implementer()->blocks()->is_empty()); | 1277 CHECK(isolate->handle_scope_implementer()->blocks()->is_empty()); |
| 1278 CHECK_EQ(0, isolate->global_handles()->NumberOfWeakHandles()); | 1278 CHECK_EQ(0, isolate->global_handles()->NumberOfWeakHandles()); |
| 1279 CHECK_EQ(0, isolate->eternal_handles()->NumberOfHandles()); | 1279 CHECK_EQ(0, isolate->eternal_handles()->NumberOfHandles()); |
| 1280 // We don't support serializing installed extensions. | 1280 // We don't support serializing installed extensions. |
| 1281 CHECK(!isolate->has_installed_extensions()); | 1281 CHECK(!isolate->has_installed_extensions()); |
| 1282 | 1282 isolate->heap()->IterateRootSmis(this); |
| 1283 isolate->heap()->IterateStrongRoots(this, VISIT_ONLY_STRONG); | 1283 isolate->heap()->IterateStrongRoots(this, VISIT_ONLY_STRONG); |
| 1284 } | 1284 } |
| 1285 | 1285 |
| 1286 | 1286 |
| 1287 void PartialSerializer::Serialize(Object** object) { | 1287 void PartialSerializer::Serialize(Object** object) { |
| 1288 this->VisitPointer(object); | 1288 this->VisitPointer(object); |
| 1289 Pad(); | 1289 Pad(); |
| 1290 } | 1290 } |
| 1291 | 1291 |
| 1292 | 1292 |
| (...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1848 | 1848 |
| 1849 bool SnapshotByteSource::AtEOF() { | 1849 bool SnapshotByteSource::AtEOF() { |
| 1850 if (0u + length_ - position_ > 2 * sizeof(uint32_t)) return false; | 1850 if (0u + length_ - position_ > 2 * sizeof(uint32_t)) return false; |
| 1851 for (int x = position_; x < length_; x++) { | 1851 for (int x = position_; x < length_; x++) { |
| 1852 if (data_[x] != SerializerDeserializer::nop()) return false; | 1852 if (data_[x] != SerializerDeserializer::nop()) return false; |
| 1853 } | 1853 } |
| 1854 return true; | 1854 return true; |
| 1855 } | 1855 } |
| 1856 | 1856 |
| 1857 } } // namespace v8::internal | 1857 } } // namespace v8::internal |
| OLD | NEW |