OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/bootstrapper.h" | 5 #include "src/bootstrapper.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/api-natives.h" | 8 #include "src/api-natives.h" |
9 #include "src/base/ieee754.h" | 9 #include "src/base/ieee754.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 ExperimentalExtraNatives::GetSourceCache(isolate_->heap())); | 133 ExperimentalExtraNatives::GetSourceCache(isolate_->heap())); |
134 | 134 |
135 extensions_cache_.Initialize(isolate_, false); // Yes, symmetrical | 135 extensions_cache_.Initialize(isolate_, false); // Yes, symmetrical |
136 } | 136 } |
137 | 137 |
138 | 138 |
139 class Genesis BASE_EMBEDDED { | 139 class Genesis BASE_EMBEDDED { |
140 public: | 140 public: |
141 Genesis(Isolate* isolate, MaybeHandle<JSGlobalProxy> maybe_global_proxy, | 141 Genesis(Isolate* isolate, MaybeHandle<JSGlobalProxy> maybe_global_proxy, |
142 v8::Local<v8::ObjectTemplate> global_proxy_template, | 142 v8::Local<v8::ObjectTemplate> global_proxy_template, |
143 size_t context_snapshot_index, GlobalContextType context_type); | 143 size_t context_snapshot_index, |
| 144 v8::DeserializeInternalFieldsCallback internal_fields_deserializer, |
| 145 GlobalContextType context_type); |
144 Genesis(Isolate* isolate, MaybeHandle<JSGlobalProxy> maybe_global_proxy, | 146 Genesis(Isolate* isolate, MaybeHandle<JSGlobalProxy> maybe_global_proxy, |
145 v8::Local<v8::ObjectTemplate> global_proxy_template); | 147 v8::Local<v8::ObjectTemplate> global_proxy_template); |
146 ~Genesis() { } | 148 ~Genesis() { } |
147 | 149 |
148 Isolate* isolate() const { return isolate_; } | 150 Isolate* isolate() const { return isolate_; } |
149 Factory* factory() const { return isolate_->factory(); } | 151 Factory* factory() const { return isolate_->factory(); } |
150 Heap* heap() const { return isolate_->heap(); } | 152 Heap* heap() const { return isolate_->heap(); } |
151 | 153 |
152 Handle<Context> result() { return result_; } | 154 Handle<Context> result() { return result_; } |
153 | 155 |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 | 304 |
303 void Bootstrapper::Iterate(ObjectVisitor* v) { | 305 void Bootstrapper::Iterate(ObjectVisitor* v) { |
304 extensions_cache_.Iterate(v); | 306 extensions_cache_.Iterate(v); |
305 v->Synchronize(VisitorSynchronization::kExtensions); | 307 v->Synchronize(VisitorSynchronization::kExtensions); |
306 } | 308 } |
307 | 309 |
308 Handle<Context> Bootstrapper::CreateEnvironment( | 310 Handle<Context> Bootstrapper::CreateEnvironment( |
309 MaybeHandle<JSGlobalProxy> maybe_global_proxy, | 311 MaybeHandle<JSGlobalProxy> maybe_global_proxy, |
310 v8::Local<v8::ObjectTemplate> global_proxy_template, | 312 v8::Local<v8::ObjectTemplate> global_proxy_template, |
311 v8::ExtensionConfiguration* extensions, size_t context_snapshot_index, | 313 v8::ExtensionConfiguration* extensions, size_t context_snapshot_index, |
| 314 v8::DeserializeInternalFieldsCallback internal_fields_deserializer, |
312 GlobalContextType context_type) { | 315 GlobalContextType context_type) { |
313 HandleScope scope(isolate_); | 316 HandleScope scope(isolate_); |
314 Genesis genesis(isolate_, maybe_global_proxy, global_proxy_template, | 317 Genesis genesis(isolate_, maybe_global_proxy, global_proxy_template, |
315 context_snapshot_index, context_type); | 318 context_snapshot_index, internal_fields_deserializer, |
| 319 context_type); |
316 Handle<Context> env = genesis.result(); | 320 Handle<Context> env = genesis.result(); |
317 if (env.is_null() || !InstallExtensions(env, extensions)) { | 321 if (env.is_null() || !InstallExtensions(env, extensions)) { |
318 return Handle<Context>(); | 322 return Handle<Context>(); |
319 } | 323 } |
320 return scope.CloseAndEscape(env); | 324 return scope.CloseAndEscape(env); |
321 } | 325 } |
322 | 326 |
323 Handle<JSGlobalProxy> Bootstrapper::NewRemoteContext( | 327 Handle<JSGlobalProxy> Bootstrapper::NewRemoteContext( |
324 MaybeHandle<JSGlobalProxy> maybe_global_proxy, | 328 MaybeHandle<JSGlobalProxy> maybe_global_proxy, |
325 v8::Local<v8::ObjectTemplate> global_proxy_template) { | 329 v8::Local<v8::ObjectTemplate> global_proxy_template) { |
(...skipping 4179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4505 if (enabled_) { | 4509 if (enabled_) { |
4506 FLAG_track_double_fields = flag_; | 4510 FLAG_track_double_fields = flag_; |
4507 } | 4511 } |
4508 } | 4512 } |
4509 | 4513 |
4510 private: | 4514 private: |
4511 bool flag_; | 4515 bool flag_; |
4512 bool enabled_; | 4516 bool enabled_; |
4513 }; | 4517 }; |
4514 | 4518 |
4515 Genesis::Genesis(Isolate* isolate, | 4519 Genesis::Genesis( |
4516 MaybeHandle<JSGlobalProxy> maybe_global_proxy, | 4520 Isolate* isolate, MaybeHandle<JSGlobalProxy> maybe_global_proxy, |
4517 v8::Local<v8::ObjectTemplate> global_proxy_template, | 4521 v8::Local<v8::ObjectTemplate> global_proxy_template, |
4518 size_t context_snapshot_index, GlobalContextType context_type) | 4522 size_t context_snapshot_index, |
| 4523 v8::DeserializeInternalFieldsCallback internal_fields_deserializer, |
| 4524 GlobalContextType context_type) |
4519 : isolate_(isolate), active_(isolate->bootstrapper()) { | 4525 : isolate_(isolate), active_(isolate->bootstrapper()) { |
4520 NoTrackDoubleFieldsForSerializerScope disable_scope(isolate); | 4526 NoTrackDoubleFieldsForSerializerScope disable_scope(isolate); |
4521 result_ = Handle<Context>::null(); | 4527 result_ = Handle<Context>::null(); |
4522 global_proxy_ = Handle<JSGlobalProxy>::null(); | 4528 global_proxy_ = Handle<JSGlobalProxy>::null(); |
4523 | 4529 |
4524 // Before creating the roots we must save the context and restore it | 4530 // Before creating the roots we must save the context and restore it |
4525 // on all function exits. | 4531 // on all function exits. |
4526 SaveContext saved_context(isolate); | 4532 SaveContext saved_context(isolate); |
4527 | 4533 |
4528 // During genesis, the boilerplate for stack overflow won't work until the | 4534 // During genesis, the boilerplate for stack overflow won't work until the |
(...skipping 26 matching lines...) Expand all Loading... |
4555 } | 4561 } |
4556 global_proxy = | 4562 global_proxy = |
4557 isolate->factory()->NewUninitializedJSGlobalProxy(instance_size); | 4563 isolate->factory()->NewUninitializedJSGlobalProxy(instance_size); |
4558 } | 4564 } |
4559 | 4565 |
4560 // We can only de-serialize a context if the isolate was initialized from | 4566 // We can only de-serialize a context if the isolate was initialized from |
4561 // a snapshot. Otherwise we have to build the context from scratch. | 4567 // a snapshot. Otherwise we have to build the context from scratch. |
4562 // Also create a context from scratch to expose natives, if required by flag. | 4568 // Also create a context from scratch to expose natives, if required by flag. |
4563 if (!isolate->initialized_from_snapshot() || | 4569 if (!isolate->initialized_from_snapshot() || |
4564 !Snapshot::NewContextFromSnapshot(isolate, global_proxy, | 4570 !Snapshot::NewContextFromSnapshot(isolate, global_proxy, |
4565 context_snapshot_index) | 4571 context_snapshot_index, |
| 4572 internal_fields_deserializer) |
4566 .ToHandle(&native_context_)) { | 4573 .ToHandle(&native_context_)) { |
4567 native_context_ = Handle<Context>(); | 4574 native_context_ = Handle<Context>(); |
4568 } | 4575 } |
4569 | 4576 |
4570 if (!native_context().is_null()) { | 4577 if (!native_context().is_null()) { |
4571 AddToWeakNativeContextList(*native_context()); | 4578 AddToWeakNativeContextList(*native_context()); |
4572 isolate->set_context(*native_context()); | 4579 isolate->set_context(*native_context()); |
4573 isolate->counters()->contexts_created_by_snapshot()->Increment(); | 4580 isolate->counters()->contexts_created_by_snapshot()->Increment(); |
4574 #if TRACE_MAPS | 4581 #if TRACE_MAPS |
4575 if (FLAG_trace_maps) { | 4582 if (FLAG_trace_maps) { |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4734 } | 4741 } |
4735 | 4742 |
4736 | 4743 |
4737 // Called when the top-level V8 mutex is destroyed. | 4744 // Called when the top-level V8 mutex is destroyed. |
4738 void Bootstrapper::FreeThreadResources() { | 4745 void Bootstrapper::FreeThreadResources() { |
4739 DCHECK(!IsActive()); | 4746 DCHECK(!IsActive()); |
4740 } | 4747 } |
4741 | 4748 |
4742 } // namespace internal | 4749 } // namespace internal |
4743 } // namespace v8 | 4750 } // namespace v8 |
OLD | NEW |