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

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

Issue 1313383005: Clear SMI and non-evacuation candidate entries when filtering the slots buffer. (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 | « src/heap/mark-compact.cc ('k') | no next file » | 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 6483 matching lines...) Expand 10 before | Expand all | Expand 10 after
6494 CHECK(reinterpret_cast<void*>(buffer->Get(1)) == 6494 CHECK(reinterpret_cast<void*>(buffer->Get(1)) ==
6495 HeapObject::RawField(heap->empty_fixed_array(), 6495 HeapObject::RawField(heap->empty_fixed_array(),
6496 FixedArrayBase::kLengthOffset)); 6496 FixedArrayBase::kLengthOffset));
6497 CHECK(reinterpret_cast<void*>(buffer->Get(2)) == 6497 CHECK(reinterpret_cast<void*>(buffer->Get(2)) ==
6498 HeapObject::RawField(heap->empty_fixed_array(), 6498 HeapObject::RawField(heap->empty_fixed_array(),
6499 FixedArrayBase::kLengthOffset)); 6499 FixedArrayBase::kLengthOffset));
6500 delete buffer; 6500 delete buffer;
6501 } 6501 }
6502 6502
6503 6503
6504 TEST(FilterInvalidSlotsBufferEntries) {
6505 FLAG_manual_evacuation_candidates_selection = true;
6506 CcTest::InitializeVM();
6507 v8::HandleScope scope(CcTest::isolate());
6508 Isolate* isolate = CcTest::i_isolate();
6509 Heap* heap = isolate->heap();
6510 Factory* factory = isolate->factory();
6511 SlotsBuffer* buffer = new SlotsBuffer(NULL);
6512
6513 // Set up a fake black object that will contain a recorded SMI, a recorded
6514 // pointer to a new space object, and a recorded pointer to a non-evacuation
6515 // candidate object. These object should be filtered out. Additionally,
6516 // we point to an evacuation candidate object which should not be filtered
6517 // out.
6518
6519 // Create fake object and mark it black.
6520 Handle<FixedArray> fake_object = factory->NewFixedArray(23, TENURED);
6521 MarkBit mark_bit = Marking::MarkBitFrom(*fake_object);
6522 Marking::MarkBlack(mark_bit);
6523
6524 // Write a SMI into field one and record its address;
6525 Object** field_smi = fake_object->RawFieldOfElementAt(0);
6526 *field_smi = Smi::FromInt(100);
6527 buffer->Add(field_smi);
6528
6529 // Write a new space reference into field 2 and record its address;
6530 Handle<FixedArray> new_space_object = factory->NewFixedArray(23);
6531 mark_bit = Marking::MarkBitFrom(*new_space_object);
6532 Marking::MarkBlack(mark_bit);
6533 Object** field_new_space = fake_object->RawFieldOfElementAt(1);
6534 *field_new_space = *new_space_object;
6535 buffer->Add(field_new_space);
6536
6537 // Write an old space reference into field 3 which points to an object not on
6538 // an evacuation candidate.
6539 Handle<FixedArray> old_space_object_non_evacuation =
6540 factory->NewFixedArray(23, TENURED);
6541 mark_bit = Marking::MarkBitFrom(*old_space_object_non_evacuation);
6542 Marking::MarkBlack(mark_bit);
6543 Object** field_old_space_object_non_evacuation =
6544 fake_object->RawFieldOfElementAt(2);
6545 *field_old_space_object_non_evacuation = *old_space_object_non_evacuation;
6546 buffer->Add(field_old_space_object_non_evacuation);
6547
6548 // Write an old space reference into field 4 which points to an object on an
6549 // evacuation candidate.
6550 SimulateFullSpace(heap->old_space());
6551 Handle<FixedArray> valid_object =
6552 isolate->factory()->NewFixedArray(23, TENURED);
6553 Page* page = Page::FromAddress(valid_object->address());
6554 page->SetFlag(MemoryChunk::EVACUATION_CANDIDATE);
6555 Object** valid_field = fake_object->RawFieldOfElementAt(3);
6556 *valid_field = *valid_object;
6557 buffer->Add(valid_field);
6558
6559 SlotsBuffer::RemoveInvalidSlots(heap, buffer);
6560 Object** kRemovedEntry = HeapObject::RawField(heap->empty_fixed_array(),
6561 FixedArrayBase::kLengthOffset);
6562 CHECK_EQ(buffer->Get(0), kRemovedEntry);
6563 CHECK_EQ(buffer->Get(1), kRemovedEntry);
6564 CHECK_EQ(buffer->Get(2), kRemovedEntry);
6565 CHECK_EQ(buffer->Get(3), valid_field);
6566
6567 // Clean-up to make verify heap happy.
6568 mark_bit = Marking::MarkBitFrom(*fake_object);
6569 Marking::MarkWhite(mark_bit);
6570 mark_bit = Marking::MarkBitFrom(*new_space_object);
6571 Marking::MarkWhite(mark_bit);
6572 mark_bit = Marking::MarkBitFrom(*old_space_object_non_evacuation);
6573 Marking::MarkWhite(mark_bit);
6574
6575 delete buffer;
6576 }
6577
6578
6504 TEST(ContextMeasure) { 6579 TEST(ContextMeasure) {
6505 CcTest::InitializeVM(); 6580 CcTest::InitializeVM();
6506 v8::HandleScope scope(CcTest::isolate()); 6581 v8::HandleScope scope(CcTest::isolate());
6507 Isolate* isolate = CcTest::i_isolate(); 6582 Isolate* isolate = CcTest::i_isolate();
6508 LocalContext context; 6583 LocalContext context;
6509 6584
6510 int size_upper_limit = 0; 6585 int size_upper_limit = 0;
6511 int count_upper_limit = 0; 6586 int count_upper_limit = 0;
6512 HeapIterator it(CcTest::heap()); 6587 HeapIterator it(CcTest::heap());
6513 for (HeapObject* obj = it.next(); obj != NULL; obj = it.next()) { 6588 for (HeapObject* obj = it.next(); obj != NULL; obj = it.next()) {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
6584 { 6659 {
6585 SharedFunctionInfo::Iterator iterator(isolate); 6660 SharedFunctionInfo::Iterator iterator(isolate);
6586 while (iterator.Next()) sfi_count--; 6661 while (iterator.Next()) sfi_count--;
6587 } 6662 }
6588 6663
6589 CHECK_EQ(0, sfi_count); 6664 CHECK_EQ(0, sfi_count);
6590 } 6665 }
6591 6666
6592 } // namespace internal 6667 } // namespace internal
6593 } // namespace v8 6668 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/mark-compact.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698