| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
| 8 #include "src/api.h" | 8 #include "src/api.h" |
| 9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
| 10 #include "src/base/once.h" | 10 #include "src/base/once.h" |
| (...skipping 1964 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1975 STATIC_ASSERT((ConstantPoolArray::kExtendedFirstOffset & | 1975 STATIC_ASSERT((ConstantPoolArray::kExtendedFirstOffset & |
| 1976 kDoubleAlignmentMask) == 0); // NOLINT | 1976 kDoubleAlignmentMask) == 0); // NOLINT |
| 1977 STATIC_ASSERT((FixedTypedArrayBase::kDataOffset & kDoubleAlignmentMask) == | 1977 STATIC_ASSERT((FixedTypedArrayBase::kDataOffset & kDoubleAlignmentMask) == |
| 1978 0); // NOLINT | 1978 0); // NOLINT |
| 1979 #ifdef V8_HOST_ARCH_32_BIT | 1979 #ifdef V8_HOST_ARCH_32_BIT |
| 1980 STATIC_ASSERT((HeapNumber::kValueOffset & kDoubleAlignmentMask) != | 1980 STATIC_ASSERT((HeapNumber::kValueOffset & kDoubleAlignmentMask) != |
| 1981 0); // NOLINT | 1981 0); // NOLINT |
| 1982 #endif | 1982 #endif |
| 1983 | 1983 |
| 1984 | 1984 |
| 1985 int Heap::GetMaximumFillToAlign(AllocationAlignment alignment) { | 1985 HeapObject* Heap::EnsureAligned(HeapObject* object, int size, |
| 1986 switch (alignment) { | 1986 AllocationAlignment alignment) { |
| 1987 case kWordAligned: | 1987 if (alignment == kDoubleAligned && |
| 1988 return 0; | 1988 (OffsetFrom(object->address()) & kDoubleAlignmentMask) != 0) { |
| 1989 case kDoubleAligned: | 1989 CreateFillerObjectAt(object->address(), kPointerSize); |
| 1990 case kDoubleUnaligned: | 1990 return HeapObject::FromAddress(object->address() + kPointerSize); |
| 1991 return kDoubleSize - kPointerSize; | 1991 } else if (alignment == kDoubleUnaligned && |
| 1992 default: | 1992 (OffsetFrom(object->address()) & kDoubleAlignmentMask) == 0) { |
| 1993 UNREACHABLE(); | 1993 CreateFillerObjectAt(object->address(), kPointerSize); |
| 1994 return HeapObject::FromAddress(object->address() + kPointerSize); |
| 1995 } else { |
| 1996 CreateFillerObjectAt(object->address() + size - kPointerSize, kPointerSize); |
| 1997 return object; |
| 1994 } | 1998 } |
| 1995 return 0; | |
| 1996 } | 1999 } |
| 1997 | 2000 |
| 1998 | 2001 |
| 1999 int Heap::GetFillToAlign(Address address, AllocationAlignment alignment) { | 2002 HeapObject* Heap::PrecedeWithFiller(HeapObject* object) { |
| 2000 intptr_t offset = OffsetFrom(address); | 2003 CreateFillerObjectAt(object->address(), kPointerSize); |
| 2001 if (alignment == kDoubleAligned && (offset & kDoubleAlignmentMask) != 0) | 2004 return HeapObject::FromAddress(object->address() + kPointerSize); |
| 2002 return kPointerSize; | |
| 2003 if (alignment == kDoubleUnaligned && (offset & kDoubleAlignmentMask) == 0) | |
| 2004 return kDoubleSize - kPointerSize; // No fill if double is always aligned. | |
| 2005 return 0; | |
| 2006 } | |
| 2007 | |
| 2008 | |
| 2009 HeapObject* Heap::PrecedeWithFiller(HeapObject* object, int filler_size) { | |
| 2010 CreateFillerObjectAt(object->address(), filler_size); | |
| 2011 return HeapObject::FromAddress(object->address() + filler_size); | |
| 2012 } | |
| 2013 | |
| 2014 | |
| 2015 HeapObject* Heap::AlignWithFiller(HeapObject* object, int object_size, | |
| 2016 int allocation_size, | |
| 2017 AllocationAlignment alignment) { | |
| 2018 int filler_size = allocation_size - object_size; | |
| 2019 DCHECK(filler_size > 0); | |
| 2020 int pre_filler = GetFillToAlign(object->address(), alignment); | |
| 2021 if (pre_filler) { | |
| 2022 object = PrecedeWithFiller(object, pre_filler); | |
| 2023 filler_size -= pre_filler; | |
| 2024 } | |
| 2025 if (filler_size) | |
| 2026 CreateFillerObjectAt(object->address() + object_size, filler_size); | |
| 2027 return object; | |
| 2028 } | 2005 } |
| 2029 | 2006 |
| 2030 | 2007 |
| 2031 HeapObject* Heap::DoubleAlignForDeserialization(HeapObject* object, int size) { | 2008 HeapObject* Heap::DoubleAlignForDeserialization(HeapObject* object, int size) { |
| 2032 return AlignWithFiller(object, size, size + kPointerSize, kDoubleAligned); | 2009 return EnsureAligned(object, size, kDoubleAligned); |
| 2033 } | 2010 } |
| 2034 | 2011 |
| 2035 | 2012 |
| 2036 enum LoggingAndProfiling { | 2013 enum LoggingAndProfiling { |
| 2037 LOGGING_AND_PROFILING_ENABLED, | 2014 LOGGING_AND_PROFILING_ENABLED, |
| 2038 LOGGING_AND_PROFILING_DISABLED | 2015 LOGGING_AND_PROFILING_DISABLED |
| 2039 }; | 2016 }; |
| 2040 | 2017 |
| 2041 | 2018 |
| 2042 enum MarksHandling { TRANSFER_MARKS, IGNORE_MARKS }; | 2019 enum MarksHandling { TRANSFER_MARKS, IGNORE_MARKS }; |
| (...skipping 4566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6609 *object_type = "CODE_TYPE"; \ | 6586 *object_type = "CODE_TYPE"; \ |
| 6610 *object_sub_type = "CODE_AGE/" #name; \ | 6587 *object_sub_type = "CODE_AGE/" #name; \ |
| 6611 return true; | 6588 return true; |
| 6612 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) | 6589 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) |
| 6613 #undef COMPARE_AND_RETURN_NAME | 6590 #undef COMPARE_AND_RETURN_NAME |
| 6614 } | 6591 } |
| 6615 return false; | 6592 return false; |
| 6616 } | 6593 } |
| 6617 } | 6594 } |
| 6618 } // namespace v8::internal | 6595 } // namespace v8::internal |
| OLD | NEW |