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 5945 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5956 int initial_length, | 5956 int initial_length, |
5957 int elements_to_trim) { | 5957 int elements_to_trim) { |
5958 v8::HandleScope scope(CcTest::isolate()); | 5958 v8::HandleScope scope(CcTest::isolate()); |
5959 Isolate* isolate = CcTest::i_isolate(); | 5959 Isolate* isolate = CcTest::i_isolate(); |
5960 Factory* factory = isolate->factory(); | 5960 Factory* factory = isolate->factory(); |
5961 Heap* heap = isolate->heap(); | 5961 Heap* heap = isolate->heap(); |
5962 | 5962 |
5963 Handle<FixedTypedArrayBase> array = | 5963 Handle<FixedTypedArrayBase> array = |
5964 factory->NewFixedTypedArray(initial_length, type, true); | 5964 factory->NewFixedTypedArray(initial_length, type, true); |
5965 int old_size = array->size(); | 5965 int old_size = array->size(); |
5966 heap->RightTrimFixedArray<Heap::CONCURRENT_TO_SWEEPER>(*array, | 5966 heap->RightTrimFixedArray(*array, elements_to_trim); |
5967 elements_to_trim); | |
5968 | 5967 |
5969 // Check that free space filler is at the right place and did not smash the | 5968 // Check that free space filler is at the right place and did not smash the |
5970 // array header. | 5969 // array header. |
5971 CHECK(array->IsFixedArrayBase()); | 5970 CHECK(array->IsFixedArrayBase()); |
5972 CHECK_EQ(initial_length - elements_to_trim, array->length()); | 5971 CHECK_EQ(initial_length - elements_to_trim, array->length()); |
5973 int new_size = array->size(); | 5972 int new_size = array->size(); |
5974 if (new_size != old_size) { | 5973 if (new_size != old_size) { |
5975 // Free space filler should be created in this case. | 5974 // Free space filler should be created in this case. |
5976 Address next_obj_address = array->address() + array->size(); | 5975 Address next_obj_address = array->address() + array->size(); |
5977 CHECK(HeapObject::FromAddress(next_obj_address)->IsFiller()); | 5976 CHECK(HeapObject::FromAddress(next_obj_address)->IsFiller()); |
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6442 (kMaxRegularHeapObjectSize - FixedArray::kHeaderSize) / kPointerSize; | 6441 (kMaxRegularHeapObjectSize - FixedArray::kHeaderSize) / kPointerSize; |
6443 Handle<FixedArray> array = factory->NewFixedArray(N, TENURED); | 6442 Handle<FixedArray> array = factory->NewFixedArray(N, TENURED); |
6444 CHECK(heap->old_space()->Contains(*array)); | 6443 CHECK(heap->old_space()->Contains(*array)); |
6445 Handle<Object> number = factory->NewHeapNumber(1.0); | 6444 Handle<Object> number = factory->NewHeapNumber(1.0); |
6446 CHECK(heap->InNewSpace(*number)); | 6445 CHECK(heap->InNewSpace(*number)); |
6447 for (int i = 0; i < N; i++) { | 6446 for (int i = 0; i < N; i++) { |
6448 array->set(i, *number); | 6447 array->set(i, *number); |
6449 } | 6448 } |
6450 CcTest::CollectGarbage(OLD_SPACE); | 6449 CcTest::CollectGarbage(OLD_SPACE); |
6451 heap::SimulateFullSpace(heap->old_space()); | 6450 heap::SimulateFullSpace(heap->old_space()); |
6452 heap->RightTrimFixedArray<Heap::CONCURRENT_TO_SWEEPER>(*array, N - 1); | 6451 heap->RightTrimFixedArray(*array, N - 1); |
6453 heap->mark_compact_collector()->EnsureSweepingCompleted(); | 6452 heap->mark_compact_collector()->EnsureSweepingCompleted(); |
6454 ByteArray* byte_array; | 6453 ByteArray* byte_array; |
6455 const int M = 256; | 6454 const int M = 256; |
6456 // Don't allow old space expansion. The test works without this flag too, | 6455 // Don't allow old space expansion. The test works without this flag too, |
6457 // but becomes very slow. | 6456 // but becomes very slow. |
6458 heap->set_force_oom(true); | 6457 heap->set_force_oom(true); |
6459 while (heap->AllocateByteArray(M, TENURED).To(&byte_array)) { | 6458 while (heap->AllocateByteArray(M, TENURED).To(&byte_array)) { |
6460 for (int j = 0; j < M; j++) { | 6459 for (int j = 0; j < M; j++) { |
6461 byte_array->set(j, 0x31); | 6460 byte_array->set(j, 0x31); |
6462 } | 6461 } |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6526 // slots are recorded for them. | 6525 // slots are recorded for them. |
6527 for (size_t j = 0; j < arrays.size(); j++) { | 6526 for (size_t j = 0; j < arrays.size(); j++) { |
6528 array = arrays[j]; | 6527 array = arrays[j]; |
6529 for (int i = 0; i < N; i++) { | 6528 for (int i = 0; i < N; i++) { |
6530 array->set(i, *ec_obj); | 6529 array->set(i, *ec_obj); |
6531 } | 6530 } |
6532 } | 6531 } |
6533 } | 6532 } |
6534 heap::SimulateIncrementalMarking(heap); | 6533 heap::SimulateIncrementalMarking(heap); |
6535 for (size_t j = 0; j < arrays.size(); j++) { | 6534 for (size_t j = 0; j < arrays.size(); j++) { |
6536 heap->RightTrimFixedArray<Heap::CONCURRENT_TO_SWEEPER>(arrays[j], N - 1); | 6535 heap->RightTrimFixedArray(arrays[j], N - 1); |
6537 } | 6536 } |
6538 } | 6537 } |
6539 // Force allocation from the free list. | 6538 // Force allocation from the free list. |
6540 heap->set_force_oom(true); | 6539 heap->set_force_oom(true); |
6541 CcTest::CollectGarbage(OLD_SPACE); | 6540 CcTest::CollectGarbage(OLD_SPACE); |
6542 } | 6541 } |
6543 | 6542 |
6544 TEST(Regress598319) { | 6543 TEST(Regress598319) { |
6545 // This test ensures that no white objects can cross the progress bar of large | 6544 // This test ensures that no white objects can cross the progress bar of large |
6546 // objects during incremental marking. It checks this by using Shift() during | 6545 // objects during incremental marking. It checks this by using Shift() during |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6891 Address end_address = start_address + array->Size(); | 6890 Address end_address = start_address + array->Size(); |
6892 Page* page = Page::FromAddress(start_address); | 6891 Page* page = Page::FromAddress(start_address); |
6893 CHECK(Marking::IsBlack(ObjectMarking::MarkBitFrom(*array))); | 6892 CHECK(Marking::IsBlack(ObjectMarking::MarkBitFrom(*array))); |
6894 CHECK(page->markbits()->AllBitsSetInRange( | 6893 CHECK(page->markbits()->AllBitsSetInRange( |
6895 page->AddressToMarkbitIndex(start_address), | 6894 page->AddressToMarkbitIndex(start_address), |
6896 page->AddressToMarkbitIndex(end_address))); | 6895 page->AddressToMarkbitIndex(end_address))); |
6897 CHECK(heap->old_space()->Contains(*array)); | 6896 CHECK(heap->old_space()->Contains(*array)); |
6898 | 6897 |
6899 // Trim it once by one word to make checking for white marking color uniform. | 6898 // Trim it once by one word to make checking for white marking color uniform. |
6900 Address previous = end_address - kPointerSize; | 6899 Address previous = end_address - kPointerSize; |
6901 heap->RightTrimFixedArray<Heap::SEQUENTIAL_TO_SWEEPER>(*array, 1); | 6900 heap->RightTrimFixedArray(*array, 1); |
6902 HeapObject* filler = HeapObject::FromAddress(previous); | 6901 HeapObject* filler = HeapObject::FromAddress(previous); |
6903 CHECK(filler->IsFiller()); | 6902 CHECK(filler->IsFiller()); |
6904 CHECK(Marking::IsImpossible(ObjectMarking::MarkBitFrom(previous))); | 6903 CHECK(Marking::IsImpossible(ObjectMarking::MarkBitFrom(previous))); |
6905 | 6904 |
6906 // Trim 10 times by one, two, and three word. | 6905 // Trim 10 times by one, two, and three word. |
6907 for (int i = 1; i <= 3; i++) { | 6906 for (int i = 1; i <= 3; i++) { |
6908 for (int j = 0; j < 10; j++) { | 6907 for (int j = 0; j < 10; j++) { |
6909 previous -= kPointerSize * i; | 6908 previous -= kPointerSize * i; |
6910 heap->RightTrimFixedArray<Heap::SEQUENTIAL_TO_SWEEPER>(*array, i); | 6909 heap->RightTrimFixedArray(*array, i); |
6911 HeapObject* filler = HeapObject::FromAddress(previous); | 6910 HeapObject* filler = HeapObject::FromAddress(previous); |
6912 CHECK(filler->IsFiller()); | 6911 CHECK(filler->IsFiller()); |
6913 CHECK(Marking::IsWhite(ObjectMarking::MarkBitFrom(previous))); | 6912 CHECK(Marking::IsWhite(ObjectMarking::MarkBitFrom(previous))); |
6914 } | 6913 } |
6915 } | 6914 } |
6916 | 6915 |
6917 heap::GcAndSweep(heap, OLD_SPACE); | 6916 heap::GcAndSweep(heap, OLD_SPACE); |
6918 } | 6917 } |
6919 | 6918 |
6920 TEST(Regress618958) { | 6919 TEST(Regress618958) { |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7020 SlotSet::FREE_EMPTY_BUCKETS); | 7019 SlotSet::FREE_EMPTY_BUCKETS); |
7021 slots[chunk->area_end() - kPointerSize] = false; | 7020 slots[chunk->area_end() - kPointerSize] = false; |
7022 RememberedSet<OLD_TO_NEW>::Iterate(chunk, [&slots](Address addr) { | 7021 RememberedSet<OLD_TO_NEW>::Iterate(chunk, [&slots](Address addr) { |
7023 CHECK(slots[addr]); | 7022 CHECK(slots[addr]); |
7024 return KEEP_SLOT; | 7023 return KEEP_SLOT; |
7025 }); | 7024 }); |
7026 } | 7025 } |
7027 | 7026 |
7028 } // namespace internal | 7027 } // namespace internal |
7029 } // namespace v8 | 7028 } // namespace v8 |
OLD | NEW |