| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/snapshot/serialize.h" | 5 #include "src/snapshot/serialize.h" |
| 6 | 6 |
| 7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
| 8 #include "src/api.h" | 8 #include "src/api.h" |
| 9 #include "src/base/platform/platform.h" | 9 #include "src/base/platform/platform.h" |
| 10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
| (...skipping 1699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1710 // serializing the canonical interpreter-entry-trampoline builtin. | 1710 // serializing the canonical interpreter-entry-trampoline builtin. |
| 1711 if (code->kind() == Code::FUNCTION || | 1711 if (code->kind() == Code::FUNCTION || |
| 1712 (!serializing_builtins_ && code->is_interpreter_entry_trampoline())) { | 1712 (!serializing_builtins_ && code->is_interpreter_entry_trampoline())) { |
| 1713 obj = isolate()->builtins()->builtin(Builtins::kCompileLazy); | 1713 obj = isolate()->builtins()->builtin(Builtins::kCompileLazy); |
| 1714 } | 1714 } |
| 1715 } else if (obj->IsBytecodeArray()) { | 1715 } else if (obj->IsBytecodeArray()) { |
| 1716 obj = isolate()->heap()->undefined_value(); | 1716 obj = isolate()->heap()->undefined_value(); |
| 1717 } | 1717 } |
| 1718 | 1718 |
| 1719 int root_index = root_index_map_.Lookup(obj); | 1719 int root_index = root_index_map_.Lookup(obj); |
| 1720 bool is_immortal_immovable_root = false; |
| 1720 // We can only encode roots as such if it has already been serialized. | 1721 // We can only encode roots as such if it has already been serialized. |
| 1721 // That applies to root indices below the wave front. | 1722 // That applies to root indices below the wave front. |
| 1722 if (root_index != RootIndexMap::kInvalidRootIndex && | 1723 if (root_index != RootIndexMap::kInvalidRootIndex) { |
| 1723 root_index < root_index_wave_front_) { | 1724 if (root_index < root_index_wave_front_) { |
| 1724 PutRoot(root_index, obj, how_to_code, where_to_point, skip); | 1725 PutRoot(root_index, obj, how_to_code, where_to_point, skip); |
| 1725 return; | 1726 return; |
| 1727 } else { |
| 1728 is_immortal_immovable_root = Heap::RootIsImmortalImmovable(root_index); |
| 1729 } |
| 1726 } | 1730 } |
| 1727 | 1731 |
| 1728 if (SerializeKnownObject(obj, how_to_code, where_to_point, skip)) return; | 1732 if (SerializeKnownObject(obj, how_to_code, where_to_point, skip)) return; |
| 1729 | 1733 |
| 1730 FlushSkip(skip); | 1734 FlushSkip(skip); |
| 1731 | 1735 |
| 1732 // Object has not yet been serialized. Serialize it here. | 1736 // Object has not yet been serialized. Serialize it here. |
| 1733 ObjectSerializer object_serializer(this, obj, sink_, how_to_code, | 1737 ObjectSerializer object_serializer(this, obj, sink_, how_to_code, |
| 1734 where_to_point); | 1738 where_to_point); |
| 1735 object_serializer.Serialize(); | 1739 object_serializer.Serialize(); |
| 1740 |
| 1741 if (is_immortal_immovable_root) { |
| 1742 // Make sure that the immortal immovable root has been included in the first |
| 1743 // chunk of its reserved space , so that it is deserialized onto the first |
| 1744 // page of its space and stays immortal immovable. |
| 1745 BackReference ref = back_reference_map_.Lookup(obj); |
| 1746 CHECK(ref.is_valid() && ref.chunk_index() == 0); |
| 1747 } |
| 1736 } | 1748 } |
| 1737 | 1749 |
| 1738 | 1750 |
| 1739 void StartupSerializer::SerializeWeakReferencesAndDeferred() { | 1751 void StartupSerializer::SerializeWeakReferencesAndDeferred() { |
| 1740 // This phase comes right after the serialization (of the snapshot). | 1752 // This phase comes right after the serialization (of the snapshot). |
| 1741 // After we have done the partial serialization the partial snapshot cache | 1753 // After we have done the partial serialization the partial snapshot cache |
| 1742 // will contain some references needed to decode the partial snapshot. We | 1754 // will contain some references needed to decode the partial snapshot. We |
| 1743 // add one entry with 'undefined' which is the sentinel that the deserializer | 1755 // add one entry with 'undefined' which is the sentinel that the deserializer |
| 1744 // uses to know it is done deserializing the array. | 1756 // uses to know it is done deserializing the array. |
| 1745 Object* undefined = isolate()->heap()->undefined_value(); | 1757 Object* undefined = isolate()->heap()->undefined_value(); |
| (...skipping 1096 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2842 SerializedCodeData* scd = new SerializedCodeData(cached_data); | 2854 SerializedCodeData* scd = new SerializedCodeData(cached_data); |
| 2843 SanityCheckResult r = scd->SanityCheck(isolate, source); | 2855 SanityCheckResult r = scd->SanityCheck(isolate, source); |
| 2844 if (r == CHECK_SUCCESS) return scd; | 2856 if (r == CHECK_SUCCESS) return scd; |
| 2845 cached_data->Reject(); | 2857 cached_data->Reject(); |
| 2846 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r); | 2858 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r); |
| 2847 delete scd; | 2859 delete scd; |
| 2848 return NULL; | 2860 return NULL; |
| 2849 } | 2861 } |
| 2850 } // namespace internal | 2862 } // namespace internal |
| 2851 } // namespace v8 | 2863 } // namespace v8 |
| OLD | NEW |