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

Unified Diff: test/cctest/test-serialize.cc

Issue 2055203002: [snapshot] support multiple contexts in the same snapshot. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@sinkmember
Patch Set: fix test. again. Created 4 years, 6 months 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 | « src/snapshot/startup-serializer.cc ('k') | test/memory/Memory.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-serialize.cc
diff --git a/test/cctest/test-serialize.cc b/test/cctest/test-serialize.cc
index 0c2622b23c905dab0d74a23476a1af309689971b..45d7499e211a1d671857cd042fe44f0fdc438c63 100644
--- a/test/cctest/test-serialize.cc
+++ b/test/cctest/test-serialize.cc
@@ -1882,6 +1882,71 @@ TEST(CodeSerializerCell) {
}
#endif // V8_TARGET_ARCH_X64
+TEST(SnapshotCreatorMultipleContexts) {
+ DisableTurbofan();
+ v8::StartupData blob;
+ {
+ v8::SnapshotCreator creator;
+ v8::Isolate* isolate = creator.GetIsolate();
+ {
+ v8::HandleScope handle_scope(isolate);
+ v8::Local<v8::Context> context = v8::Context::New(isolate);
+ v8::Context::Scope context_scope(context);
+ CompileRun("var f = function() { return 1; }");
+ CHECK_EQ(0, creator.AddContext(context));
+ }
+ {
+ v8::HandleScope handle_scope(isolate);
+ v8::Local<v8::Context> context = v8::Context::New(isolate);
+ v8::Context::Scope context_scope(context);
+ CompileRun("var f = function() { return 2; }");
+ CHECK_EQ(1, creator.AddContext(context));
+ }
+ {
+ v8::HandleScope handle_scope(isolate);
+ v8::Local<v8::Context> context = v8::Context::New(isolate);
+ CHECK_EQ(2, creator.AddContext(context));
+ }
+ blob =
+ creator.CreateBlob(v8::SnapshotCreator::FunctionCodeHandling::kClear);
+ }
+
+ v8::Isolate::CreateParams params;
+ params.snapshot_blob = &blob;
+ params.array_buffer_allocator = CcTest::array_buffer_allocator();
+ v8::Isolate* isolate = v8::Isolate::New(params);
+ {
+ v8::Isolate::Scope isolate_scope(isolate);
+ v8::ExtensionConfiguration* no_extension = nullptr;
+ v8::Local<v8::ObjectTemplate> no_template = v8::Local<v8::ObjectTemplate>();
+ v8::Local<v8::Value> no_object = v8::Local<v8::Value>();
+ {
+ v8::HandleScope handle_scope(isolate);
+ v8::Local<v8::Context> context =
+ v8::Context::New(isolate, no_extension, no_template, no_object, 0);
+ v8::Context::Scope context_scope(context);
+ ExpectInt32("f()", 1);
+ }
+ {
+ v8::HandleScope handle_scope(isolate);
+ v8::Local<v8::Context> context =
+ v8::Context::New(isolate, no_extension, no_template, no_object, 1);
+ v8::Context::Scope context_scope(context);
+ ExpectInt32("f()", 2);
+ }
+ {
+ v8::HandleScope handle_scope(isolate);
+ v8::Local<v8::Context> context =
+ v8::Context::New(isolate, no_extension, no_template, no_object, 2);
+ v8::Context::Scope context_scope(context);
+ ExpectUndefined("this.f");
+ }
+ }
+
+ isolate->Dispose();
+ delete[] blob.data;
+}
+
TEST(SerializationMemoryStats) {
FLAG_profile_deserialization = true;
FLAG_always_opt = false;
« no previous file with comments | « src/snapshot/startup-serializer.cc ('k') | test/memory/Memory.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698