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 5997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6008 size_t counter2 = 2000; | 6008 size_t counter2 = 2000; |
6009 tracer->SampleAllocation(time2, counter2, counter2); | 6009 tracer->SampleAllocation(time2, counter2, counter2); |
6010 size_t throughput = tracer->AllocationThroughputInBytesPerMillisecond(100); | 6010 size_t throughput = tracer->AllocationThroughputInBytesPerMillisecond(100); |
6011 CHECK_EQ(2 * (counter2 - counter1) / (time2 - time1), throughput); | 6011 CHECK_EQ(2 * (counter2 - counter1) / (time2 - time1), throughput); |
6012 int time3 = 1000; | 6012 int time3 = 1000; |
6013 size_t counter3 = 30000; | 6013 size_t counter3 = 30000; |
6014 tracer->SampleAllocation(time3, counter3, counter3); | 6014 tracer->SampleAllocation(time3, counter3, counter3); |
6015 throughput = tracer->AllocationThroughputInBytesPerMillisecond(100); | 6015 throughput = tracer->AllocationThroughputInBytesPerMillisecond(100); |
6016 CHECK_EQ(2 * (counter3 - counter1) / (time3 - time1), throughput); | 6016 CHECK_EQ(2 * (counter3 - counter1) / (time3 - time1), throughput); |
6017 } | 6017 } |
| 6018 |
| 6019 |
| 6020 TEST(SlotsBufferObjectSlotsRemoval) { |
| 6021 CcTest::InitializeVM(); |
| 6022 v8::HandleScope scope(CcTest::isolate()); |
| 6023 Isolate* isolate = CcTest::i_isolate(); |
| 6024 Heap* heap = isolate->heap(); |
| 6025 Factory* factory = isolate->factory(); |
| 6026 |
| 6027 SlotsBuffer* buffer = new SlotsBuffer(NULL); |
| 6028 void* fake_object[1]; |
| 6029 |
| 6030 Handle<FixedArray> array = factory->NewFixedArray(2, TENURED); |
| 6031 CHECK(heap->old_space()->Contains(*array)); |
| 6032 array->set(0, reinterpret_cast<Object*>(fake_object), SKIP_WRITE_BARRIER); |
| 6033 |
| 6034 // Firstly, let's test the regular slots buffer entry. |
| 6035 buffer->Add(HeapObject::RawField(*array, FixedArray::kHeaderSize)); |
| 6036 DCHECK(reinterpret_cast<void*>(buffer->Get(0)) == |
| 6037 HeapObject::RawField(*array, FixedArray::kHeaderSize)); |
| 6038 SlotsBuffer::RemoveObjectSlots(CcTest::i_isolate()->heap(), buffer, *array); |
| 6039 DCHECK(reinterpret_cast<void*>(buffer->Get(0)) == |
| 6040 HeapObject::RawField(heap->empty_fixed_array(), |
| 6041 FixedArrayBase::kLengthOffset)); |
| 6042 |
| 6043 // Secondly, let's test the typed slots buffer entry. |
| 6044 SlotsBuffer::AddTo(NULL, &buffer, SlotsBuffer::EMBEDDED_OBJECT_SLOT, |
| 6045 array->address() + FixedArray::kHeaderSize, |
| 6046 SlotsBuffer::FAIL_ON_OVERFLOW); |
| 6047 DCHECK(reinterpret_cast<void*>(buffer->Get(1)) == |
| 6048 reinterpret_cast<Object**>(SlotsBuffer::EMBEDDED_OBJECT_SLOT)); |
| 6049 DCHECK(reinterpret_cast<void*>(buffer->Get(2)) == |
| 6050 HeapObject::RawField(*array, FixedArray::kHeaderSize)); |
| 6051 SlotsBuffer::RemoveObjectSlots(CcTest::i_isolate()->heap(), buffer, *array); |
| 6052 DCHECK(reinterpret_cast<void*>(buffer->Get(1)) == |
| 6053 HeapObject::RawField(heap->empty_fixed_array(), |
| 6054 FixedArrayBase::kLengthOffset)); |
| 6055 DCHECK(reinterpret_cast<void*>(buffer->Get(2)) == |
| 6056 HeapObject::RawField(heap->empty_fixed_array(), |
| 6057 FixedArrayBase::kLengthOffset)); |
| 6058 delete buffer; |
| 6059 } |
OLD | NEW |