| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 885 character = *tag++; | 885 character = *tag++; |
| 886 sink_->PutSection(character, "TagCharacter"); | 886 sink_->PutSection(character, "TagCharacter"); |
| 887 } while (character != 0); | 887 } while (character != 0); |
| 888 } | 888 } |
| 889 | 889 |
| 890 #endif | 890 #endif |
| 891 | 891 |
| 892 Serializer::Serializer(SnapshotByteSink* sink) | 892 Serializer::Serializer(SnapshotByteSink* sink) |
| 893 : sink_(sink), | 893 : sink_(sink), |
| 894 current_root_index_(0), | 894 current_root_index_(0), |
| 895 external_reference_encoder_(NULL), | 895 external_reference_encoder_(new ExternalReferenceEncoder), |
| 896 large_object_total_(0) { | 896 large_object_total_(0) { |
| 897 for (int i = 0; i <= LAST_SPACE; i++) { | 897 for (int i = 0; i <= LAST_SPACE; i++) { |
| 898 fullness_[i] = 0; | 898 fullness_[i] = 0; |
| 899 } | 899 } |
| 900 } | 900 } |
| 901 | 901 |
| 902 | 902 |
| 903 Serializer::~Serializer() { |
| 904 delete external_reference_encoder_; |
| 905 } |
| 906 |
| 907 |
| 903 void StartupSerializer::SerializeStrongReferences() { | 908 void StartupSerializer::SerializeStrongReferences() { |
| 904 // No active threads. | 909 // No active threads. |
| 905 CHECK_EQ(NULL, ThreadState::FirstInUse()); | 910 CHECK_EQ(NULL, ThreadState::FirstInUse()); |
| 906 // No active or weak handles. | 911 // No active or weak handles. |
| 907 CHECK(HandleScopeImplementer::instance()->blocks()->is_empty()); | 912 CHECK(HandleScopeImplementer::instance()->blocks()->is_empty()); |
| 908 CHECK_EQ(0, GlobalHandles::NumberOfWeakHandles()); | 913 CHECK_EQ(0, GlobalHandles::NumberOfWeakHandles()); |
| 909 CHECK_EQ(NULL, external_reference_encoder_); | |
| 910 // We don't support serializing installed extensions. | 914 // We don't support serializing installed extensions. |
| 911 for (RegisteredExtension* ext = RegisteredExtension::first_extension(); | 915 for (RegisteredExtension* ext = RegisteredExtension::first_extension(); |
| 912 ext != NULL; | 916 ext != NULL; |
| 913 ext = ext->next()) { | 917 ext = ext->next()) { |
| 914 CHECK_NE(v8::INSTALLED, ext->state()); | 918 CHECK_NE(v8::INSTALLED, ext->state()); |
| 915 } | 919 } |
| 916 external_reference_encoder_ = new ExternalReferenceEncoder(); | |
| 917 Heap::IterateStrongRoots(this, VISIT_ONLY_STRONG); | 920 Heap::IterateStrongRoots(this, VISIT_ONLY_STRONG); |
| 918 delete external_reference_encoder_; | |
| 919 external_reference_encoder_ = NULL; | |
| 920 } | 921 } |
| 921 | 922 |
| 922 | 923 |
| 923 void PartialSerializer::Serialize(Object** object) { | 924 void PartialSerializer::Serialize(Object** object) { |
| 924 external_reference_encoder_ = new ExternalReferenceEncoder(); | |
| 925 this->VisitPointer(object); | 925 this->VisitPointer(object); |
| 926 | 926 |
| 927 // After we have done the partial serialization the partial snapshot cache | 927 // After we have done the partial serialization the partial snapshot cache |
| 928 // will contain some references needed to decode the partial snapshot. We | 928 // will contain some references needed to decode the partial snapshot. We |
| 929 // fill it up with undefineds so it has a predictable length so the | 929 // fill it up with undefineds so it has a predictable length so the |
| 930 // deserialization code doesn't need to know the length. | 930 // deserialization code doesn't need to know the length. |
| 931 for (int index = partial_snapshot_cache_length_; | 931 for (int index = partial_snapshot_cache_length_; |
| 932 index < kPartialSnapshotCacheCapacity; | 932 index < kPartialSnapshotCacheCapacity; |
| 933 index++) { | 933 index++) { |
| 934 partial_snapshot_cache_[index] = Heap::undefined_value(); | 934 partial_snapshot_cache_[index] = Heap::undefined_value(); |
| 935 startup_serializer_->VisitPointer(&partial_snapshot_cache_[index]); | 935 startup_serializer_->VisitPointer(&partial_snapshot_cache_[index]); |
| 936 } | 936 } |
| 937 partial_snapshot_cache_length_ = kPartialSnapshotCacheCapacity; | 937 partial_snapshot_cache_length_ = kPartialSnapshotCacheCapacity; |
| 938 | |
| 939 delete external_reference_encoder_; | |
| 940 external_reference_encoder_ = NULL; | |
| 941 } | 938 } |
| 942 | 939 |
| 943 | 940 |
| 944 void Serializer::VisitPointers(Object** start, Object** end) { | 941 void Serializer::VisitPointers(Object** start, Object** end) { |
| 945 for (Object** current = start; current < end; current++) { | 942 for (Object** current = start; current < end; current++) { |
| 946 if ((*current)->IsSmi()) { | 943 if ((*current)->IsSmi()) { |
| 947 sink_->Put(RAW_DATA_SERIALIZATION, "RawData"); | 944 sink_->Put(RAW_DATA_SERIALIZATION, "RawData"); |
| 948 sink_->PutInt(kPointerSize, "length"); | 945 sink_->PutInt(kPointerSize, "length"); |
| 949 for (int i = 0; i < kPointerSize; i++) { | 946 for (int i = 0; i < kPointerSize; i++) { |
| 950 sink_->Put(reinterpret_cast<byte*>(current)[i], "Byte"); | 947 sink_->Put(reinterpret_cast<byte*>(current)[i], "Byte"); |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1353 fullness_[space] = RoundUp(fullness_[space], Page::kPageSize); | 1350 fullness_[space] = RoundUp(fullness_[space], Page::kPageSize); |
| 1354 } | 1351 } |
| 1355 } | 1352 } |
| 1356 int allocation_address = fullness_[space]; | 1353 int allocation_address = fullness_[space]; |
| 1357 fullness_[space] = allocation_address + size; | 1354 fullness_[space] = allocation_address + size; |
| 1358 return allocation_address; | 1355 return allocation_address; |
| 1359 } | 1356 } |
| 1360 | 1357 |
| 1361 | 1358 |
| 1362 } } // namespace v8::internal | 1359 } } // namespace v8::internal |
| OLD | NEW |