| 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 4484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4495 if (check.HasOverflowed()) { | 4495 if (check.HasOverflowed()) { |
| 4496 isolate->StackOverflow(); | 4496 isolate->StackOverflow(); |
| 4497 return; | 4497 return; |
| 4498 } | 4498 } |
| 4499 | 4499 |
| 4500 // The deserializer needs to hook up references to the global proxy. | 4500 // The deserializer needs to hook up references to the global proxy. |
| 4501 // Create an uninitialized global proxy now if we don't have one | 4501 // Create an uninitialized global proxy now if we don't have one |
| 4502 // and initialize it later in CreateNewGlobals. | 4502 // and initialize it later in CreateNewGlobals. |
| 4503 Handle<JSGlobalProxy> global_proxy; | 4503 Handle<JSGlobalProxy> global_proxy; |
| 4504 if (!maybe_global_proxy.ToHandle(&global_proxy)) { | 4504 if (!maybe_global_proxy.ToHandle(&global_proxy)) { |
| 4505 const int internal_field_count = | 4505 int instance_size = 0; |
| 4506 !global_proxy_template.IsEmpty() | 4506 if (context_snapshot_index > 0) { |
| 4507 ? global_proxy_template->InternalFieldCount() | 4507 // The global proxy function to reinitialize this global proxy is in the |
| 4508 : 0; | 4508 // context that is yet to be deserialized. We need to prepare a global |
| 4509 global_proxy = isolate->factory()->NewUninitializedJSGlobalProxy( | 4509 // proxy of the correct size. |
| 4510 JSGlobalProxy::SizeWithInternalFields(internal_field_count)); | 4510 Object* size = isolate->heap()->serialized_global_proxy_sizes()->get( |
| 4511 static_cast<int>(context_snapshot_index) - 1); |
| 4512 instance_size = Smi::cast(size)->value(); |
| 4513 } else { |
| 4514 instance_size = JSGlobalProxy::SizeWithInternalFields( |
| 4515 global_proxy_template.IsEmpty() |
| 4516 ? 0 |
| 4517 : global_proxy_template->InternalFieldCount()); |
| 4518 } |
| 4519 global_proxy = |
| 4520 isolate->factory()->NewUninitializedJSGlobalProxy(instance_size); |
| 4511 } | 4521 } |
| 4512 | 4522 |
| 4513 // We can only de-serialize a context if the isolate was initialized from | 4523 // We can only de-serialize a context if the isolate was initialized from |
| 4514 // a snapshot. Otherwise we have to build the context from scratch. | 4524 // a snapshot. Otherwise we have to build the context from scratch. |
| 4515 // Also create a context from scratch to expose natives, if required by flag. | 4525 // Also create a context from scratch to expose natives, if required by flag. |
| 4516 if (!isolate->initialized_from_snapshot() || | 4526 if (!isolate->initialized_from_snapshot() || |
| 4517 !Snapshot::NewContextFromSnapshot(isolate, global_proxy, | 4527 !Snapshot::NewContextFromSnapshot(isolate, global_proxy, |
| 4518 context_snapshot_index) | 4528 context_snapshot_index) |
| 4519 .ToHandle(&native_context_)) { | 4529 .ToHandle(&native_context_)) { |
| 4520 native_context_ = Handle<Context>(); | 4530 native_context_ = Handle<Context>(); |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4687 } | 4697 } |
| 4688 | 4698 |
| 4689 | 4699 |
| 4690 // Called when the top-level V8 mutex is destroyed. | 4700 // Called when the top-level V8 mutex is destroyed. |
| 4691 void Bootstrapper::FreeThreadResources() { | 4701 void Bootstrapper::FreeThreadResources() { |
| 4692 DCHECK(!IsActive()); | 4702 DCHECK(!IsActive()); |
| 4693 } | 4703 } |
| 4694 | 4704 |
| 4695 } // namespace internal | 4705 } // namespace internal |
| 4696 } // namespace v8 | 4706 } // namespace v8 |
| OLD | NEW |