| 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 5790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5801 } | 5801 } |
| 5802 | 5802 |
| 5803 | 5803 |
| 5804 TEST(OldSpaceAllocationCounter) { | 5804 TEST(OldSpaceAllocationCounter) { |
| 5805 CcTest::InitializeVM(); | 5805 CcTest::InitializeVM(); |
| 5806 v8::HandleScope scope(CcTest::isolate()); | 5806 v8::HandleScope scope(CcTest::isolate()); |
| 5807 Isolate* isolate = CcTest::i_isolate(); | 5807 Isolate* isolate = CcTest::i_isolate(); |
| 5808 Heap* heap = isolate->heap(); | 5808 Heap* heap = isolate->heap(); |
| 5809 size_t counter1 = heap->OldGenerationAllocationCounter(); | 5809 size_t counter1 = heap->OldGenerationAllocationCounter(); |
| 5810 heap->CollectGarbage(NEW_SPACE); | 5810 heap->CollectGarbage(NEW_SPACE); |
| 5811 heap->CollectGarbage(NEW_SPACE); |
| 5811 const size_t kSize = 1024; | 5812 const size_t kSize = 1024; |
| 5812 AllocateInSpace(isolate, kSize, OLD_SPACE); | 5813 AllocateInSpace(isolate, kSize, OLD_SPACE); |
| 5813 size_t counter2 = heap->OldGenerationAllocationCounter(); | 5814 size_t counter2 = heap->OldGenerationAllocationCounter(); |
| 5814 // TODO(ulan): replace all CHECK_LE with CHECK_EQ after v8:4148 is fixed. | 5815 // TODO(ulan): replace all CHECK_LE with CHECK_EQ after v8:4148 is fixed. |
| 5815 CHECK_LE(kSize, counter2 - counter1); | 5816 CHECK_LE(kSize, counter2 - counter1); |
| 5816 heap->CollectGarbage(NEW_SPACE); | 5817 heap->CollectGarbage(NEW_SPACE); |
| 5817 size_t counter3 = heap->OldGenerationAllocationCounter(); | 5818 size_t counter3 = heap->OldGenerationAllocationCounter(); |
| 5818 CHECK_EQ(0u, counter3 - counter2); | 5819 CHECK_EQ(0u, counter3 - counter2); |
| 5819 AllocateInSpace(isolate, kSize, OLD_SPACE); | 5820 AllocateInSpace(isolate, kSize, OLD_SPACE); |
| 5820 heap->CollectGarbage(OLD_SPACE); | 5821 heap->CollectGarbage(OLD_SPACE); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5861 v8::HandleScope scope(CcTest::isolate()); | 5862 v8::HandleScope scope(CcTest::isolate()); |
| 5862 Isolate* isolate = CcTest::i_isolate(); | 5863 Isolate* isolate = CcTest::i_isolate(); |
| 5863 Heap* heap = isolate->heap(); | 5864 Heap* heap = isolate->heap(); |
| 5864 GCTracer* tracer = heap->tracer(); | 5865 GCTracer* tracer = heap->tracer(); |
| 5865 int time1 = 100; | 5866 int time1 = 100; |
| 5866 size_t counter1 = 1000; | 5867 size_t counter1 = 1000; |
| 5867 tracer->SampleAllocation(time1, counter1, 0); | 5868 tracer->SampleAllocation(time1, counter1, 0); |
| 5868 int time2 = 200; | 5869 int time2 = 200; |
| 5869 size_t counter2 = 2000; | 5870 size_t counter2 = 2000; |
| 5870 tracer->SampleAllocation(time2, counter2, 0); | 5871 tracer->SampleAllocation(time2, counter2, 0); |
| 5871 size_t throughput = tracer->AllocationThroughputInBytesPerMillisecond(100); | 5872 size_t throughput = |
| 5873 tracer->NewSpaceAllocationThroughputInBytesPerMillisecond(100); |
| 5872 CHECK_EQ((counter2 - counter1) / (time2 - time1), throughput); | 5874 CHECK_EQ((counter2 - counter1) / (time2 - time1), throughput); |
| 5873 int time3 = 1000; | 5875 int time3 = 1000; |
| 5874 size_t counter3 = 30000; | 5876 size_t counter3 = 30000; |
| 5875 tracer->SampleAllocation(time3, counter3, 0); | 5877 tracer->SampleAllocation(time3, counter3, 0); |
| 5876 throughput = tracer->AllocationThroughputInBytesPerMillisecond(100); | 5878 throughput = tracer->NewSpaceAllocationThroughputInBytesPerMillisecond(100); |
| 5877 CHECK_EQ((counter3 - counter1) / (time3 - time1), throughput); | 5879 CHECK_EQ((counter3 - counter1) / (time3 - time1), throughput); |
| 5878 } | 5880 } |
| 5879 | 5881 |
| 5880 | 5882 |
| 5881 static void CheckLeak(const v8::FunctionCallbackInfo<v8::Value>& args) { | 5883 static void CheckLeak(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 5882 Isolate* isolate = CcTest::i_isolate(); | 5884 Isolate* isolate = CcTest::i_isolate(); |
| 5883 Object* message = | 5885 Object* message = |
| 5884 *reinterpret_cast<Object**>(isolate->pending_message_obj_address()); | 5886 *reinterpret_cast<Object**>(isolate->pending_message_obj_address()); |
| 5885 CHECK(message->IsTheHole()); | 5887 CHECK(message->IsTheHole()); |
| 5886 } | 5888 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5925 v8::HandleScope scope(CcTest::isolate()); | 5927 v8::HandleScope scope(CcTest::isolate()); |
| 5926 Isolate* isolate = CcTest::i_isolate(); | 5928 Isolate* isolate = CcTest::i_isolate(); |
| 5927 Heap* heap = isolate->heap(); | 5929 Heap* heap = isolate->heap(); |
| 5928 GCTracer* tracer = heap->tracer(); | 5930 GCTracer* tracer = heap->tracer(); |
| 5929 int time1 = 100; | 5931 int time1 = 100; |
| 5930 size_t counter1 = 1000; | 5932 size_t counter1 = 1000; |
| 5931 tracer->SampleAllocation(time1, 0, counter1); | 5933 tracer->SampleAllocation(time1, 0, counter1); |
| 5932 int time2 = 200; | 5934 int time2 = 200; |
| 5933 size_t counter2 = 2000; | 5935 size_t counter2 = 2000; |
| 5934 tracer->SampleAllocation(time2, 0, counter2); | 5936 tracer->SampleAllocation(time2, 0, counter2); |
| 5935 size_t throughput = tracer->AllocationThroughputInBytesPerMillisecond(100); | 5937 size_t throughput = |
| 5938 tracer->OldGenerationAllocationThroughputInBytesPerMillisecond(100); |
| 5936 CHECK_EQ((counter2 - counter1) / (time2 - time1), throughput); | 5939 CHECK_EQ((counter2 - counter1) / (time2 - time1), throughput); |
| 5937 int time3 = 1000; | 5940 int time3 = 1000; |
| 5938 size_t counter3 = 30000; | 5941 size_t counter3 = 30000; |
| 5939 tracer->SampleAllocation(time3, 0, counter3); | 5942 tracer->SampleAllocation(time3, 0, counter3); |
| 5940 throughput = tracer->AllocationThroughputInBytesPerMillisecond(100); | 5943 throughput = |
| 5944 tracer->OldGenerationAllocationThroughputInBytesPerMillisecond(100); |
| 5941 CHECK_EQ((counter3 - counter1) / (time3 - time1), throughput); | 5945 CHECK_EQ((counter3 - counter1) / (time3 - time1), throughput); |
| 5942 } | 5946 } |
| 5943 | 5947 |
| 5944 | 5948 |
| 5945 TEST(AllocationThroughput) { | 5949 TEST(AllocationThroughput) { |
| 5946 CcTest::InitializeVM(); | 5950 CcTest::InitializeVM(); |
| 5947 v8::HandleScope scope(CcTest::isolate()); | 5951 v8::HandleScope scope(CcTest::isolate()); |
| 5948 Isolate* isolate = CcTest::i_isolate(); | 5952 Isolate* isolate = CcTest::i_isolate(); |
| 5949 Heap* heap = isolate->heap(); | 5953 Heap* heap = isolate->heap(); |
| 5950 GCTracer* tracer = heap->tracer(); | 5954 GCTracer* tracer = heap->tracer(); |
| 5951 int time1 = 100; | 5955 int time1 = 100; |
| 5952 size_t counter1 = 1000; | 5956 size_t counter1 = 1000; |
| 5953 tracer->SampleAllocation(time1, counter1, counter1); | 5957 tracer->SampleAllocation(time1, counter1, counter1); |
| 5954 int time2 = 200; | 5958 int time2 = 200; |
| 5955 size_t counter2 = 2000; | 5959 size_t counter2 = 2000; |
| 5956 tracer->SampleAllocation(time2, counter2, counter2); | 5960 tracer->SampleAllocation(time2, counter2, counter2); |
| 5957 size_t throughput = tracer->AllocationThroughputInBytesPerMillisecond(100); | 5961 size_t throughput = tracer->AllocationThroughputInBytesPerMillisecond(100); |
| 5958 CHECK_EQ(2 * (counter2 - counter1) / (time2 - time1), throughput); | 5962 CHECK_EQ(2 * (counter2 - counter1) / (time2 - time1), throughput); |
| 5959 int time3 = 1000; | 5963 int time3 = 1000; |
| 5960 size_t counter3 = 30000; | 5964 size_t counter3 = 30000; |
| 5961 tracer->SampleAllocation(time3, counter3, counter3); | 5965 tracer->SampleAllocation(time3, counter3, counter3); |
| 5962 throughput = tracer->AllocationThroughputInBytesPerMillisecond(100); | 5966 throughput = tracer->AllocationThroughputInBytesPerMillisecond(100); |
| 5963 CHECK_EQ(2 * (counter3 - counter1) / (time3 - time1), throughput); | 5967 CHECK_EQ(2 * (counter3 - counter1) / (time3 - time1), throughput); |
| 5964 } | 5968 } |
| OLD | NEW |