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