OLD | NEW |
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 Loading... |
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 } |
OLD | NEW |