Chromium Code Reviews| 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 1697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1708 // serializing the canonical interpreter-entry-trampoline builtin. | 1708 // serializing the canonical interpreter-entry-trampoline builtin. |
| 1709 if (code->kind() == Code::FUNCTION || | 1709 if (code->kind() == Code::FUNCTION || |
| 1710 (!serializing_builtins_ && code->is_interpreter_entry_trampoline())) { | 1710 (!serializing_builtins_ && code->is_interpreter_entry_trampoline())) { |
| 1711 obj = isolate()->builtins()->builtin(Builtins::kCompileLazy); | 1711 obj = isolate()->builtins()->builtin(Builtins::kCompileLazy); |
| 1712 } | 1712 } |
| 1713 } else if (obj->IsBytecodeArray()) { | 1713 } else if (obj->IsBytecodeArray()) { |
| 1714 obj = isolate()->heap()->undefined_value(); | 1714 obj = isolate()->heap()->undefined_value(); |
| 1715 } | 1715 } |
| 1716 | 1716 |
| 1717 int root_index = root_index_map_.Lookup(obj); | 1717 int root_index = root_index_map_.Lookup(obj); |
| 1718 bool is_immortal_immovable_root = false; | |
| 1718 // We can only encode roots as such if it has already been serialized. | 1719 // We can only encode roots as such if it has already been serialized. |
| 1719 // That applies to root indices below the wave front. | 1720 // That applies to root indices below the wave front. |
| 1720 if (root_index != RootIndexMap::kInvalidRootIndex && | 1721 if (root_index != RootIndexMap::kInvalidRootIndex) { |
| 1721 root_index < root_index_wave_front_) { | 1722 if (root_index < root_index_wave_front_) { |
| 1722 PutRoot(root_index, obj, how_to_code, where_to_point, skip); | 1723 PutRoot(root_index, obj, how_to_code, where_to_point, skip); |
| 1723 return; | 1724 return; |
| 1725 } else { | |
| 1726 is_immortal_immovable_root = Heap::RootIsImmortalImmovable(root_index); | |
| 1727 } | |
| 1724 } | 1728 } |
| 1725 | 1729 |
| 1726 if (SerializeKnownObject(obj, how_to_code, where_to_point, skip)) return; | 1730 if (SerializeKnownObject(obj, how_to_code, where_to_point, skip)) return; |
| 1727 | 1731 |
| 1728 FlushSkip(skip); | 1732 FlushSkip(skip); |
| 1729 | 1733 |
| 1730 // Object has not yet been serialized. Serialize it here. | 1734 // Object has not yet been serialized. Serialize it here. |
| 1731 ObjectSerializer object_serializer(this, obj, sink_, how_to_code, | 1735 ObjectSerializer object_serializer(this, obj, sink_, how_to_code, |
| 1732 where_to_point); | 1736 where_to_point); |
| 1733 object_serializer.Serialize(); | 1737 object_serializer.Serialize(); |
| 1738 | |
| 1739 if (is_immortal_immovable_root) { | |
| 1740 // Make sure that the immortal immovable root has been included in the first | |
| 1741 // chunk of its reserved space , so that it is deserialized onto the first | |
|
Michael Starzinger
2016/02/05 14:47:59
nit: Spurious white-space before comma.
| |
| 1742 // page of its space and stays immortal immovable. | |
| 1743 BackReference ref = back_reference_map_.Lookup(obj); | |
| 1744 CHECK(ref.is_valid() && ref.chunk_index() == 0); | |
| 1745 } | |
| 1734 } | 1746 } |
| 1735 | 1747 |
| 1736 | 1748 |
| 1737 void StartupSerializer::SerializeWeakReferencesAndDeferred() { | 1749 void StartupSerializer::SerializeWeakReferencesAndDeferred() { |
| 1738 // This phase comes right after the serialization (of the snapshot). | 1750 // This phase comes right after the serialization (of the snapshot). |
| 1739 // After we have done the partial serialization the partial snapshot cache | 1751 // After we have done the partial serialization the partial snapshot cache |
| 1740 // will contain some references needed to decode the partial snapshot. We | 1752 // will contain some references needed to decode the partial snapshot. We |
| 1741 // add one entry with 'undefined' which is the sentinel that the deserializer | 1753 // add one entry with 'undefined' which is the sentinel that the deserializer |
| 1742 // uses to know it is done deserializing the array. | 1754 // uses to know it is done deserializing the array. |
| 1743 Object* undefined = isolate()->heap()->undefined_value(); | 1755 Object* undefined = isolate()->heap()->undefined_value(); |
| (...skipping 1103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2847 SerializedCodeData* scd = new SerializedCodeData(cached_data); | 2859 SerializedCodeData* scd = new SerializedCodeData(cached_data); |
| 2848 SanityCheckResult r = scd->SanityCheck(isolate, source); | 2860 SanityCheckResult r = scd->SanityCheck(isolate, source); |
| 2849 if (r == CHECK_SUCCESS) return scd; | 2861 if (r == CHECK_SUCCESS) return scd; |
| 2850 cached_data->Reject(); | 2862 cached_data->Reject(); |
| 2851 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r); | 2863 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r); |
| 2852 delete scd; | 2864 delete scd; |
| 2853 return NULL; | 2865 return NULL; |
| 2854 } | 2866 } |
| 2855 } // namespace internal | 2867 } // namespace internal |
| 2856 } // namespace v8 | 2868 } // namespace v8 |
| OLD | NEW |