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

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

Issue 1156113003: Fix test-heap/OldSpaceAllocationCounter. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 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 | « no previous file | 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 5468 matching lines...) Expand 10 before | Expand all | Expand 10 after
5479 start = counter; 5479 start = counter;
5480 } 5480 }
5481 } 5481 }
5482 5482
5483 5483
5484 TEST(OldSpaceAllocationCounter) { 5484 TEST(OldSpaceAllocationCounter) {
5485 CcTest::InitializeVM(); 5485 CcTest::InitializeVM();
5486 v8::HandleScope scope(CcTest::isolate()); 5486 v8::HandleScope scope(CcTest::isolate());
5487 Isolate* isolate = CcTest::i_isolate(); 5487 Isolate* isolate = CcTest::i_isolate();
5488 Heap* heap = isolate->heap(); 5488 Heap* heap = isolate->heap();
5489 // TODO(ulan): remove this GC after fixing no-snapshot failure.
5490 heap->CollectGarbage(OLD_SPACE);
5491 size_t counter1 = heap->OldGenerationAllocationCounter(); 5489 size_t counter1 = heap->OldGenerationAllocationCounter();
5492 heap->CollectGarbage(NEW_SPACE); 5490 heap->CollectGarbage(NEW_SPACE);
5493 const size_t kSize = 1024; 5491 const size_t kSize = 1024;
5494 AllocateInSpace(isolate, kSize, OLD_SPACE); 5492 AllocateInSpace(isolate, kSize, OLD_SPACE);
5495 size_t counter2 = heap->OldGenerationAllocationCounter(); 5493 size_t counter2 = heap->OldGenerationAllocationCounter();
5496 CHECK_EQ(kSize, counter2 - counter1); 5494 // TODO(ulan): replace all CHECK_LE with CHECK_EQ after v8:4148 is fixed.
5495 CHECK_LE(kSize, counter2 - counter1);
5497 heap->CollectGarbage(NEW_SPACE); 5496 heap->CollectGarbage(NEW_SPACE);
5498 size_t counter3 = heap->OldGenerationAllocationCounter(); 5497 size_t counter3 = heap->OldGenerationAllocationCounter();
5499 CHECK_EQ(0, counter3 - counter2); 5498 CHECK_LE(0, counter3 - counter2);
5500 AllocateInSpace(isolate, kSize, OLD_SPACE); 5499 AllocateInSpace(isolate, kSize, OLD_SPACE);
5501 heap->CollectGarbage(OLD_SPACE); 5500 heap->CollectGarbage(OLD_SPACE);
5502 size_t counter4 = heap->OldGenerationAllocationCounter(); 5501 size_t counter4 = heap->OldGenerationAllocationCounter();
5503 CHECK_EQ(kSize, counter4 - counter3); 5502 CHECK_LE(kSize, counter4 - counter3);
5504 // Test counter overflow. 5503 // Test counter overflow.
5505 size_t max_counter = -1; 5504 size_t max_counter = -1;
5506 heap->set_old_generation_allocation_counter(max_counter - 10 * kSize); 5505 heap->set_old_generation_allocation_counter(max_counter - 10 * kSize);
5507 size_t start = heap->OldGenerationAllocationCounter(); 5506 size_t start = heap->OldGenerationAllocationCounter();
5508 for (int i = 0; i < 20; i++) { 5507 for (int i = 0; i < 20; i++) {
5509 AllocateInSpace(isolate, kSize, OLD_SPACE); 5508 AllocateInSpace(isolate, kSize, OLD_SPACE);
5510 size_t counter = heap->OldGenerationAllocationCounter(); 5509 size_t counter = heap->OldGenerationAllocationCounter();
5511 CHECK_EQ(kSize, counter - start); 5510 CHECK_LE(kSize, counter - start);
5512 start = counter; 5511 start = counter;
5513 } 5512 }
5514 } 5513 }
5515 5514
5516 5515
5517 TEST(NewSpaceAllocationThroughput) { 5516 TEST(NewSpaceAllocationThroughput) {
5518 CcTest::InitializeVM(); 5517 CcTest::InitializeVM();
5519 v8::HandleScope scope(CcTest::isolate()); 5518 v8::HandleScope scope(CcTest::isolate());
5520 Isolate* isolate = CcTest::i_isolate(); 5519 Isolate* isolate = CcTest::i_isolate();
5521 Heap* heap = isolate->heap(); 5520 Heap* heap = isolate->heap();
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
5635 size_t counter2 = 2000; 5634 size_t counter2 = 2000;
5636 tracer->SampleAllocation(time2, counter2, counter2); 5635 tracer->SampleAllocation(time2, counter2, counter2);
5637 size_t bytes = tracer->AllocatedBytesInLast(1000); 5636 size_t bytes = tracer->AllocatedBytesInLast(1000);
5638 CHECK_EQ(20000, bytes); 5637 CHECK_EQ(20000, bytes);
5639 int time3 = 1000; 5638 int time3 = 1000;
5640 size_t counter3 = 30000; 5639 size_t counter3 = 30000;
5641 tracer->SampleAllocation(time3, counter3, counter3); 5640 tracer->SampleAllocation(time3, counter3, counter3);
5642 bytes = tracer->AllocatedBytesInLast(100); 5641 bytes = tracer->AllocatedBytesInLast(100);
5643 CHECK_EQ(2 * (counter3 - counter1) * 100 / (time3 - time1), bytes); 5642 CHECK_EQ(2 * (counter3 - counter1) * 100 / (time3 - time1), bytes);
5644 } 5643 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698