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 5468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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); |
5489 size_t counter1 = heap->OldGenerationAllocationCounter(); | 5491 size_t counter1 = heap->OldGenerationAllocationCounter(); |
5490 heap->CollectGarbage(NEW_SPACE); | 5492 heap->CollectGarbage(NEW_SPACE); |
5491 const size_t kSize = 1024; | 5493 const size_t kSize = 1024; |
5492 AllocateInSpace(isolate, kSize, OLD_SPACE); | 5494 AllocateInSpace(isolate, kSize, OLD_SPACE); |
5493 size_t counter2 = heap->OldGenerationAllocationCounter(); | 5495 size_t counter2 = heap->OldGenerationAllocationCounter(); |
5494 CHECK_EQ(kSize, counter2 - counter1); | 5496 CHECK_EQ(kSize, counter2 - counter1); |
5495 heap->CollectGarbage(NEW_SPACE); | 5497 heap->CollectGarbage(NEW_SPACE); |
5496 size_t counter3 = heap->OldGenerationAllocationCounter(); | 5498 size_t counter3 = heap->OldGenerationAllocationCounter(); |
5497 CHECK_EQ(0, counter3 - counter2); | 5499 CHECK_EQ(0, counter3 - counter2); |
5498 AllocateInSpace(isolate, kSize, OLD_SPACE); | 5500 AllocateInSpace(isolate, kSize, OLD_SPACE); |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5633 size_t counter2 = 2000; | 5635 size_t counter2 = 2000; |
5634 tracer->SampleAllocation(time2, counter2, counter2); | 5636 tracer->SampleAllocation(time2, counter2, counter2); |
5635 size_t bytes = tracer->AllocatedBytesInLast(1000); | 5637 size_t bytes = tracer->AllocatedBytesInLast(1000); |
5636 CHECK_EQ(20000, bytes); | 5638 CHECK_EQ(20000, bytes); |
5637 int time3 = 1000; | 5639 int time3 = 1000; |
5638 size_t counter3 = 30000; | 5640 size_t counter3 = 30000; |
5639 tracer->SampleAllocation(time3, counter3, counter3); | 5641 tracer->SampleAllocation(time3, counter3, counter3); |
5640 bytes = tracer->AllocatedBytesInLast(100); | 5642 bytes = tracer->AllocatedBytesInLast(100); |
5641 CHECK_EQ(2 * (counter3 - counter1) * 100 / (time3 - time1), bytes); | 5643 CHECK_EQ(2 * (counter3 - counter1) * 100 / (time3 - time1), bytes); |
5642 } | 5644 } |
OLD | NEW |