| 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 6796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6807 array->Shrink(1); | 6807 array->Shrink(1); |
| 6808 CHECK(array->Size() < size_before); | 6808 CHECK(array->Size() < size_before); |
| 6809 | 6809 |
| 6810 CcTest::heap()->CollectAllGarbage(); | 6810 CcTest::heap()->CollectAllGarbage(); |
| 6811 CHECK(chunk->CommittedPhysicalMemory() < committed_memory_before); | 6811 CHECK(chunk->CommittedPhysicalMemory() < committed_memory_before); |
| 6812 size_t shrinked_size = | 6812 size_t shrinked_size = |
| 6813 RoundUp((array->address() - chunk->address()) + array->Size(), | 6813 RoundUp((array->address() - chunk->address()) + array->Size(), |
| 6814 base::OS::CommitPageSize()); | 6814 base::OS::CommitPageSize()); |
| 6815 CHECK_EQ(shrinked_size, chunk->CommittedPhysicalMemory()); | 6815 CHECK_EQ(shrinked_size, chunk->CommittedPhysicalMemory()); |
| 6816 } | 6816 } |
| 6817 |
| 6818 TEST(RememberedSetRemoveRange) { |
| 6819 CcTest::InitializeVM(); |
| 6820 v8::HandleScope scope(CcTest::isolate()); |
| 6821 Heap* heap = CcTest::heap(); |
| 6822 Isolate* isolate = heap->isolate(); |
| 6823 |
| 6824 Handle<FixedArray> array = isolate->factory()->NewFixedArray(500000); |
| 6825 MemoryChunk* chunk = MemoryChunk::FromAddress(array->address()); |
| 6826 CHECK(chunk->owner()->identity() == LO_SPACE); |
| 6827 Address start = array->address(); |
| 6828 // Maps slot to boolean indicator of whether the slot should be in the set. |
| 6829 std::map<Address, bool> slots; |
| 6830 slots[start + 0] = true; |
| 6831 slots[start + kPointerSize] = true; |
| 6832 slots[start + Page::kPageSize - kPointerSize] = true; |
| 6833 slots[start + Page::kPageSize] = true; |
| 6834 slots[start + Page::kPageSize + kPointerSize] = true; |
| 6835 slots[chunk->area_end() - kPointerSize] = true; |
| 6836 |
| 6837 for (auto x : slots) { |
| 6838 RememberedSet<OLD_TO_NEW>::Insert(chunk, x.first); |
| 6839 } |
| 6840 |
| 6841 RememberedSet<OLD_TO_NEW>::Iterate(chunk, [&slots](Address addr) { |
| 6842 CHECK(slots[addr]); |
| 6843 return KEEP_SLOT; |
| 6844 }); |
| 6845 |
| 6846 RememberedSet<OLD_TO_NEW>::RemoveRange(chunk, start, start + kPointerSize); |
| 6847 slots[start] = false; |
| 6848 RememberedSet<OLD_TO_NEW>::Iterate(chunk, [&slots](Address addr) { |
| 6849 CHECK(slots[addr]); |
| 6850 return KEEP_SLOT; |
| 6851 }); |
| 6852 |
| 6853 RememberedSet<OLD_TO_NEW>::RemoveRange(chunk, start + kPointerSize, |
| 6854 start + Page::kPageSize); |
| 6855 slots[start + kPointerSize] = false; |
| 6856 slots[start + Page::kPageSize - kPointerSize] = false; |
| 6857 RememberedSet<OLD_TO_NEW>::Iterate(chunk, [&slots](Address addr) { |
| 6858 CHECK(slots[addr]); |
| 6859 return KEEP_SLOT; |
| 6860 }); |
| 6861 |
| 6862 RememberedSet<OLD_TO_NEW>::RemoveRange( |
| 6863 chunk, start, start + Page::kPageSize + kPointerSize); |
| 6864 slots[start + Page::kPageSize] = false; |
| 6865 RememberedSet<OLD_TO_NEW>::Iterate(chunk, [&slots](Address addr) { |
| 6866 CHECK(slots[addr]); |
| 6867 return KEEP_SLOT; |
| 6868 }); |
| 6869 |
| 6870 RememberedSet<OLD_TO_NEW>::RemoveRange( |
| 6871 chunk, chunk->area_end() - kPointerSize, chunk->area_end()); |
| 6872 slots[chunk->area_end() - kPointerSize] = false; |
| 6873 RememberedSet<OLD_TO_NEW>::Iterate(chunk, [&slots](Address addr) { |
| 6874 CHECK(slots[addr]); |
| 6875 return KEEP_SLOT; |
| 6876 }); |
| 6877 } |
| 6878 |
| 6817 } // namespace internal | 6879 } // namespace internal |
| 6818 } // namespace v8 | 6880 } // namespace v8 |
| OLD | NEW |