Generalize HeapObject alignment requirements.
Removes EnsureDouble* methods. Adds a RequiredAlignment method. Changes call sites. LOG=N BUG=v8:4124 Review URL: https://codereview.chromium.org/1150953002 Cr-Commit-Position: refs/heads/master@{#28541}
This commit is contained in:
parent
41795b8ae2
commit
ebee0aa21a
@ -1941,9 +1941,7 @@ int MarkCompactCollector::DiscoverAndEvacuateBlackObjectsOnPage(
|
||||
continue;
|
||||
}
|
||||
|
||||
AllocationAlignment alignment = object->NeedsToEnsureDoubleAlignment()
|
||||
? kDoubleAligned
|
||||
: kWordAligned;
|
||||
AllocationAlignment alignment = object->RequiredAlignment();
|
||||
AllocationResult allocation = new_space->AllocateRaw(size, alignment);
|
||||
if (allocation.IsRetry()) {
|
||||
if (!new_space->AddFreshPage()) {
|
||||
@ -3105,8 +3103,7 @@ bool MarkCompactCollector::TryPromoteObject(HeapObject* object,
|
||||
OldSpace* old_space = heap()->old_space();
|
||||
|
||||
HeapObject* target;
|
||||
AllocationAlignment alignment =
|
||||
object->NeedsToEnsureDoubleAlignment() ? kDoubleAligned : kWordAligned;
|
||||
AllocationAlignment alignment = object->RequiredAlignment();
|
||||
AllocationResult allocation = old_space->AllocateRaw(object_size, alignment);
|
||||
if (allocation.To(&target)) {
|
||||
MigrateObject(target, object, object_size, old_space->identity());
|
||||
@ -3330,10 +3327,7 @@ void MarkCompactCollector::EvacuateLiveObjectsFromPage(Page* p) {
|
||||
DCHECK(Marking::IsBlack(Marking::MarkBitFrom(object)));
|
||||
|
||||
int size = object->Size();
|
||||
|
||||
AllocationAlignment alignment = object->NeedsToEnsureDoubleAlignment()
|
||||
? kDoubleAligned
|
||||
: kWordAligned;
|
||||
AllocationAlignment alignment = object->RequiredAlignment();
|
||||
HeapObject* target_object;
|
||||
AllocationResult allocation = space->AllocateRaw(size, alignment);
|
||||
if (!allocation.To(&target_object)) {
|
||||
|
@ -47,10 +47,6 @@ void HeapObject::HeapObjectVerify() {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO(yangguo): Use this check once crbug/436911 has been fixed.
|
||||
// DCHECK(!NeedsToEnsureDoubleAlignment() ||
|
||||
// IsAligned(OffsetFrom(address()), kDoubleAlignment));
|
||||
|
||||
switch (instance_type) {
|
||||
case SYMBOL_TYPE:
|
||||
Symbol::cast(this)->SymbolVerify();
|
||||
|
@ -2832,23 +2832,16 @@ WriteBarrierMode HeapObject::GetWriteBarrierMode(
|
||||
}
|
||||
|
||||
|
||||
bool HeapObject::NeedsToEnsureDoubleAlignment() {
|
||||
AllocationAlignment HeapObject::RequiredAlignment() {
|
||||
#ifdef V8_HOST_ARCH_32_BIT
|
||||
return (IsFixedFloat64Array() || IsFixedDoubleArray() ||
|
||||
IsConstantPoolArray()) &&
|
||||
FixedArrayBase::cast(this)->length() != 0;
|
||||
#else
|
||||
return false;
|
||||
#endif // V8_HOST_ARCH_32_BIT
|
||||
}
|
||||
|
||||
|
||||
bool HeapObject::NeedsToEnsureDoubleUnalignment() {
|
||||
#ifdef V8_HOST_ARCH_32_BIT
|
||||
return IsHeapNumber();
|
||||
#else
|
||||
return false;
|
||||
if ((IsFixedFloat64Array() || IsFixedDoubleArray() ||
|
||||
IsConstantPoolArray()) &&
|
||||
FixedArrayBase::cast(this)->length() != 0) {
|
||||
return kDoubleAligned;
|
||||
}
|
||||
if (IsHeapNumber()) return kDoubleUnaligned;
|
||||
#endif // V8_HOST_ARCH_32_BIT
|
||||
return kWordAligned;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1487,8 +1487,7 @@ class HeapObject: public Object {
|
||||
static void VerifyHeapPointer(Object* p);
|
||||
#endif
|
||||
|
||||
inline bool NeedsToEnsureDoubleAlignment();
|
||||
inline bool NeedsToEnsureDoubleUnalignment();
|
||||
inline AllocationAlignment RequiredAlignment();
|
||||
|
||||
// Layout description.
|
||||
// First field in a heap object is map.
|
||||
|
@ -1729,7 +1729,8 @@ void Serializer::ObjectSerializer::SerializePrologue(AllocationSpace space,
|
||||
back_reference = serializer_->AllocateLargeObject(size);
|
||||
} else {
|
||||
bool needs_double_align = false;
|
||||
if (object_->NeedsToEnsureDoubleAlignment()) {
|
||||
// TODO(bbudge): Generalize to other alignment constraints.
|
||||
if (object_->RequiredAlignment() == kDoubleAligned) {
|
||||
// Add wriggle room for double alignment padding.
|
||||
back_reference = serializer_->Allocate(space, size + kPointerSize);
|
||||
needs_double_align = true;
|
||||
|
Loading…
Reference in New Issue
Block a user