OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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/startup-serializer.h" | 5 #include "src/snapshot/startup-serializer.h" |
6 | 6 |
7 #include "src/objects-inl.h" | 7 #include "src/objects-inl.h" |
8 #include "src/v8threads.h" | 8 #include "src/v8threads.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 // This comes right after serialization of the partial snapshot, where we | 83 // This comes right after serialization of the partial snapshot, where we |
84 // add entries to the partial snapshot cache of the startup snapshot. Add | 84 // add entries to the partial snapshot cache of the startup snapshot. Add |
85 // one entry with 'undefined' to terminate the partial snapshot cache. | 85 // one entry with 'undefined' to terminate the partial snapshot cache. |
86 Object* undefined = isolate()->heap()->undefined_value(); | 86 Object* undefined = isolate()->heap()->undefined_value(); |
87 VisitPointer(&undefined); | 87 VisitPointer(&undefined); |
88 isolate()->heap()->IterateWeakRoots(this, VISIT_ALL); | 88 isolate()->heap()->IterateWeakRoots(this, VISIT_ALL); |
89 SerializeDeferredObjects(); | 89 SerializeDeferredObjects(); |
90 Pad(); | 90 Pad(); |
91 } | 91 } |
92 | 92 |
| 93 int StartupSerializer::PartialSnapshotCacheIndex(HeapObject* heap_object) { |
| 94 int index; |
| 95 if (!partial_cache_index_map_.LookupOrInsert(heap_object, &index)) { |
| 96 // This object is not part of the partial snapshot cache yet. Add it to the |
| 97 // startup snapshot so we can refer to it via partial snapshot index from |
| 98 // the partial snapshot. |
| 99 VisitPointer(reinterpret_cast<Object**>(&heap_object)); |
| 100 } |
| 101 return index; |
| 102 } |
| 103 |
93 void StartupSerializer::Synchronize(VisitorSynchronization::SyncTag tag) { | 104 void StartupSerializer::Synchronize(VisitorSynchronization::SyncTag tag) { |
94 // We expect the builtins tag after builtins have been serialized. | 105 // We expect the builtins tag after builtins have been serialized. |
95 DCHECK(!serializing_builtins_ || tag == VisitorSynchronization::kBuiltins); | 106 DCHECK(!serializing_builtins_ || tag == VisitorSynchronization::kBuiltins); |
96 serializing_builtins_ = (tag == VisitorSynchronization::kHandleScope); | 107 serializing_builtins_ = (tag == VisitorSynchronization::kHandleScope); |
97 sink_.Put(kSynchronize, "Synchronize"); | 108 sink_.Put(kSynchronize, "Synchronize"); |
98 } | 109 } |
99 | 110 |
100 void StartupSerializer::SerializeStrongReferences() { | 111 void StartupSerializer::SerializeStrongReferences() { |
101 Isolate* isolate = this->isolate(); | 112 Isolate* isolate = this->isolate(); |
102 // No active threads. | 113 // No active threads. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 if (root_index == Heap::kStackLimitRootIndex || | 170 if (root_index == Heap::kStackLimitRootIndex || |
160 root_index == Heap::kRealStackLimitRootIndex) { | 171 root_index == Heap::kRealStackLimitRootIndex) { |
161 return true; | 172 return true; |
162 } | 173 } |
163 return Heap::RootIsImmortalImmovable(root_index) != | 174 return Heap::RootIsImmortalImmovable(root_index) != |
164 serializing_immortal_immovables_roots_; | 175 serializing_immortal_immovables_roots_; |
165 } | 176 } |
166 | 177 |
167 } // namespace internal | 178 } // namespace internal |
168 } // namespace v8 | 179 } // namespace v8 |
OLD | NEW |