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 2011 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2022 // may precede or follow the object. | 2022 // may precede or follow the object. |
2023 TEST(TestAlignedOverAllocation) { | 2023 TEST(TestAlignedOverAllocation) { |
2024 // Double misalignment is 4 on 32-bit platforms, 0 on 64-bit ones. | 2024 // Double misalignment is 4 on 32-bit platforms, 0 on 64-bit ones. |
2025 const intptr_t double_misalignment = kDoubleSize - kPointerSize; | 2025 const intptr_t double_misalignment = kDoubleSize - kPointerSize; |
2026 Address start; | 2026 Address start; |
2027 HeapObject* obj; | 2027 HeapObject* obj; |
2028 HeapObject* filler1; | 2028 HeapObject* filler1; |
2029 HeapObject* filler2; | 2029 HeapObject* filler2; |
2030 if (double_misalignment) { | 2030 if (double_misalignment) { |
2031 start = AlignOldSpace(kDoubleAligned, 0); | 2031 start = AlignOldSpace(kDoubleAligned, 0); |
2032 // If we run out of linear allocation area then we might get null here. In | |
2033 // that case we are unlucky and the test is not going to work, but it's not | |
2034 // a test failure, this is a reasonable thing to happen. Just abandon. | |
2035 if (start == NULL) return; | |
2036 obj = OldSpaceAllocateAligned(kPointerSize, kDoubleAligned); | 2032 obj = OldSpaceAllocateAligned(kPointerSize, kDoubleAligned); |
2037 // The object is aligned, and a filler object is created after. | 2033 // The object is aligned, and a filler object is created after. |
2038 CHECK(IsAddressAligned(obj->address(), kDoubleAlignment)); | 2034 CHECK(IsAddressAligned(obj->address(), kDoubleAlignment)); |
2039 filler1 = HeapObject::FromAddress(start + kPointerSize); | 2035 filler1 = HeapObject::FromAddress(start + kPointerSize); |
2040 CHECK(obj != filler1 && filler1->IsFiller() && | 2036 CHECK(obj != filler1 && filler1->IsFiller() && |
2041 filler1->Size() == kPointerSize); | 2037 filler1->Size() == kPointerSize); |
2042 // Try the opposite alignment case. | 2038 // Try the opposite alignment case. |
2043 start = AlignOldSpace(kDoubleAligned, kPointerSize); | 2039 start = AlignOldSpace(kDoubleAligned, kPointerSize); |
2044 if (start == NULL) return; | |
2045 obj = OldSpaceAllocateAligned(kPointerSize, kDoubleAligned); | 2040 obj = OldSpaceAllocateAligned(kPointerSize, kDoubleAligned); |
2046 CHECK(IsAddressAligned(obj->address(), kDoubleAlignment)); | 2041 CHECK(IsAddressAligned(obj->address(), kDoubleAlignment)); |
2047 filler1 = HeapObject::FromAddress(start); | 2042 filler1 = HeapObject::FromAddress(start); |
2048 CHECK(obj != filler1); | 2043 CHECK(obj != filler1); |
2049 CHECK(filler1->IsFiller()); | 2044 CHECK(filler1->IsFiller()); |
2050 CHECK(filler1->Size() == kPointerSize); | 2045 CHECK(filler1->Size() == kPointerSize); |
2051 CHECK(obj != filler1 && filler1->IsFiller() && | 2046 CHECK(obj != filler1 && filler1->IsFiller() && |
2052 filler1->Size() == kPointerSize); | 2047 filler1->Size() == kPointerSize); |
2053 | 2048 |
2054 // Similarly for kDoubleUnaligned. | 2049 // Similarly for kDoubleUnaligned. |
2055 start = AlignOldSpace(kDoubleUnaligned, 0); | 2050 start = AlignOldSpace(kDoubleUnaligned, 0); |
2056 if (start == NULL) return; | |
2057 obj = OldSpaceAllocateAligned(kPointerSize, kDoubleUnaligned); | 2051 obj = OldSpaceAllocateAligned(kPointerSize, kDoubleUnaligned); |
2058 // The object is aligned, and a filler object is created after. | 2052 // The object is aligned, and a filler object is created after. |
2059 CHECK(IsAddressAligned(obj->address(), kDoubleAlignment, kPointerSize)); | 2053 CHECK(IsAddressAligned(obj->address(), kDoubleAlignment, kPointerSize)); |
2060 filler1 = HeapObject::FromAddress(start + kPointerSize); | 2054 filler1 = HeapObject::FromAddress(start + kPointerSize); |
2061 CHECK(obj != filler1 && filler1->IsFiller() && | 2055 CHECK(obj != filler1 && filler1->IsFiller() && |
2062 filler1->Size() == kPointerSize); | 2056 filler1->Size() == kPointerSize); |
2063 // Try the opposite alignment case. | 2057 // Try the opposite alignment case. |
2064 start = AlignOldSpace(kDoubleUnaligned, kPointerSize); | 2058 start = AlignOldSpace(kDoubleUnaligned, kPointerSize); |
2065 if (start == NULL) return; | |
2066 obj = OldSpaceAllocateAligned(kPointerSize, kDoubleUnaligned); | 2059 obj = OldSpaceAllocateAligned(kPointerSize, kDoubleUnaligned); |
2067 CHECK(IsAddressAligned(obj->address(), kDoubleAlignment, kPointerSize)); | 2060 CHECK(IsAddressAligned(obj->address(), kDoubleAlignment, kPointerSize)); |
2068 filler1 = HeapObject::FromAddress(start); | 2061 filler1 = HeapObject::FromAddress(start); |
2069 CHECK(obj != filler1 && filler1->IsFiller() && | 2062 CHECK(obj != filler1 && filler1->IsFiller() && |
2070 filler1->Size() == kPointerSize); | 2063 filler1->Size() == kPointerSize); |
2071 } | 2064 } |
2072 | 2065 |
2073 // Now test SIMD alignment. There are 2 or 4 possible alignments, depending | 2066 // Now test SIMD alignment. There are 2 or 4 possible alignments, depending |
2074 // on platform. | 2067 // on platform. |
2075 start = AlignOldSpace(kSimd128Unaligned, 0); | 2068 start = AlignOldSpace(kSimd128Unaligned, 0); |
2076 if (start == NULL) return; | |
2077 obj = OldSpaceAllocateAligned(kPointerSize, kSimd128Unaligned); | 2069 obj = OldSpaceAllocateAligned(kPointerSize, kSimd128Unaligned); |
2078 CHECK(IsAddressAligned(obj->address(), kSimd128Alignment, kPointerSize)); | 2070 CHECK(IsAddressAligned(obj->address(), kSimd128Alignment, kPointerSize)); |
2079 // There is a filler object after the object. | 2071 // There is a filler object after the object. |
2080 filler1 = HeapObject::FromAddress(start + kPointerSize); | 2072 filler1 = HeapObject::FromAddress(start + kPointerSize); |
2081 CHECK(obj != filler1 && filler1->IsFiller() && | 2073 CHECK(obj != filler1 && filler1->IsFiller() && |
2082 filler1->Size() == kSimd128Size - kPointerSize); | 2074 filler1->Size() == kSimd128Size - kPointerSize); |
2083 start = AlignOldSpace(kSimd128Unaligned, kPointerSize); | 2075 start = AlignOldSpace(kSimd128Unaligned, kPointerSize); |
2084 if (start == NULL) return; | |
2085 obj = OldSpaceAllocateAligned(kPointerSize, kSimd128Unaligned); | 2076 obj = OldSpaceAllocateAligned(kPointerSize, kSimd128Unaligned); |
2086 CHECK(IsAddressAligned(obj->address(), kSimd128Alignment, kPointerSize)); | 2077 CHECK(IsAddressAligned(obj->address(), kSimd128Alignment, kPointerSize)); |
2087 // There is a filler object before the object. | 2078 // There is a filler object before the object. |
2088 filler1 = HeapObject::FromAddress(start); | 2079 filler1 = HeapObject::FromAddress(start); |
2089 CHECK(obj != filler1 && filler1->IsFiller() && | 2080 CHECK(obj != filler1 && filler1->IsFiller() && |
2090 filler1->Size() == kSimd128Size - kPointerSize); | 2081 filler1->Size() == kSimd128Size - kPointerSize); |
2091 | 2082 |
2092 if (double_misalignment) { | 2083 if (double_misalignment) { |
2093 // Test the 2 other alignments possible on 32 bit platforms. | 2084 // Test the 2 other alignments possible on 32 bit platforms. |
2094 start = AlignOldSpace(kSimd128Unaligned, 2 * kPointerSize); | 2085 start = AlignOldSpace(kSimd128Unaligned, 2 * kPointerSize); |
2095 if (start == NULL) return; | |
2096 obj = OldSpaceAllocateAligned(kPointerSize, kSimd128Unaligned); | 2086 obj = OldSpaceAllocateAligned(kPointerSize, kSimd128Unaligned); |
2097 CHECK(IsAddressAligned(obj->address(), kSimd128Alignment, kPointerSize)); | 2087 CHECK(IsAddressAligned(obj->address(), kSimd128Alignment, kPointerSize)); |
2098 // There are filler objects before and after the object. | 2088 // There are filler objects before and after the object. |
2099 filler1 = HeapObject::FromAddress(start); | 2089 filler1 = HeapObject::FromAddress(start); |
2100 CHECK(obj != filler1 && filler1->IsFiller() && | 2090 CHECK(obj != filler1 && filler1->IsFiller() && |
2101 filler1->Size() == 2 * kPointerSize); | 2091 filler1->Size() == 2 * kPointerSize); |
2102 filler2 = HeapObject::FromAddress(start + 3 * kPointerSize); | 2092 filler2 = HeapObject::FromAddress(start + 3 * kPointerSize); |
2103 CHECK(obj != filler2 && filler2->IsFiller() && | 2093 CHECK(obj != filler2 && filler2->IsFiller() && |
2104 filler2->Size() == kPointerSize); | 2094 filler2->Size() == kPointerSize); |
2105 start = AlignOldSpace(kSimd128Unaligned, 3 * kPointerSize); | 2095 start = AlignOldSpace(kSimd128Unaligned, 3 * kPointerSize); |
2106 if (start == NULL) return; | |
2107 obj = OldSpaceAllocateAligned(kPointerSize, kSimd128Unaligned); | 2096 obj = OldSpaceAllocateAligned(kPointerSize, kSimd128Unaligned); |
2108 CHECK(IsAddressAligned(obj->address(), kSimd128Alignment, kPointerSize)); | 2097 CHECK(IsAddressAligned(obj->address(), kSimd128Alignment, kPointerSize)); |
2109 // There are filler objects before and after the object. | 2098 // There are filler objects before and after the object. |
2110 filler1 = HeapObject::FromAddress(start); | 2099 filler1 = HeapObject::FromAddress(start); |
2111 CHECK(obj != filler1 && filler1->IsFiller() && | 2100 CHECK(obj != filler1 && filler1->IsFiller() && |
2112 filler1->Size() == kPointerSize); | 2101 filler1->Size() == kPointerSize); |
2113 filler2 = HeapObject::FromAddress(start + 2 * kPointerSize); | 2102 filler2 = HeapObject::FromAddress(start + 2 * kPointerSize); |
2114 CHECK(obj != filler2 && filler2->IsFiller() && | 2103 CHECK(obj != filler2 && filler2->IsFiller() && |
2115 filler2->Size() == 2 * kPointerSize); | 2104 filler2->Size() == 2 * kPointerSize); |
2116 } | 2105 } |
(...skipping 3277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5394 | 5383 |
5395 Handle<FixedArray> temp2 = | 5384 Handle<FixedArray> temp2 = |
5396 factory->NewFixedArray(padding_array_length, TENURED); | 5385 factory->NewFixedArray(padding_array_length, TENURED); |
5397 Page* page = Page::FromAddress(temp2->address()); | 5386 Page* page = Page::FromAddress(temp2->address()); |
5398 CHECK_EQ(Page::kObjectStartOffset, page->Offset(temp2->address())); | 5387 CHECK_EQ(Page::kObjectStartOffset, page->Offset(temp2->address())); |
5399 } | 5388 } |
5400 | 5389 |
5401 Handle<JSObject> o = factory->NewJSObjectFromMap(map1, TENURED, false); | 5390 Handle<JSObject> o = factory->NewJSObjectFromMap(map1, TENURED, false); |
5402 o->set_properties(*factory->empty_fixed_array()); | 5391 o->set_properties(*factory->empty_fixed_array()); |
5403 | 5392 |
5404 // Ensure that the object allocated where we need it. If not, then abandon | 5393 // Ensure that the object allocated where we need it. |
5405 // the test, since this isn't actually something we can reasonably require. | |
5406 Page* page = Page::FromAddress(o->address()); | 5394 Page* page = Page::FromAddress(o->address()); |
5407 if (desired_offset != page->Offset(o->address())) return; | 5395 CHECK_EQ(desired_offset, page->Offset(o->address())); |
5408 | 5396 |
5409 // Now we have an object right at the end of the page. | 5397 // Now we have an object right at the end of the page. |
5410 | 5398 |
5411 // Enable incremental marking to trigger actions in Heap::AdjustLiveBytes() | 5399 // Enable incremental marking to trigger actions in Heap::AdjustLiveBytes() |
5412 // that would cause crash. | 5400 // that would cause crash. |
5413 IncrementalMarking* marking = CcTest::heap()->incremental_marking(); | 5401 IncrementalMarking* marking = CcTest::heap()->incremental_marking(); |
5414 marking->Abort(); | 5402 marking->Abort(); |
5415 marking->Start(Heap::kNoGCFlags); | 5403 marking->Start(Heap::kNoGCFlags); |
5416 CHECK(marking->IsMarking()); | 5404 CHECK(marking->IsMarking()); |
5417 | 5405 |
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6056 HeapObject::RawField(*array, FixedArray::kHeaderSize)); | 6044 HeapObject::RawField(*array, FixedArray::kHeaderSize)); |
6057 SlotsBuffer::RemoveObjectSlots(CcTest::i_isolate()->heap(), buffer, *array); | 6045 SlotsBuffer::RemoveObjectSlots(CcTest::i_isolate()->heap(), buffer, *array); |
6058 DCHECK(reinterpret_cast<void*>(buffer->Get(1)) == | 6046 DCHECK(reinterpret_cast<void*>(buffer->Get(1)) == |
6059 HeapObject::RawField(heap->empty_fixed_array(), | 6047 HeapObject::RawField(heap->empty_fixed_array(), |
6060 FixedArrayBase::kLengthOffset)); | 6048 FixedArrayBase::kLengthOffset)); |
6061 DCHECK(reinterpret_cast<void*>(buffer->Get(2)) == | 6049 DCHECK(reinterpret_cast<void*>(buffer->Get(2)) == |
6062 HeapObject::RawField(heap->empty_fixed_array(), | 6050 HeapObject::RawField(heap->empty_fixed_array(), |
6063 FixedArrayBase::kLengthOffset)); | 6051 FixedArrayBase::kLengthOffset)); |
6064 delete buffer; | 6052 delete buffer; |
6065 } | 6053 } |
OLD | NEW |