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

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

Issue 585523002: The --optimize-for-size flag should imply a small semi-space (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « src/flag-definitions.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 4342 matching lines...) Expand 10 before | Expand all | Expand 10 after
4353 i::FLAG_expose_gc = true; 4353 i::FLAG_expose_gc = true;
4354 i::FLAG_max_semi_space_size = 2; 4354 i::FLAG_max_semi_space_size = 2;
4355 CcTest::InitializeVM(); 4355 CcTest::InitializeVM();
4356 v8::HandleScope scope(CcTest::isolate()); 4356 v8::HandleScope scope(CcTest::isolate());
4357 Isolate* isolate = CcTest::i_isolate(); 4357 Isolate* isolate = CcTest::i_isolate();
4358 Heap* heap = isolate->heap(); 4358 Heap* heap = isolate->heap();
4359 NewSpace* new_space = heap->new_space(); 4359 NewSpace* new_space = heap->new_space();
4360 4360
4361 // In this test we will try to overwrite the promotion queue which is at the 4361 // In this test we will try to overwrite the promotion queue which is at the
4362 // end of to-space. To actually make that possible, we need at least two 4362 // end of to-space. To actually make that possible, we need at least two
4363 // semi-space pages and take advantage of fragementation. 4363 // semi-space pages and take advantage of fragmentation.
4364 // (1) Grow semi-space to two pages. 4364 // (1) Grow semi-space to two pages.
4365 // (2) Create a few small long living objects and call the scavenger to 4365 // (2) Create a few small long living objects and call the scavenger to
4366 // move them to the other semi-space. 4366 // move them to the other semi-space.
4367 // (3) Create a huge object, i.e., remainder of first semi-space page and 4367 // (3) Create a huge object, i.e., remainder of first semi-space page and
4368 // create another huge object which should be of maximum allocatable memory 4368 // create another huge object which should be of maximum allocatable memory
4369 // size of the second semi-space page. 4369 // size of the second semi-space page.
4370 // (4) Call the scavenger again. 4370 // (4) Call the scavenger again.
4371 // What will happen is: the scavenger will promote the objects created in (2) 4371 // What will happen is: the scavenger will promote the objects created in (2)
4372 // and will create promotion queue entries at the end of the second 4372 // and will create promotion queue entries at the end of the second
4373 // semi-space page during the next scavenge when it promotes the objects to 4373 // semi-space page during the next scavenge when it promotes the objects to
4374 // the old generation. The first allocation of (3) will fill up the first 4374 // the old generation. The first allocation of (3) will fill up the first
4375 // semi-space page. The second allocation in (3) will not fit into the first 4375 // semi-space page. The second allocation in (3) will not fit into the first
4376 // semi-space page, but it will overwrite the promotion queue which are in 4376 // semi-space page, but it will overwrite the promotion queue which are in
4377 // the second semi-space page. If the right guards are in place, the promotion 4377 // the second semi-space page. If the right guards are in place, the promotion
4378 // queue will be evacuated in that case. 4378 // queue will be evacuated in that case.
4379 4379
4380 // Grow the semi-space to two pages to make semi-space copy overwrite the 4380 // Grow the semi-space to two pages to make semi-space copy overwrite the
4381 // promotion queue, which will be at the end of the second page. 4381 // promotion queue, which will be at the end of the second page.
4382 intptr_t old_capacity = new_space->Capacity(); 4382 intptr_t old_capacity = new_space->Capacity();
4383
4384 // If we are in a low memory config, we can't grow to two pages and we can't
4385 // run this test. This also means the issue we are testing cannot arise, as
4386 // there is no fragmentation.
4387 if (new_space->IsAtMaximumCapacity()) return;
4388
4383 new_space->Grow(); 4389 new_space->Grow();
4384 CHECK(new_space->IsAtMaximumCapacity()); 4390 CHECK(new_space->IsAtMaximumCapacity());
4385 CHECK(2 * old_capacity == new_space->Capacity()); 4391 CHECK(2 * old_capacity == new_space->Capacity());
4386 4392
4387 // Call the scavenger two times to get an empty new space 4393 // Call the scavenger two times to get an empty new space
4388 heap->CollectGarbage(NEW_SPACE); 4394 heap->CollectGarbage(NEW_SPACE);
4389 heap->CollectGarbage(NEW_SPACE); 4395 heap->CollectGarbage(NEW_SPACE);
4390 4396
4391 // First create a few objects which will survive a scavenge, and will get 4397 // First create a few objects which will survive a scavenge, and will get
4392 // promoted to the old generation later on. These objects will create 4398 // promoted to the old generation later on. These objects will create
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
4479 #ifdef DEBUG 4485 #ifdef DEBUG
4480 TEST(PathTracer) { 4486 TEST(PathTracer) {
4481 CcTest::InitializeVM(); 4487 CcTest::InitializeVM();
4482 v8::HandleScope scope(CcTest::isolate()); 4488 v8::HandleScope scope(CcTest::isolate());
4483 4489
4484 v8::Local<v8::Value> result = CompileRun("'abc'"); 4490 v8::Local<v8::Value> result = CompileRun("'abc'");
4485 Handle<Object> o = v8::Utils::OpenHandle(*result); 4491 Handle<Object> o = v8::Utils::OpenHandle(*result);
4486 CcTest::i_isolate()->heap()->TracePathToObject(*o); 4492 CcTest::i_isolate()->heap()->TracePathToObject(*o);
4487 } 4493 }
4488 #endif // DEBUG 4494 #endif // DEBUG
OLDNEW
« no previous file with comments | « src/flag-definitions.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698