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/partial-serializer.h" | 5 #include "src/snapshot/partial-serializer.h" |
6 #include "src/snapshot/startup-serializer.h" | 6 #include "src/snapshot/startup-serializer.h" |
7 | 7 |
8 #include "src/objects-inl.h" | 8 #include "src/objects-inl.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
11 namespace internal { | 11 namespace internal { |
12 | 12 |
13 PartialSerializer::PartialSerializer( | 13 PartialSerializer::PartialSerializer( |
14 Isolate* isolate, StartupSerializer* startup_serializer, | 14 Isolate* isolate, StartupSerializer* startup_serializer, |
15 v8::SerializeInternalFieldsCallback callback) | 15 v8::SerializeInternalFieldsCallback callback) |
16 : Serializer(isolate), | 16 : Serializer(isolate), |
17 startup_serializer_(startup_serializer), | 17 startup_serializer_(startup_serializer), |
18 serialize_internal_fields_(callback) { | 18 serialize_internal_fields_(callback) { |
19 InitializeCodeAddressMap(); | 19 InitializeCodeAddressMap(); |
20 } | 20 } |
21 | 21 |
22 PartialSerializer::~PartialSerializer() { | 22 PartialSerializer::~PartialSerializer() { |
23 OutputStatistics("PartialSerializer"); | 23 OutputStatistics("PartialSerializer"); |
24 } | 24 } |
25 | 25 |
26 void PartialSerializer::Serialize(Object** o, bool include_global_proxy) { | 26 void PartialSerializer::Serialize(Object** o, bool include_global_proxy) { |
27 if ((*o)->IsContext()) { | 27 if ((*o)->IsContext()) { |
28 Context* context = Context::cast(*o); | 28 Context* context = Context::cast(*o); |
29 if (!include_global_proxy) { | 29 reference_map()->AddAttachedReference(context->global_proxy()); |
30 reference_map()->AddAttachedReference(context->global_proxy()); | |
31 } | |
32 // The bootstrap snapshot has a code-stub context. When serializing the | 30 // The bootstrap snapshot has a code-stub context. When serializing the |
33 // partial snapshot, it is chained into the weak context list on the isolate | 31 // partial snapshot, it is chained into the weak context list on the isolate |
34 // and it's next context pointer may point to the code-stub context. Clear | 32 // and it's next context pointer may point to the code-stub context. Clear |
35 // it before serializing, it will get re-added to the context list | 33 // it before serializing, it will get re-added to the context list |
36 // explicitly when it's loaded. | 34 // explicitly when it's loaded. |
37 if (context->IsNativeContext()) { | 35 if (context->IsNativeContext()) { |
38 context->set(Context::NEXT_CONTEXT_LINK, | 36 context->set(Context::NEXT_CONTEXT_LINK, |
39 isolate_->heap()->undefined_value()); | 37 isolate_->heap()->undefined_value()); |
40 DCHECK(!context->global_object()->IsUndefined(context->GetIsolate())); | 38 DCHECK(!context->global_object()->IsUndefined(context->GetIsolate())); |
41 // Reset math random cache to get fresh random numbers. | 39 // Reset math random cache to get fresh random numbers. |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 sink_.PutRaw(reinterpret_cast<const byte*>(data.data), data.raw_size, | 147 sink_.PutRaw(reinterpret_cast<const byte*>(data.data), data.raw_size, |
150 "internal fields data"); | 148 "internal fields data"); |
151 delete[] data.data; | 149 delete[] data.data; |
152 } | 150 } |
153 } | 151 } |
154 sink_.Put(kSynchronize, "Finished with internal fields data"); | 152 sink_.Put(kSynchronize, "Finished with internal fields data"); |
155 } | 153 } |
156 | 154 |
157 } // namespace internal | 155 } // namespace internal |
158 } // namespace v8 | 156 } // namespace v8 |
OLD | NEW |