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

Side by Side Diff: src/heap/heap.cc

Issue 1150593003: Clean up aligned allocation code in preparation for SIMD alignments. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix compile. Created 5 years, 7 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
OLDNEW
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 1954 matching lines...) Expand 10 before | Expand all | Expand 10 after
1965 STATIC_ASSERT((ConstantPoolArray::kExtendedFirstOffset & 1965 STATIC_ASSERT((ConstantPoolArray::kExtendedFirstOffset &
1966 kDoubleAlignmentMask) == 0); // NOLINT 1966 kDoubleAlignmentMask) == 0); // NOLINT
1967 STATIC_ASSERT((FixedTypedArrayBase::kDataOffset & kDoubleAlignmentMask) == 1967 STATIC_ASSERT((FixedTypedArrayBase::kDataOffset & kDoubleAlignmentMask) ==
1968 0); // NOLINT 1968 0); // NOLINT
1969 #ifdef V8_HOST_ARCH_32_BIT 1969 #ifdef V8_HOST_ARCH_32_BIT
1970 STATIC_ASSERT((HeapNumber::kValueOffset & kDoubleAlignmentMask) != 1970 STATIC_ASSERT((HeapNumber::kValueOffset & kDoubleAlignmentMask) !=
1971 0); // NOLINT 1971 0); // NOLINT
1972 #endif 1972 #endif
1973 1973
1974 1974
1975 HeapObject* Heap::EnsureAligned(HeapObject* object, int size, 1975 int Heap::GetAlignmentSize(Address address, AllocationAlignment alignment) {
1976 AllocationAlignment alignment) { 1976 intptr_t offset = OffsetFrom(address);
1977 if (alignment == kDoubleAligned && 1977 if (alignment == kDoubleAligned && (offset & kDoubleAlignmentMask) != 0)
1978 (OffsetFrom(object->address()) & kDoubleAlignmentMask) != 0) { 1978 return kPointerSize;
1979 CreateFillerObjectAt(object->address(), kPointerSize); 1979 if (alignment == kDoubleValueAligned && (offset & kDoubleAlignmentMask) == 0)
1980 return HeapObject::FromAddress(object->address() + kPointerSize); 1980 return kPointerSize;
1981 } else if (alignment == kDoubleUnaligned && 1981 return 0;
1982 (OffsetFrom(object->address()) & kDoubleAlignmentMask) == 0) {
1983 CreateFillerObjectAt(object->address(), kPointerSize);
1984 return HeapObject::FromAddress(object->address() + kPointerSize);
1985 } else {
1986 CreateFillerObjectAt(object->address() + size - kPointerSize, kPointerSize);
1987 return object;
1988 }
1989 } 1982 }
1990 1983
1991 1984
1992 HeapObject* Heap::PrecedeWithFiller(HeapObject* object) { 1985 HeapObject* Heap::PrecedeWithFiller(HeapObject* object, int fill_size) {
1993 CreateFillerObjectAt(object->address(), kPointerSize); 1986 CreateFillerObjectAt(object->address(), fill_size);
1994 return HeapObject::FromAddress(object->address() + kPointerSize); 1987 return HeapObject::FromAddress(object->address() + fill_size);
1995 } 1988 }
1996 1989
1997 1990
1998 HeapObject* Heap::DoubleAlignForDeserialization(HeapObject* object, int size) { 1991 HeapObject* Heap::DoubleAlignForDeserialization(HeapObject* object, int size) {
1999 return EnsureAligned(object, size, kDoubleAligned); 1992 Address address = object->address();
1993 int fill_size = GetAlignmentSize(address, kDoubleAligned);
1994 // If object is not aligned, add fill to align it.
1995 if (fill_size) return PrecedeWithFiller(object, kPointerSize);
1996
1997 // object is aligned. Add fill in the extra space at the end.
1998 // TODO(bbudge) Calculate alignment fill earlier to avoid this.
1999 CreateFillerObjectAt(address + size - kPointerSize, kPointerSize);
2000 return object;
2000 } 2001 }
2001 2002
2002 2003
2003 enum LoggingAndProfiling { 2004 enum LoggingAndProfiling {
2004 LOGGING_AND_PROFILING_ENABLED, 2005 LOGGING_AND_PROFILING_ENABLED,
2005 LOGGING_AND_PROFILING_DISABLED 2006 LOGGING_AND_PROFILING_DISABLED
2006 }; 2007 };
2007 2008
2008 2009
2009 enum MarksHandling { TRANSFER_MARKS, IGNORE_MARKS }; 2010 enum MarksHandling { TRANSFER_MARKS, IGNORE_MARKS };
(...skipping 830 matching lines...) Expand 10 before | Expand all | Expand 10 after
2840 // Statically ensure that it is safe to allocate heap numbers in paged 2841 // Statically ensure that it is safe to allocate heap numbers in paged
2841 // spaces. 2842 // spaces.
2842 int size = HeapNumber::kSize; 2843 int size = HeapNumber::kSize;
2843 STATIC_ASSERT(HeapNumber::kSize <= Page::kMaxRegularHeapObjectSize); 2844 STATIC_ASSERT(HeapNumber::kSize <= Page::kMaxRegularHeapObjectSize);
2844 2845
2845 AllocationSpace space = SelectSpace(size, pretenure); 2846 AllocationSpace space = SelectSpace(size, pretenure);
2846 2847
2847 HeapObject* result; 2848 HeapObject* result;
2848 { 2849 {
2849 AllocationResult allocation = 2850 AllocationResult allocation =
2850 AllocateRaw(size, space, OLD_SPACE, kDoubleUnaligned); 2851 AllocateRaw(size, space, OLD_SPACE, kDoubleValueAligned);
2851 if (!allocation.To(&result)) return allocation; 2852 if (!allocation.To(&result)) return allocation;
2852 } 2853 }
2853 2854
2854 Map* map = mode == MUTABLE ? mutable_heap_number_map() : heap_number_map(); 2855 Map* map = mode == MUTABLE ? mutable_heap_number_map() : heap_number_map();
2855 HeapObject::cast(result)->set_map_no_write_barrier(map); 2856 HeapObject::cast(result)->set_map_no_write_barrier(map);
2856 HeapNumber::cast(result)->set_value(value); 2857 HeapNumber::cast(result)->set_value(value);
2857 return result; 2858 return result;
2858 } 2859 }
2859 2860
2860 2861
(...skipping 3684 matching lines...) Expand 10 before | Expand all | Expand 10 after
6545 *object_type = "CODE_TYPE"; \ 6546 *object_type = "CODE_TYPE"; \
6546 *object_sub_type = "CODE_AGE/" #name; \ 6547 *object_sub_type = "CODE_AGE/" #name; \
6547 return true; 6548 return true;
6548 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) 6549 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME)
6549 #undef COMPARE_AND_RETURN_NAME 6550 #undef COMPARE_AND_RETURN_NAME
6550 } 6551 }
6551 return false; 6552 return false;
6552 } 6553 }
6553 } 6554 }
6554 } // namespace v8::internal 6555 } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap/heap.h ('k') | src/heap/spaces.h » ('j') | src/heap/spaces-inl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698