OLD | NEW |
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 5477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5488 Heap* heap = isolate->heap(); | 5488 Heap* heap = isolate->heap(); |
5489 size_t counter1 = heap->OldGenerationAllocationCounter(); | 5489 size_t counter1 = heap->OldGenerationAllocationCounter(); |
5490 heap->CollectGarbage(NEW_SPACE); | 5490 heap->CollectGarbage(NEW_SPACE); |
5491 const size_t kSize = 1024; | 5491 const size_t kSize = 1024; |
5492 AllocateInSpace(isolate, kSize, OLD_SPACE); | 5492 AllocateInSpace(isolate, kSize, OLD_SPACE); |
5493 size_t counter2 = heap->OldGenerationAllocationCounter(); | 5493 size_t counter2 = heap->OldGenerationAllocationCounter(); |
5494 // TODO(ulan): replace all CHECK_LE with CHECK_EQ after v8:4148 is fixed. | 5494 // TODO(ulan): replace all CHECK_LE with CHECK_EQ after v8:4148 is fixed. |
5495 CHECK_LE(kSize, counter2 - counter1); | 5495 CHECK_LE(kSize, counter2 - counter1); |
5496 heap->CollectGarbage(NEW_SPACE); | 5496 heap->CollectGarbage(NEW_SPACE); |
5497 size_t counter3 = heap->OldGenerationAllocationCounter(); | 5497 size_t counter3 = heap->OldGenerationAllocationCounter(); |
5498 CHECK_LE(0, counter3 - counter2); | 5498 CHECK_EQ(0u, counter3 - counter2); |
5499 AllocateInSpace(isolate, kSize, OLD_SPACE); | 5499 AllocateInSpace(isolate, kSize, OLD_SPACE); |
5500 heap->CollectGarbage(OLD_SPACE); | 5500 heap->CollectGarbage(OLD_SPACE); |
5501 size_t counter4 = heap->OldGenerationAllocationCounter(); | 5501 size_t counter4 = heap->OldGenerationAllocationCounter(); |
5502 CHECK_LE(kSize, counter4 - counter3); | 5502 CHECK_LE(kSize, counter4 - counter3); |
5503 // Test counter overflow. | 5503 // Test counter overflow. |
5504 size_t max_counter = -1; | 5504 size_t max_counter = -1; |
5505 heap->set_old_generation_allocation_counter(max_counter - 10 * kSize); | 5505 heap->set_old_generation_allocation_counter(max_counter - 10 * kSize); |
5506 size_t start = heap->OldGenerationAllocationCounter(); | 5506 size_t start = heap->OldGenerationAllocationCounter(); |
5507 for (int i = 0; i < 20; i++) { | 5507 for (int i = 0; i < 20; i++) { |
5508 AllocateInSpace(isolate, kSize, OLD_SPACE); | 5508 AllocateInSpace(isolate, kSize, OLD_SPACE); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5634 size_t counter2 = 2000; | 5634 size_t counter2 = 2000; |
5635 tracer->SampleAllocation(time2, counter2, counter2); | 5635 tracer->SampleAllocation(time2, counter2, counter2); |
5636 size_t bytes = tracer->AllocatedBytesInLast(1000); | 5636 size_t bytes = tracer->AllocatedBytesInLast(1000); |
5637 CHECK_EQ(20000, bytes); | 5637 CHECK_EQ(20000, bytes); |
5638 int time3 = 1000; | 5638 int time3 = 1000; |
5639 size_t counter3 = 30000; | 5639 size_t counter3 = 30000; |
5640 tracer->SampleAllocation(time3, counter3, counter3); | 5640 tracer->SampleAllocation(time3, counter3, counter3); |
5641 bytes = tracer->AllocatedBytesInLast(100); | 5641 bytes = tracer->AllocatedBytesInLast(100); |
5642 CHECK_EQ(2 * (counter3 - counter1) * 100 / (time3 - time1), bytes); | 5642 CHECK_EQ(2 * (counter3 - counter1) * 100 / (time3 - time1), bytes); |
5643 } | 5643 } |
OLD | NEW |