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) { | 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 reference_map()->AddAttachedReference(context->global_proxy()); | 29 if (!include_global_proxy) { |
| 30 reference_map()->AddAttachedReference(context->global_proxy()); |
| 31 } |
30 // The bootstrap snapshot has a code-stub context. When serializing the | 32 // The bootstrap snapshot has a code-stub context. When serializing the |
31 // partial snapshot, it is chained into the weak context list on the isolate | 33 // partial snapshot, it is chained into the weak context list on the isolate |
32 // and it's next context pointer may point to the code-stub context. Clear | 34 // and it's next context pointer may point to the code-stub context. Clear |
33 // it before serializing, it will get re-added to the context list | 35 // it before serializing, it will get re-added to the context list |
34 // explicitly when it's loaded. | 36 // explicitly when it's loaded. |
35 if (context->IsNativeContext()) { | 37 if (context->IsNativeContext()) { |
36 context->set(Context::NEXT_CONTEXT_LINK, | 38 context->set(Context::NEXT_CONTEXT_LINK, |
37 isolate_->heap()->undefined_value()); | 39 isolate_->heap()->undefined_value()); |
38 DCHECK(!context->global_object()->IsUndefined(context->GetIsolate())); | 40 DCHECK(!context->global_object()->IsUndefined(context->GetIsolate())); |
39 // Reset math random cache to get fresh random numbers. | 41 // Reset math random cache to get fresh random numbers. |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 sink_.PutRaw(reinterpret_cast<const byte*>(data.data), data.raw_size, | 149 sink_.PutRaw(reinterpret_cast<const byte*>(data.data), data.raw_size, |
148 "internal fields data"); | 150 "internal fields data"); |
149 delete[] data.data; | 151 delete[] data.data; |
150 } | 152 } |
151 } | 153 } |
152 sink_.Put(kSynchronize, "Finished with internal fields data"); | 154 sink_.Put(kSynchronize, "Finished with internal fields data"); |
153 } | 155 } |
154 | 156 |
155 } // namespace internal | 157 } // namespace internal |
156 } // namespace v8 | 158 } // namespace v8 |
OLD | NEW |