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

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

Issue 2807023003: [snapshot] encode resource before serializing. (Closed)
Patch Set: fix Created 3 years, 8 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 unified diff | Download patch
« no previous file with comments | « src/snapshot/serializer-common.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 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 v8::Persistent<v8::Context> env; 264 v8::Persistent<v8::Context> env;
265 { 265 {
266 HandleScope scope(isolate); 266 HandleScope scope(isolate);
267 env.Reset(v8_isolate, v8::Context::New(v8_isolate)); 267 env.Reset(v8_isolate, v8::Context::New(v8_isolate));
268 } 268 }
269 CHECK(!env.IsEmpty()); 269 CHECK(!env.IsEmpty());
270 { 270 {
271 v8::HandleScope handle_scope(v8_isolate); 271 v8::HandleScope handle_scope(v8_isolate);
272 v8::Local<v8::Context>::New(v8_isolate, env)->Enter(); 272 v8::Local<v8::Context>::New(v8_isolate, env)->Enter();
273 } 273 }
274 // Make sure all builtin scripts are cached.
275 {
276 HandleScope scope(isolate);
277 for (int i = 0; i < Natives::GetBuiltinsCount(); i++) {
278 isolate->bootstrapper()->SourceLookup<Natives>(i);
279 }
280 }
281 274
282 heap->CollectAllAvailableGarbage(i::GarbageCollectionReason::kTesting); 275 heap->CollectAllAvailableGarbage(i::GarbageCollectionReason::kTesting);
283 heap->CollectAllAvailableGarbage(i::GarbageCollectionReason::kTesting); 276 heap->CollectAllAvailableGarbage(i::GarbageCollectionReason::kTesting);
284 277
285 Object* raw_foo; 278 Object* raw_foo;
286 { 279 {
287 v8::HandleScope handle_scope(v8_isolate); 280 v8::HandleScope handle_scope(v8_isolate);
288 v8::Local<v8::String> foo = v8_str("foo"); 281 v8::Local<v8::String> foo = v8_str("foo");
289 CHECK(!foo.IsEmpty()); 282 CHECK(!foo.IsEmpty());
290 raw_foo = *(v8::Utils::OpenHandle(*foo)); 283 raw_foo = *(v8::Utils::OpenHandle(*foo));
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 v8::Persistent<v8::Context> env; 364 v8::Persistent<v8::Context> env;
372 { 365 {
373 HandleScope scope(isolate); 366 HandleScope scope(isolate);
374 env.Reset(v8_isolate, v8::Context::New(v8_isolate)); 367 env.Reset(v8_isolate, v8::Context::New(v8_isolate));
375 } 368 }
376 CHECK(!env.IsEmpty()); 369 CHECK(!env.IsEmpty());
377 { 370 {
378 v8::HandleScope handle_scope(v8_isolate); 371 v8::HandleScope handle_scope(v8_isolate);
379 v8::Local<v8::Context>::New(v8_isolate, env)->Enter(); 372 v8::Local<v8::Context>::New(v8_isolate, env)->Enter();
380 } 373 }
381 // Make sure all builtin scripts are cached.
382 {
383 HandleScope scope(isolate);
384 for (int i = 0; i < Natives::GetBuiltinsCount(); i++) {
385 isolate->bootstrapper()->SourceLookup<Natives>(i);
386 }
387 }
388 374
389 // If we don't do this then we end up with a stray root pointing at the 375 // If we don't do this then we end up with a stray root pointing at the
390 // context even after we have disposed of env. 376 // context even after we have disposed of env.
391 heap->CollectAllAvailableGarbage(i::GarbageCollectionReason::kTesting); 377 heap->CollectAllAvailableGarbage(i::GarbageCollectionReason::kTesting);
392 378
393 { 379 {
394 v8::HandleScope handle_scope(v8_isolate); 380 v8::HandleScope handle_scope(v8_isolate);
395 v8::Local<v8::Context>::New(v8_isolate, env)->Exit(); 381 v8::Local<v8::Context>::New(v8_isolate, env)->Exit();
396 } 382 }
397 383
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 Vector<const uint8_t> source = ConstructSource( 482 Vector<const uint8_t> source = ConstructSource(
497 STATIC_CHAR_VECTOR("function g() { return [,"), 483 STATIC_CHAR_VECTOR("function g() { return [,"),
498 STATIC_CHAR_VECTOR("1,"), 484 STATIC_CHAR_VECTOR("1,"),
499 STATIC_CHAR_VECTOR("];} a = g(); b = g(); b.push(1);"), 100000); 485 STATIC_CHAR_VECTOR("];} a = g(); b = g(); b.push(1);"), 100000);
500 v8::MaybeLocal<v8::String> source_str = v8::String::NewFromOneByte( 486 v8::MaybeLocal<v8::String> source_str = v8::String::NewFromOneByte(
501 v8_isolate, source.start(), v8::NewStringType::kNormal, 487 v8_isolate, source.start(), v8::NewStringType::kNormal,
502 source.length()); 488 source.length());
503 CompileRun(source_str.ToLocalChecked()); 489 CompileRun(source_str.ToLocalChecked());
504 source.Dispose(); 490 source.Dispose();
505 } 491 }
506 // Make sure all builtin scripts are cached.
507 {
508 HandleScope scope(isolate);
509 for (int i = 0; i < Natives::GetBuiltinsCount(); i++) {
510 isolate->bootstrapper()->SourceLookup<Natives>(i);
511 }
512 }
513 // If we don't do this then we end up with a stray root pointing at the 492 // If we don't do this then we end up with a stray root pointing at the
514 // context even after we have disposed of env. 493 // context even after we have disposed of env.
515 isolate->heap()->CollectAllAvailableGarbage( 494 isolate->heap()->CollectAllAvailableGarbage(
516 i::GarbageCollectionReason::kTesting); 495 i::GarbageCollectionReason::kTesting);
517 496
518 { 497 {
519 v8::HandleScope handle_scope(v8_isolate); 498 v8::HandleScope handle_scope(v8_isolate);
520 v8::Local<v8::Context>::New(v8_isolate, env)->Exit(); 499 v8::Local<v8::Context>::New(v8_isolate, env)->Exit();
521 } 500 }
522 501
(...skipping 1963 matching lines...) Expand 10 before | Expand all | Expand 10 after
2486 } 2465 }
2487 delete[] blob.data; 2466 delete[] blob.data;
2488 } 2467 }
2489 2468
2490 TEST(SerializationMemoryStats) { 2469 TEST(SerializationMemoryStats) {
2491 FLAG_profile_deserialization = true; 2470 FLAG_profile_deserialization = true;
2492 FLAG_always_opt = false; 2471 FLAG_always_opt = false;
2493 v8::StartupData blob = v8::V8::CreateSnapshotDataBlob(); 2472 v8::StartupData blob = v8::V8::CreateSnapshotDataBlob();
2494 delete[] blob.data; 2473 delete[] blob.data;
2495 } 2474 }
OLDNEW
« no previous file with comments | « src/snapshot/serializer-common.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698