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

Side by Side Diff: test/cctest/test-serialize.cc

Issue 2571743002: [serializer] API to re-use global proxy in v8::Context::FromSnapshot. (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 unified diff | Download patch
« no previous file with comments | « src/snapshot/snapshot-common.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2007-2010 the V8 project authors. All rights reserved. 1 // Copyright 2007-2010 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 2425 matching lines...) Expand 10 before | Expand all | Expand 10 after
2436 v8::TryCatch try_catch(isolate); 2436 v8::TryCatch try_catch(isolate);
2437 CHECK(CompileRun("x").IsEmpty()); 2437 CHECK(CompileRun("x").IsEmpty());
2438 CHECK(try_catch.HasCaught()); 2438 CHECK(try_catch.HasCaught());
2439 } 2439 }
2440 { 2440 {
2441 // Create a new context from first additional context snapshot. This 2441 // Create a new context from first additional context snapshot. This
2442 // will use the global object from the snapshot, including interceptor. 2442 // will use the global object from the snapshot, including interceptor.
2443 v8::HandleScope handle_scope(isolate); 2443 v8::HandleScope handle_scope(isolate);
2444 v8::Local<v8::Context> context = 2444 v8::Local<v8::Context> context =
2445 v8::Context::FromSnapshot(isolate, 0).ToLocalChecked(); 2445 v8::Context::FromSnapshot(isolate, 0).ToLocalChecked();
2446 v8::Context::Scope context_scope(context); 2446 {
2447 ExpectInt32("f()", 42); 2447 v8::Context::Scope context_scope(context);
2448 ExpectInt32("g()", 12); 2448 ExpectInt32("f()", 42);
2449 ExpectInt32("h()", 13); 2449 ExpectInt32("g()", 12);
2450 ExpectInt32("i()", 24); 2450 ExpectInt32("h()", 13);
2451 ExpectInt32("j()", 25); 2451 ExpectInt32("i()", 24);
2452 ExpectInt32("o.p", 8); 2452 ExpectInt32("j()", 25);
2453 ExpectInt32("x", 2016); 2453 ExpectInt32("o.p", 8);
2454 ExpectInt32("y", 2017); 2454 ExpectInt32("x", 2016);
2455 }
2456
2457 v8::Local<v8::Object> global = context->Global();
2458 context->DetachGlobal();
2459
2460 // New context, but reuse global proxy.
2461 v8::ExtensionConfiguration* no_extensions = nullptr;
2462 v8::Local<v8::Context> context2 =
2463 v8::Context::FromSnapshot(isolate, 0, no_extensions, global)
2464 .ToLocalChecked();
2465 {
2466 v8::Context::Scope context_scope(context2);
2467 ExpectInt32("f()", 42);
2468 ExpectInt32("g()", 12);
2469 ExpectInt32("h()", 13);
2470 ExpectInt32("i()", 24);
2471 ExpectInt32("j()", 25);
2472 ExpectInt32("o.p", 8);
2473 ExpectInt32("x", 2016);
2474 }
2475
2476 CHECK(context2->Global()->Equals(context2, global).FromJust());
2455 } 2477 }
2456 } 2478 }
2457 isolate->Dispose(); 2479 isolate->Dispose();
2458 } 2480 }
2459 delete[] blob.data; 2481 delete[] blob.data;
2460 } 2482 }
2461 2483
2462 TEST(SerializationMemoryStats) { 2484 TEST(SerializationMemoryStats) {
2463 FLAG_profile_deserialization = true; 2485 FLAG_profile_deserialization = true;
2464 FLAG_always_opt = false; 2486 FLAG_always_opt = false;
2465 v8::StartupData blob = v8::V8::CreateSnapshotDataBlob(); 2487 v8::StartupData blob = v8::V8::CreateSnapshotDataBlob();
2466 delete[] blob.data; 2488 delete[] blob.data;
2467 } 2489 }
OLDNEW
« no previous file with comments | « src/snapshot/snapshot-common.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698