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

Side by Side Diff: test/cctest/test-serialize.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 unified diff | Download patch
« no previous file with comments | « src/heap/heap-inl.h ('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 2366 matching lines...) Expand 10 before | Expand all | Expand 10 after
2377 { 2377 {
2378 // Add additional context. This context implicitly *does* serialize 2378 // Add additional context. This context implicitly *does* serialize
2379 // the global proxy, and upon deserialization one has to be created 2379 // the global proxy, and upon deserialization one has to be created
2380 // in the bootstrapper from the global object template. 2380 // in the bootstrapper from the global object template.
2381 // Side effects from extensions are persisted. 2381 // Side effects from extensions are persisted.
2382 v8::HandleScope handle_scope(isolate); 2382 v8::HandleScope handle_scope(isolate);
2383 v8::Local<v8::ObjectTemplate> global_template = 2383 v8::Local<v8::ObjectTemplate> global_template =
2384 v8::ObjectTemplate::New(isolate); 2384 v8::ObjectTemplate::New(isolate);
2385 v8::Local<v8::FunctionTemplate> callback = 2385 v8::Local<v8::FunctionTemplate> callback =
2386 v8::FunctionTemplate::New(isolate, SerializedCallback); 2386 v8::FunctionTemplate::New(isolate, SerializedCallback);
2387 global_template->SetInternalFieldCount(3);
2387 global_template->Set(v8_str("f"), callback); 2388 global_template->Set(v8_str("f"), callback);
2388 global_template->SetHandler(v8::NamedPropertyHandlerConfiguration( 2389 global_template->SetHandler(v8::NamedPropertyHandlerConfiguration(
2389 NamedPropertyGetterForSerialization)); 2390 NamedPropertyGetterForSerialization));
2390 global_template->SetAccessor(v8_str("y"), AccessorForSerialization); 2391 global_template->SetAccessor(v8_str("y"), AccessorForSerialization);
2391 v8::Local<v8::Context> context = 2392 v8::Local<v8::Context> context =
2392 v8::Context::New(isolate, &extensions, global_template); 2393 v8::Context::New(isolate, &extensions, global_template);
2393 v8::Context::Scope context_scope(context); 2394 v8::Context::Scope context_scope(context);
2394 ExpectInt32("f()", 42); 2395 ExpectInt32("f()", 42);
2395 ExpectInt32("g()", 12); 2396 ExpectInt32("g()", 12);
2396 ExpectInt32("h()", 13); 2397 ExpectInt32("h()", 13);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
2448 ExpectInt32("f()", 42); 2449 ExpectInt32("f()", 42);
2449 ExpectInt32("g()", 12); 2450 ExpectInt32("g()", 12);
2450 ExpectInt32("h()", 13); 2451 ExpectInt32("h()", 13);
2451 ExpectInt32("i()", 24); 2452 ExpectInt32("i()", 24);
2452 ExpectInt32("j()", 25); 2453 ExpectInt32("j()", 25);
2453 ExpectInt32("o.p", 8); 2454 ExpectInt32("o.p", 8);
2454 ExpectInt32("x", 2016); 2455 ExpectInt32("x", 2016);
2455 } 2456 }
2456 2457
2457 v8::Local<v8::Object> global = context->Global(); 2458 v8::Local<v8::Object> global = context->Global();
2459 CHECK_EQ(3, global->InternalFieldCount());
2458 context->DetachGlobal(); 2460 context->DetachGlobal();
2459 2461
2460 // New context, but reuse global proxy. 2462 // New context, but reuse global proxy.
2461 v8::ExtensionConfiguration* no_extensions = nullptr; 2463 v8::ExtensionConfiguration* no_extensions = nullptr;
2462 v8::Local<v8::Context> context2 = 2464 v8::Local<v8::Context> context2 =
2463 v8::Context::FromSnapshot(isolate, 0, no_extensions, global) 2465 v8::Context::FromSnapshot(isolate, 0, no_extensions, global)
2464 .ToLocalChecked(); 2466 .ToLocalChecked();
2465 { 2467 {
2466 v8::Context::Scope context_scope(context2); 2468 v8::Context::Scope context_scope(context2);
2467 ExpectInt32("f()", 42); 2469 ExpectInt32("f()", 42);
(...skipping 12 matching lines...) Expand all
2480 } 2482 }
2481 delete[] blob.data; 2483 delete[] blob.data;
2482 } 2484 }
2483 2485
2484 TEST(SerializationMemoryStats) { 2486 TEST(SerializationMemoryStats) {
2485 FLAG_profile_deserialization = true; 2487 FLAG_profile_deserialization = true;
2486 FLAG_always_opt = false; 2488 FLAG_always_opt = false;
2487 v8::StartupData blob = v8::V8::CreateSnapshotDataBlob(); 2489 v8::StartupData blob = v8::V8::CreateSnapshotDataBlob();
2488 delete[] blob.data; 2490 delete[] blob.data;
2489 } 2491 }
OLDNEW
« no previous file with comments | « src/heap/heap-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698