| 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 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 | 314 |
| 315 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate); | 315 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate); |
| 316 HandleScope handle_scope(isolate); | 316 HandleScope handle_scope(isolate); |
| 317 Handle<Object> root; | 317 Handle<Object> root; |
| 318 // Intentionally empty handle. The deserializer should not come across | 318 // Intentionally empty handle. The deserializer should not come across |
| 319 // any references to the global proxy in this test. | 319 // any references to the global proxy in this test. |
| 320 Handle<JSGlobalProxy> global_proxy = Handle<JSGlobalProxy>::null(); | 320 Handle<JSGlobalProxy> global_proxy = Handle<JSGlobalProxy>::null(); |
| 321 { | 321 { |
| 322 SnapshotData snapshot_data(partial_blob); | 322 SnapshotData snapshot_data(partial_blob); |
| 323 Deserializer deserializer(&snapshot_data); | 323 Deserializer deserializer(&snapshot_data); |
| 324 root = deserializer.DeserializePartial(isolate, global_proxy) | 324 root = deserializer.DeserializePartial(isolate, global_proxy, nullptr) |
| 325 .ToHandleChecked(); | 325 .ToHandleChecked(); |
| 326 CHECK(root->IsString()); | 326 CHECK(root->IsString()); |
| 327 } | 327 } |
| 328 | 328 |
| 329 Handle<Object> root2; | 329 Handle<Object> root2; |
| 330 { | 330 { |
| 331 SnapshotData snapshot_data(partial_blob); | 331 SnapshotData snapshot_data(partial_blob); |
| 332 Deserializer deserializer(&snapshot_data); | 332 Deserializer deserializer(&snapshot_data); |
| 333 root2 = deserializer.DeserializePartial(isolate, global_proxy) | 333 root2 = deserializer.DeserializePartial(isolate, global_proxy, nullptr) |
| 334 .ToHandleChecked(); | 334 .ToHandleChecked(); |
| 335 CHECK(root2->IsString()); | 335 CHECK(root2->IsString()); |
| 336 CHECK(root.is_identical_to(root2)); | 336 CHECK(root.is_identical_to(root2)); |
| 337 } | 337 } |
| 338 partial_blob.Dispose(); | 338 partial_blob.Dispose(); |
| 339 } | 339 } |
| 340 v8_isolate->Dispose(); | 340 v8_isolate->Dispose(); |
| 341 } | 341 } |
| 342 | 342 |
| 343 static void PartiallySerializeContext(Vector<const byte>* startup_blob_out, | 343 static void PartiallySerializeContext(Vector<const byte>* startup_blob_out, |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 | 412 |
| 413 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate); | 413 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate); |
| 414 HandleScope handle_scope(isolate); | 414 HandleScope handle_scope(isolate); |
| 415 Handle<Object> root; | 415 Handle<Object> root; |
| 416 Handle<JSGlobalProxy> global_proxy = | 416 Handle<JSGlobalProxy> global_proxy = |
| 417 isolate->factory()->NewUninitializedJSGlobalProxy( | 417 isolate->factory()->NewUninitializedJSGlobalProxy( |
| 418 JSGlobalProxy::SizeWithInternalFields(0)); | 418 JSGlobalProxy::SizeWithInternalFields(0)); |
| 419 { | 419 { |
| 420 SnapshotData snapshot_data(partial_blob); | 420 SnapshotData snapshot_data(partial_blob); |
| 421 Deserializer deserializer(&snapshot_data); | 421 Deserializer deserializer(&snapshot_data); |
| 422 root = deserializer.DeserializePartial(isolate, global_proxy) | 422 root = deserializer.DeserializePartial(isolate, global_proxy, nullptr) |
| 423 .ToHandleChecked(); | 423 .ToHandleChecked(); |
| 424 CHECK(root->IsContext()); | 424 CHECK(root->IsContext()); |
| 425 CHECK(Handle<Context>::cast(root)->global_proxy() == *global_proxy); | 425 CHECK(Handle<Context>::cast(root)->global_proxy() == *global_proxy); |
| 426 } | 426 } |
| 427 | 427 |
| 428 Handle<Object> root2; | 428 Handle<Object> root2; |
| 429 { | 429 { |
| 430 SnapshotData snapshot_data(partial_blob); | 430 SnapshotData snapshot_data(partial_blob); |
| 431 Deserializer deserializer(&snapshot_data); | 431 Deserializer deserializer(&snapshot_data); |
| 432 root2 = deserializer.DeserializePartial(isolate, global_proxy) | 432 root2 = deserializer.DeserializePartial(isolate, global_proxy, nullptr) |
| 433 .ToHandleChecked(); | 433 .ToHandleChecked(); |
| 434 CHECK(root2->IsContext()); | 434 CHECK(root2->IsContext()); |
| 435 CHECK(!root.is_identical_to(root2)); | 435 CHECK(!root.is_identical_to(root2)); |
| 436 } | 436 } |
| 437 partial_blob.Dispose(); | 437 partial_blob.Dispose(); |
| 438 } | 438 } |
| 439 v8_isolate->Dispose(); | 439 v8_isolate->Dispose(); |
| 440 } | 440 } |
| 441 | 441 |
| 442 static void PartiallySerializeCustomContext( | 442 static void PartiallySerializeCustomContext( |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 | 532 |
| 533 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate); | 533 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate); |
| 534 HandleScope handle_scope(isolate); | 534 HandleScope handle_scope(isolate); |
| 535 Handle<Object> root; | 535 Handle<Object> root; |
| 536 Handle<JSGlobalProxy> global_proxy = | 536 Handle<JSGlobalProxy> global_proxy = |
| 537 isolate->factory()->NewUninitializedJSGlobalProxy( | 537 isolate->factory()->NewUninitializedJSGlobalProxy( |
| 538 JSGlobalProxy::SizeWithInternalFields(0)); | 538 JSGlobalProxy::SizeWithInternalFields(0)); |
| 539 { | 539 { |
| 540 SnapshotData snapshot_data(partial_blob); | 540 SnapshotData snapshot_data(partial_blob); |
| 541 Deserializer deserializer(&snapshot_data); | 541 Deserializer deserializer(&snapshot_data); |
| 542 root = deserializer.DeserializePartial(isolate, global_proxy) | 542 root = deserializer.DeserializePartial(isolate, global_proxy, nullptr) |
| 543 .ToHandleChecked(); | 543 .ToHandleChecked(); |
| 544 CHECK(root->IsContext()); | 544 CHECK(root->IsContext()); |
| 545 Handle<Context> context = Handle<Context>::cast(root); | 545 Handle<Context> context = Handle<Context>::cast(root); |
| 546 | 546 |
| 547 // Add context to the weak native context list | 547 // Add context to the weak native context list |
| 548 context->set(Context::NEXT_CONTEXT_LINK, | 548 context->set(Context::NEXT_CONTEXT_LINK, |
| 549 isolate->heap()->native_contexts_list(), | 549 isolate->heap()->native_contexts_list(), |
| 550 UPDATE_WEAK_WRITE_BARRIER); | 550 UPDATE_WEAK_WRITE_BARRIER); |
| 551 isolate->heap()->set_native_contexts_list(*context); | 551 isolate->heap()->set_native_contexts_list(*context); |
| 552 | 552 |
| (...skipping 1643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2196 { | 2196 { |
| 2197 v8::HandleScope handle_scope(isolate); | 2197 v8::HandleScope handle_scope(isolate); |
| 2198 v8::ExtensionConfiguration* no_extension = nullptr; | 2198 v8::ExtensionConfiguration* no_extension = nullptr; |
| 2199 v8::Local<v8::ObjectTemplate> global_template = | 2199 v8::Local<v8::ObjectTemplate> global_template = |
| 2200 v8::ObjectTemplate::New(isolate); | 2200 v8::ObjectTemplate::New(isolate); |
| 2201 v8::Local<v8::FunctionTemplate> callback = | 2201 v8::Local<v8::FunctionTemplate> callback = |
| 2202 v8::FunctionTemplate::New(isolate, SerializedCallback); | 2202 v8::FunctionTemplate::New(isolate, SerializedCallback); |
| 2203 global_template->Set(v8_str("f"), callback); | 2203 global_template->Set(v8_str("f"), callback); |
| 2204 v8::Local<v8::Context> context = | 2204 v8::Local<v8::Context> context = |
| 2205 v8::Context::New(isolate, no_extension, global_template); | 2205 v8::Context::New(isolate, no_extension, global_template); |
| 2206 creator.SetDefaultContext(context); |
| 2207 context = v8::Context::New(isolate, no_extension, global_template); |
| 2206 v8::Local<v8::ObjectTemplate> object_template = | 2208 v8::Local<v8::ObjectTemplate> object_template = |
| 2207 v8::ObjectTemplate::New(isolate); | 2209 v8::ObjectTemplate::New(isolate); |
| 2208 object_template->SetInternalFieldCount(3); | 2210 object_template->SetInternalFieldCount(3); |
| 2209 | 2211 |
| 2210 v8::Context::Scope context_scope(context); | 2212 v8::Context::Scope context_scope(context); |
| 2211 ExpectInt32("f()", 42); | 2213 ExpectInt32("f()", 42); |
| 2212 | 2214 |
| 2213 v8::Local<v8::Object> a = | 2215 v8::Local<v8::Object> a = |
| 2214 object_template->NewInstance(context).ToLocalChecked(); | 2216 object_template->NewInstance(context).ToLocalChecked(); |
| 2215 v8::Local<v8::Object> b = | 2217 v8::Local<v8::Object> b = |
| 2216 object_template->NewInstance(context).ToLocalChecked(); | 2218 object_template->NewInstance(context).ToLocalChecked(); |
| 2217 v8::Local<v8::Object> c = | 2219 v8::Local<v8::Object> c = |
| 2218 object_template->NewInstance(context).ToLocalChecked(); | 2220 object_template->NewInstance(context).ToLocalChecked(); |
| 2219 v8::Local<v8::External> null_external = | 2221 v8::Local<v8::External> null_external = |
| 2220 v8::External::New(isolate, nullptr); | 2222 v8::External::New(isolate, nullptr); |
| 2221 v8::Local<v8::External> field_external = | 2223 v8::Local<v8::External> field_external = |
| 2222 v8::External::New(isolate, &serialized_static_field); | 2224 v8::External::New(isolate, &serialized_static_field); |
| 2223 a->SetInternalField(0, b); | 2225 a->SetInternalField(0, b); |
| 2224 a->SetAlignedPointerInInternalField(1, a1); | 2226 a->SetAlignedPointerInInternalField(1, a1); |
| 2225 b->SetAlignedPointerInInternalField(0, b0); | 2227 b->SetAlignedPointerInInternalField(0, b0); |
| 2226 b->SetInternalField(1, c); | 2228 b->SetInternalField(1, c); |
| 2227 c->SetAlignedPointerInInternalField(0, c0); | 2229 c->SetAlignedPointerInInternalField(0, c0); |
| 2228 c->SetInternalField(1, null_external); | 2230 c->SetInternalField(1, null_external); |
| 2229 c->SetInternalField(2, field_external); | 2231 c->SetInternalField(2, field_external); |
| 2230 CHECK(context->Global()->Set(context, v8_str("a"), a).FromJust()); | 2232 CHECK(context->Global()->Set(context, v8_str("a"), a).FromJust()); |
| 2231 | 2233 |
| 2232 creator.SetDefaultContext(context); | 2234 CHECK_EQ(0u, creator.AddContext(context, SerializeInternalFields)); |
| 2233 CHECK_EQ(0u, creator.AddTemplate(callback)); | 2235 CHECK_EQ(0u, creator.AddTemplate(callback)); |
| 2234 CHECK_EQ(1u, creator.AddTemplate(global_template)); | 2236 CHECK_EQ(1u, creator.AddTemplate(global_template)); |
| 2235 } | 2237 } |
| 2236 blob = creator.CreateBlob(v8::SnapshotCreator::FunctionCodeHandling::kClear, | 2238 blob = |
| 2237 SerializeInternalFields); | 2239 creator.CreateBlob(v8::SnapshotCreator::FunctionCodeHandling::kClear); |
| 2238 | 2240 |
| 2239 delete a1; | 2241 delete a1; |
| 2240 delete b0; | 2242 delete b0; |
| 2241 delete c0; | 2243 delete c0; |
| 2242 } | 2244 } |
| 2243 | 2245 |
| 2244 { | 2246 { |
| 2245 v8::Isolate::CreateParams params; | 2247 v8::Isolate::CreateParams params; |
| 2246 params.snapshot_blob = &blob; | 2248 params.snapshot_blob = &blob; |
| 2247 params.array_buffer_allocator = CcTest::array_buffer_allocator(); | 2249 params.array_buffer_allocator = CcTest::array_buffer_allocator(); |
| 2248 params.external_references = original_external_references; | 2250 params.external_references = original_external_references; |
| 2249 params.deserialize_internal_fields_callback = DeserializeInternalFields; | |
| 2250 v8::Isolate* isolate = v8::Isolate::New(params); | 2251 v8::Isolate* isolate = v8::Isolate::New(params); |
| 2251 { | 2252 { |
| 2252 v8::Isolate::Scope isolate_scope(isolate); | 2253 v8::Isolate::Scope isolate_scope(isolate); |
| 2253 { | 2254 { |
| 2254 // Create a new context without a new object template. | 2255 // Create a new context without a new object template. |
| 2255 v8::HandleScope handle_scope(isolate); | 2256 v8::HandleScope handle_scope(isolate); |
| 2256 v8::Local<v8::Context> context = v8::Context::New(isolate); | 2257 v8::Local<v8::Context> context = |
| 2258 v8::Context::FromSnapshot(isolate, 0, DeserializeInternalFields) |
| 2259 .ToLocalChecked(); |
| 2257 v8::Context::Scope context_scope(context); | 2260 v8::Context::Scope context_scope(context); |
| 2258 ExpectInt32("f()", 42); | 2261 ExpectInt32("f()", 42); |
| 2259 | 2262 |
| 2260 // Retrieve the snapshotted object template. | 2263 // Retrieve the snapshotted object template. |
| 2261 v8::Local<v8::ObjectTemplate> obj_template = | 2264 v8::Local<v8::ObjectTemplate> obj_template = |
| 2262 v8::ObjectTemplate::FromSnapshot(isolate, 1).ToLocalChecked(); | 2265 v8::ObjectTemplate::FromSnapshot(isolate, 1).ToLocalChecked(); |
| 2263 CHECK(!obj_template.IsEmpty()); | 2266 CHECK(!obj_template.IsEmpty()); |
| 2264 v8::Local<v8::Object> object = | 2267 v8::Local<v8::Object> object = |
| 2265 obj_template->NewInstance(context).ToLocalChecked(); | 2268 obj_template->NewInstance(context).ToLocalChecked(); |
| 2266 CHECK(context->Global()->Set(context, v8_str("o"), object).FromJust()); | 2269 CHECK(context->Global()->Set(context, v8_str("o"), object).FromJust()); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2313 v8::Local<v8::External>::Cast(c2)->Value()); | 2316 v8::Local<v8::External>::Cast(c2)->Value()); |
| 2314 | 2317 |
| 2315 // Accessing out of bound returns empty MaybeHandle. | 2318 // Accessing out of bound returns empty MaybeHandle. |
| 2316 CHECK(v8::ObjectTemplate::FromSnapshot(isolate, 2).IsEmpty()); | 2319 CHECK(v8::ObjectTemplate::FromSnapshot(isolate, 2).IsEmpty()); |
| 2317 CHECK(v8::FunctionTemplate::FromSnapshot(isolate, 2).IsEmpty()); | 2320 CHECK(v8::FunctionTemplate::FromSnapshot(isolate, 2).IsEmpty()); |
| 2318 CHECK(v8::Context::FromSnapshot(isolate, 1).IsEmpty()); | 2321 CHECK(v8::Context::FromSnapshot(isolate, 1).IsEmpty()); |
| 2319 | 2322 |
| 2320 for (auto data : deserialized_data) delete data; | 2323 for (auto data : deserialized_data) delete data; |
| 2321 deserialized_data.clear(); | 2324 deserialized_data.clear(); |
| 2322 } | 2325 } |
| 2323 | |
| 2324 { | |
| 2325 // Create a context with a new object template. It is merged into the | |
| 2326 // deserialized global object. | |
| 2327 v8::HandleScope handle_scope(isolate); | |
| 2328 v8::ExtensionConfiguration* no_extension = nullptr; | |
| 2329 v8::Local<v8::ObjectTemplate> global_template = | |
| 2330 v8::ObjectTemplate::New(isolate); | |
| 2331 global_template->Set( | |
| 2332 v8_str("g"), | |
| 2333 v8::FunctionTemplate::New(isolate, SerializedCallbackReplacement)); | |
| 2334 v8::Local<v8::Context> context = | |
| 2335 v8::Context::New(isolate, no_extension, global_template); | |
| 2336 v8::Context::Scope context_scope(context); | |
| 2337 ExpectInt32("g()", 1337); | |
| 2338 ExpectInt32("f()", 42); | |
| 2339 | |
| 2340 for (auto data : deserialized_data) delete data; | |
| 2341 deserialized_data.clear(); | |
| 2342 } | |
| 2343 } | 2326 } |
| 2344 isolate->Dispose(); | 2327 isolate->Dispose(); |
| 2345 } | 2328 } |
| 2346 delete[] blob.data; | 2329 delete[] blob.data; |
| 2347 } | 2330 } |
| 2348 | 2331 |
| 2349 TEST(SnapshotCreatorIncludeGlobalProxy) { | 2332 TEST(SnapshotCreatorIncludeGlobalProxy) { |
| 2350 DisableAlwaysOpt(); | 2333 DisableAlwaysOpt(); |
| 2351 v8::StartupData blob; | 2334 v8::StartupData blob; |
| 2352 | 2335 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2418 ExpectInt32("h()", 13); | 2401 ExpectInt32("h()", 13); |
| 2419 ExpectInt32("o.p", 7); | 2402 ExpectInt32("o.p", 7); |
| 2420 ExpectInt32("x", 2016); | 2403 ExpectInt32("x", 2016); |
| 2421 ExpectInt32("y", 2017); | 2404 ExpectInt32("y", 2017); |
| 2422 CHECK(v8_str("hidden string") | 2405 CHECK(v8_str("hidden string") |
| 2423 ->Equals(context, context->Global() | 2406 ->Equals(context, context->Global() |
| 2424 ->GetPrivate(context, hidden) | 2407 ->GetPrivate(context, hidden) |
| 2425 .ToLocalChecked()) | 2408 .ToLocalChecked()) |
| 2426 .FromJust()); | 2409 .FromJust()); |
| 2427 | 2410 |
| 2428 CHECK_EQ(0u, creator.AddContext(context)); | 2411 CHECK_EQ(0u, creator.AddContext(context, SerializeInternalFields)); |
| 2429 } | 2412 } |
| 2430 blob = creator.CreateBlob(v8::SnapshotCreator::FunctionCodeHandling::kClear, | 2413 blob = |
| 2431 SerializeInternalFields); | 2414 creator.CreateBlob(v8::SnapshotCreator::FunctionCodeHandling::kClear); |
| 2432 } | 2415 } |
| 2433 | 2416 |
| 2434 { | 2417 { |
| 2435 v8::Isolate::CreateParams params; | 2418 v8::Isolate::CreateParams params; |
| 2436 params.snapshot_blob = &blob; | 2419 params.snapshot_blob = &blob; |
| 2437 params.array_buffer_allocator = CcTest::array_buffer_allocator(); | 2420 params.array_buffer_allocator = CcTest::array_buffer_allocator(); |
| 2438 params.external_references = original_external_references; | 2421 params.external_references = original_external_references; |
| 2439 params.deserialize_internal_fields_callback = DeserializeInternalFields; | |
| 2440 v8::Isolate* isolate = v8::Isolate::New(params); | 2422 v8::Isolate* isolate = v8::Isolate::New(params); |
| 2441 { | 2423 { |
| 2442 v8::Isolate::Scope isolate_scope(isolate); | 2424 v8::Isolate::Scope isolate_scope(isolate); |
| 2443 // We can introduce new extensions, which could override the already | 2425 // We can introduce new extensions, which could override the already |
| 2444 // snapshotted extension. | 2426 // snapshotted extension. |
| 2445 v8::Extension* extension = new v8::Extension("new extension", | 2427 v8::Extension* extension = new v8::Extension("new extension", |
| 2446 "function i() { return 24; }" | 2428 "function i() { return 24; }" |
| 2447 "function j() { return 25; }" | 2429 "function j() { return 25; }" |
| 2448 "if (o.p == 7) o.p++;"); | 2430 "if (o.p == 7) o.p++;"); |
| 2449 extension->set_auto_enable(true); | 2431 extension->set_auto_enable(true); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2463 ExpectInt32("o.p", 8); | 2445 ExpectInt32("o.p", 8); |
| 2464 v8::TryCatch try_catch(isolate); | 2446 v8::TryCatch try_catch(isolate); |
| 2465 CHECK(CompileRun("x").IsEmpty()); | 2447 CHECK(CompileRun("x").IsEmpty()); |
| 2466 CHECK(try_catch.HasCaught()); | 2448 CHECK(try_catch.HasCaught()); |
| 2467 } | 2449 } |
| 2468 { | 2450 { |
| 2469 // Create a new context from first additional context snapshot. This | 2451 // Create a new context from first additional context snapshot. This |
| 2470 // will use the global object from the snapshot, including interceptor. | 2452 // will use the global object from the snapshot, including interceptor. |
| 2471 v8::HandleScope handle_scope(isolate); | 2453 v8::HandleScope handle_scope(isolate); |
| 2472 v8::Local<v8::Context> context = | 2454 v8::Local<v8::Context> context = |
| 2473 v8::Context::FromSnapshot(isolate, 0).ToLocalChecked(); | 2455 v8::Context::FromSnapshot(isolate, 0, DeserializeInternalFields) |
| 2456 .ToLocalChecked(); |
| 2474 { | 2457 { |
| 2475 v8::Context::Scope context_scope(context); | 2458 v8::Context::Scope context_scope(context); |
| 2476 ExpectInt32("f()", 42); | 2459 ExpectInt32("f()", 42); |
| 2477 ExpectInt32("g()", 12); | 2460 ExpectInt32("g()", 12); |
| 2478 ExpectInt32("h()", 13); | 2461 ExpectInt32("h()", 13); |
| 2479 ExpectInt32("i()", 24); | 2462 ExpectInt32("i()", 24); |
| 2480 ExpectInt32("j()", 25); | 2463 ExpectInt32("j()", 25); |
| 2481 ExpectInt32("o.p", 8); | 2464 ExpectInt32("o.p", 8); |
| 2482 ExpectInt32("x", 2016); | 2465 ExpectInt32("x", 2016); |
| 2483 v8::Local<v8::Private> hidden = | 2466 v8::Local<v8::Private> hidden = |
| 2484 v8::Private::ForApi(isolate, v8_str("hidden")); | 2467 v8::Private::ForApi(isolate, v8_str("hidden")); |
| 2485 CHECK(v8_str("hidden string") | 2468 CHECK(v8_str("hidden string") |
| 2486 ->Equals(context, context->Global() | 2469 ->Equals(context, context->Global() |
| 2487 ->GetPrivate(context, hidden) | 2470 ->GetPrivate(context, hidden) |
| 2488 .ToLocalChecked()) | 2471 .ToLocalChecked()) |
| 2489 .FromJust()); | 2472 .FromJust()); |
| 2490 ExpectString("cached", "cached string"); | 2473 ExpectString("cached", "cached string"); |
| 2491 } | 2474 } |
| 2492 | 2475 |
| 2493 v8::Local<v8::Object> global = context->Global(); | 2476 v8::Local<v8::Object> global = context->Global(); |
| 2494 CHECK_EQ(3, global->InternalFieldCount()); | 2477 CHECK_EQ(3, global->InternalFieldCount()); |
| 2495 context->DetachGlobal(); | 2478 context->DetachGlobal(); |
| 2496 | 2479 |
| 2497 // New context, but reuse global proxy. | 2480 // New context, but reuse global proxy. |
| 2498 v8::ExtensionConfiguration* no_extensions = nullptr; | 2481 v8::ExtensionConfiguration* no_extensions = nullptr; |
| 2499 v8::Local<v8::Context> context2 = | 2482 v8::Local<v8::Context> context2 = |
| 2500 v8::Context::FromSnapshot(isolate, 0, no_extensions, global) | 2483 v8::Context::FromSnapshot(isolate, 0, DeserializeInternalFields, |
| 2484 no_extensions, global) |
| 2501 .ToLocalChecked(); | 2485 .ToLocalChecked(); |
| 2502 { | 2486 { |
| 2503 v8::Context::Scope context_scope(context2); | 2487 v8::Context::Scope context_scope(context2); |
| 2504 ExpectInt32("f()", 42); | 2488 ExpectInt32("f()", 42); |
| 2505 ExpectInt32("g()", 12); | 2489 ExpectInt32("g()", 12); |
| 2506 ExpectInt32("h()", 13); | 2490 ExpectInt32("h()", 13); |
| 2507 ExpectInt32("i()", 24); | 2491 ExpectInt32("i()", 24); |
| 2508 ExpectInt32("j()", 25); | 2492 ExpectInt32("j()", 25); |
| 2509 ExpectInt32("o.p", 8); | 2493 ExpectInt32("o.p", 8); |
| 2510 ExpectInt32("x", 2016); | 2494 ExpectInt32("x", 2016); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2532 } | 2516 } |
| 2533 delete[] blob.data; | 2517 delete[] blob.data; |
| 2534 } | 2518 } |
| 2535 | 2519 |
| 2536 TEST(SerializationMemoryStats) { | 2520 TEST(SerializationMemoryStats) { |
| 2537 FLAG_profile_deserialization = true; | 2521 FLAG_profile_deserialization = true; |
| 2538 FLAG_always_opt = false; | 2522 FLAG_always_opt = false; |
| 2539 v8::StartupData blob = v8::V8::CreateSnapshotDataBlob(); | 2523 v8::StartupData blob = v8::V8::CreateSnapshotDataBlob(); |
| 2540 delete[] blob.data; | 2524 delete[] blob.data; |
| 2541 } | 2525 } |
| OLD | NEW |