Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: test/cctest/test-heap.cc

Issue 1343043002: [heap] Move slots buffer into a separate file. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/cctest/cctest.gyp ('k') | test/cctest/test-slots-buffer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 6435 matching lines...) Expand 10 before | Expand all | Expand 10 after
6446 size_t throughput = tracer->AllocationThroughputInBytesPerMillisecond(100); 6446 size_t throughput = tracer->AllocationThroughputInBytesPerMillisecond(100);
6447 CHECK_EQ(2 * (counter2 - counter1) / (time2 - time1), throughput); 6447 CHECK_EQ(2 * (counter2 - counter1) / (time2 - time1), throughput);
6448 int time3 = 1000; 6448 int time3 = 1000;
6449 size_t counter3 = 30000; 6449 size_t counter3 = 30000;
6450 tracer->SampleAllocation(time3, counter3, counter3); 6450 tracer->SampleAllocation(time3, counter3, counter3);
6451 throughput = tracer->AllocationThroughputInBytesPerMillisecond(100); 6451 throughput = tracer->AllocationThroughputInBytesPerMillisecond(100);
6452 CHECK_EQ(2 * (counter3 - counter1) / (time3 - time1), throughput); 6452 CHECK_EQ(2 * (counter3 - counter1) / (time3 - time1), throughput);
6453 } 6453 }
6454 6454
6455 6455
6456 TEST(SlotsBufferObjectSlotsRemoval) {
6457 CcTest::InitializeVM();
6458 v8::HandleScope scope(CcTest::isolate());
6459 Isolate* isolate = CcTest::i_isolate();
6460 Heap* heap = isolate->heap();
6461 Factory* factory = isolate->factory();
6462
6463 SlotsBuffer* buffer = new SlotsBuffer(NULL);
6464 void* fake_object[1];
6465
6466 Handle<FixedArray> array = factory->NewFixedArray(2, TENURED);
6467 CHECK(heap->old_space()->Contains(*array));
6468 array->set(0, reinterpret_cast<Object*>(fake_object), SKIP_WRITE_BARRIER);
6469
6470 // Firstly, let's test the regular slots buffer entry.
6471 buffer->Add(HeapObject::RawField(*array, FixedArray::kHeaderSize));
6472 CHECK(reinterpret_cast<void*>(buffer->Get(0)) ==
6473 HeapObject::RawField(*array, FixedArray::kHeaderSize));
6474 SlotsBuffer::RemoveObjectSlots(CcTest::i_isolate()->heap(), buffer,
6475 array->address(),
6476 array->address() + array->Size());
6477 CHECK(reinterpret_cast<void*>(buffer->Get(0)) ==
6478 HeapObject::RawField(heap->empty_fixed_array(),
6479 FixedArrayBase::kLengthOffset));
6480
6481 // Secondly, let's test the typed slots buffer entry.
6482 SlotsBuffer::AddTo(NULL, &buffer, SlotsBuffer::EMBEDDED_OBJECT_SLOT,
6483 array->address() + FixedArray::kHeaderSize,
6484 SlotsBuffer::FAIL_ON_OVERFLOW);
6485 CHECK(reinterpret_cast<void*>(buffer->Get(1)) ==
6486 reinterpret_cast<Object**>(SlotsBuffer::EMBEDDED_OBJECT_SLOT));
6487 CHECK(reinterpret_cast<void*>(buffer->Get(2)) ==
6488 HeapObject::RawField(*array, FixedArray::kHeaderSize));
6489 SlotsBuffer::RemoveObjectSlots(CcTest::i_isolate()->heap(), buffer,
6490 array->address(),
6491 array->address() + array->Size());
6492 CHECK(reinterpret_cast<void*>(buffer->Get(1)) ==
6493 HeapObject::RawField(heap->empty_fixed_array(),
6494 FixedArrayBase::kLengthOffset));
6495 CHECK(reinterpret_cast<void*>(buffer->Get(2)) ==
6496 HeapObject::RawField(heap->empty_fixed_array(),
6497 FixedArrayBase::kLengthOffset));
6498 delete buffer;
6499 }
6500
6501
6502 TEST(FilterInvalidSlotsBufferEntries) {
6503 FLAG_manual_evacuation_candidates_selection = true;
6504 CcTest::InitializeVM();
6505 v8::HandleScope scope(CcTest::isolate());
6506 Isolate* isolate = CcTest::i_isolate();
6507 Heap* heap = isolate->heap();
6508 Factory* factory = isolate->factory();
6509 SlotsBuffer* buffer = new SlotsBuffer(NULL);
6510
6511 // Set up a fake black object that will contain a recorded SMI, a recorded
6512 // pointer to a new space object, and a recorded pointer to a non-evacuation
6513 // candidate object. These object should be filtered out. Additionally,
6514 // we point to an evacuation candidate object which should not be filtered
6515 // out.
6516
6517 // Create fake object and mark it black.
6518 Handle<FixedArray> fake_object = factory->NewFixedArray(23, TENURED);
6519 MarkBit mark_bit = Marking::MarkBitFrom(*fake_object);
6520 Marking::MarkBlack(mark_bit);
6521
6522 // Write a SMI into field one and record its address;
6523 Object** field_smi = fake_object->RawFieldOfElementAt(0);
6524 *field_smi = Smi::FromInt(100);
6525 buffer->Add(field_smi);
6526
6527 // Write a new space reference into field 2 and record its address;
6528 Handle<FixedArray> new_space_object = factory->NewFixedArray(23);
6529 mark_bit = Marking::MarkBitFrom(*new_space_object);
6530 Marking::MarkBlack(mark_bit);
6531 Object** field_new_space = fake_object->RawFieldOfElementAt(1);
6532 *field_new_space = *new_space_object;
6533 buffer->Add(field_new_space);
6534
6535 // Write an old space reference into field 3 which points to an object not on
6536 // an evacuation candidate.
6537 Handle<FixedArray> old_space_object_non_evacuation =
6538 factory->NewFixedArray(23, TENURED);
6539 mark_bit = Marking::MarkBitFrom(*old_space_object_non_evacuation);
6540 Marking::MarkBlack(mark_bit);
6541 Object** field_old_space_object_non_evacuation =
6542 fake_object->RawFieldOfElementAt(2);
6543 *field_old_space_object_non_evacuation = *old_space_object_non_evacuation;
6544 buffer->Add(field_old_space_object_non_evacuation);
6545
6546 // Write an old space reference into field 4 which points to an object on an
6547 // evacuation candidate.
6548 SimulateFullSpace(heap->old_space());
6549 Handle<FixedArray> valid_object =
6550 isolate->factory()->NewFixedArray(23, TENURED);
6551 Page* page = Page::FromAddress(valid_object->address());
6552 page->SetFlag(MemoryChunk::EVACUATION_CANDIDATE);
6553 Object** valid_field = fake_object->RawFieldOfElementAt(3);
6554 *valid_field = *valid_object;
6555 buffer->Add(valid_field);
6556
6557 SlotsBuffer::RemoveInvalidSlots(heap, buffer);
6558 Object** kRemovedEntry = HeapObject::RawField(heap->empty_fixed_array(),
6559 FixedArrayBase::kLengthOffset);
6560 CHECK_EQ(buffer->Get(0), kRemovedEntry);
6561 CHECK_EQ(buffer->Get(1), kRemovedEntry);
6562 CHECK_EQ(buffer->Get(2), kRemovedEntry);
6563 CHECK_EQ(buffer->Get(3), valid_field);
6564
6565 // Clean-up to make verify heap happy.
6566 mark_bit = Marking::MarkBitFrom(*fake_object);
6567 Marking::MarkWhite(mark_bit);
6568 mark_bit = Marking::MarkBitFrom(*new_space_object);
6569 Marking::MarkWhite(mark_bit);
6570 mark_bit = Marking::MarkBitFrom(*old_space_object_non_evacuation);
6571 Marking::MarkWhite(mark_bit);
6572
6573 delete buffer;
6574 }
6575
6576
6577 TEST(ContextMeasure) { 6456 TEST(ContextMeasure) {
6578 CcTest::InitializeVM(); 6457 CcTest::InitializeVM();
6579 v8::HandleScope scope(CcTest::isolate()); 6458 v8::HandleScope scope(CcTest::isolate());
6580 Isolate* isolate = CcTest::i_isolate(); 6459 Isolate* isolate = CcTest::i_isolate();
6581 LocalContext context; 6460 LocalContext context;
6582 6461
6583 int size_upper_limit = 0; 6462 int size_upper_limit = 0;
6584 int count_upper_limit = 0; 6463 int count_upper_limit = 0;
6585 HeapIterator it(CcTest::heap()); 6464 HeapIterator it(CcTest::heap());
6586 for (HeapObject* obj = it.next(); obj != NULL; obj = it.next()) { 6465 for (HeapObject* obj = it.next(); obj != NULL; obj = it.next()) {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
6692 // The CollectGarbage call above starts sweeper threads. 6571 // The CollectGarbage call above starts sweeper threads.
6693 // The crash will happen if the following two functions 6572 // The crash will happen if the following two functions
6694 // are called before sweeping finishes. 6573 // are called before sweeping finishes.
6695 heap->StartIncrementalMarking(); 6574 heap->StartIncrementalMarking();
6696 heap->FinalizeIncrementalMarkingIfComplete("test"); 6575 heap->FinalizeIncrementalMarkingIfComplete("test");
6697 } 6576 }
6698 6577
6699 6578
6700 } // namespace internal 6579 } // namespace internal
6701 } // namespace v8 6580 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/cctest.gyp ('k') | test/cctest/test-slots-buffer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698