Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Unified Diff: src/api.cc

Issue 2585693002: [serializer] allocate global proxy with the expected size. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/bootstrapper.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index 632ab9d3688a02b3a7b9eb66b113013ee45cd224..912b5467bf7cf3f45f5e068a0a26be4f834f6dde 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -551,6 +551,8 @@ StartupData SnapshotCreator::CreateBlob(
DCHECK(!data->created_);
DCHECK(!data->default_context_.IsEmpty());
+ int num_additional_contexts = static_cast<int>(data->contexts_.Size());
+
{
int num_templates = static_cast<int>(data->templates_.Size());
i::HandleScope scope(isolate);
@@ -561,6 +563,18 @@ StartupData SnapshotCreator::CreateBlob(
}
isolate->heap()->SetSerializedTemplates(*templates);
data->templates_.Clear();
+
+ // We need to store the global proxy size upfront in case we need the
+ // bootstrapper to create a global proxy before we deserialize the context.
+ i::Handle<i::FixedArray> global_proxy_sizes =
+ isolate->factory()->NewFixedArray(num_additional_contexts, i::TENURED);
+ for (int i = 0; i < num_additional_contexts; i++) {
+ i::Handle<i::Context> context =
+ v8::Utils::OpenHandle(*data->contexts_.Get(i));
+ global_proxy_sizes->set(i,
+ i::Smi::FromInt(context->global_proxy()->Size()));
+ }
+ isolate->heap()->SetSerializedGlobalProxySizes(*global_proxy_sizes);
}
// If we don't do this then we end up with a stray root pointing at the
@@ -571,7 +585,6 @@ StartupData SnapshotCreator::CreateBlob(
i::DisallowHeapAllocation no_gc_from_here_on;
- int num_additional_contexts = static_cast<int>(data->contexts_.Size());
i::List<i::Object*> contexts(num_additional_contexts);
i::Object* default_context;
{
« no previous file with comments | « no previous file | src/bootstrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698