Commit 589ecbfa authored by bmeurer's avatar bmeurer Committed by Commit bot

[turbofan] Utilize maps from field type tracking to eliminate map checks.

Hook up TurboFan with the existing field type tracking machinery to
eliminate redundant map checks on the results of LoadField operators.
The store side is already implemented in TurboFan for quite some time,
this just adds the load part.

R=jarin@chromium.org
BUG=v8:5267

Review-Url: https://codereview.chromium.org/2604393002
Cr-Commit-Position: refs/heads/master@{#42015}
parent 4f95a1eb
......@@ -16,55 +16,58 @@ namespace compiler {
// static
FieldAccess AccessBuilder::ForExternalDoubleValue() {
FieldAccess access = {kUntaggedBase, 0,
MaybeHandle<Name>(), Type::Number(),
MachineType::Float64(), kNoWriteBarrier};
FieldAccess access = {kUntaggedBase, 0,
MaybeHandle<Name>(), MaybeHandle<Map>(),
Type::Number(), MachineType::Float64(),
kNoWriteBarrier};
return access;
}
// static
FieldAccess AccessBuilder::ForExternalUint8Value() {
FieldAccess access = {kUntaggedBase, 0,
MaybeHandle<Name>(), TypeCache::Get().kUint8,
MachineType::Uint8(), kNoWriteBarrier};
FieldAccess access = {kUntaggedBase, 0,
MaybeHandle<Name>(), MaybeHandle<Map>(),
TypeCache::Get().kUint8, MachineType::Uint8(),
kNoWriteBarrier};
return access;
}
// static
FieldAccess AccessBuilder::ForMap() {
FieldAccess access = {
kTaggedBase, HeapObject::kMapOffset, MaybeHandle<Name>(),
Type::OtherInternal(), MachineType::TaggedPointer(), kMapWriteBarrier};
FieldAccess access = {kTaggedBase, HeapObject::kMapOffset,
MaybeHandle<Name>(), MaybeHandle<Map>(),
Type::OtherInternal(), MachineType::TaggedPointer(),
kMapWriteBarrier};
return access;
}
// static
FieldAccess AccessBuilder::ForHeapNumberValue() {
FieldAccess access = {kTaggedBase,
HeapNumber::kValueOffset,
MaybeHandle<Name>(),
TypeCache::Get().kFloat64,
MachineType::Float64(),
kNoWriteBarrier};
FieldAccess access = {
kTaggedBase, HeapNumber::kValueOffset, MaybeHandle<Name>(),
MaybeHandle<Map>(), TypeCache::Get().kFloat64, MachineType::Float64(),
kNoWriteBarrier};
return access;
}
// static
FieldAccess AccessBuilder::ForJSObjectProperties() {
FieldAccess access = {
kTaggedBase, JSObject::kPropertiesOffset, MaybeHandle<Name>(),
Type::Internal(), MachineType::TaggedPointer(), kPointerWriteBarrier};
FieldAccess access = {kTaggedBase, JSObject::kPropertiesOffset,
MaybeHandle<Name>(), MaybeHandle<Map>(),
Type::Internal(), MachineType::TaggedPointer(),
kPointerWriteBarrier};
return access;
}
// static
FieldAccess AccessBuilder::ForJSObjectElements() {
FieldAccess access = {
kTaggedBase, JSObject::kElementsOffset, MaybeHandle<Name>(),
Type::Internal(), MachineType::TaggedPointer(), kPointerWriteBarrier};
FieldAccess access = {kTaggedBase, JSObject::kElementsOffset,
MaybeHandle<Name>(), MaybeHandle<Map>(),
Type::Internal(), MachineType::TaggedPointer(),
kPointerWriteBarrier};
return access;
}
......@@ -73,11 +76,9 @@ FieldAccess AccessBuilder::ForJSObjectElements() {
FieldAccess AccessBuilder::ForJSObjectInObjectProperty(Handle<Map> map,
int index) {
int const offset = map->GetInObjectPropertyOffset(index);
FieldAccess access = {kTaggedBase,
offset,
MaybeHandle<Name>(),
Type::NonInternal(),
MachineType::AnyTagged(),
FieldAccess access = {kTaggedBase, offset,
MaybeHandle<Name>(), MaybeHandle<Map>(),
Type::NonInternal(), MachineType::AnyTagged(),
kFullWriteBarrier};
return access;
}
......@@ -85,114 +86,108 @@ FieldAccess AccessBuilder::ForJSObjectInObjectProperty(Handle<Map> map,
// static
FieldAccess AccessBuilder::ForJSFunctionPrototypeOrInitialMap() {
FieldAccess access = {kTaggedBase,
JSFunction::kPrototypeOrInitialMapOffset,
MaybeHandle<Name>(),
Type::Any(),
MachineType::AnyTagged(),
kFullWriteBarrier};
FieldAccess access = {
kTaggedBase, JSFunction::kPrototypeOrInitialMapOffset,
MaybeHandle<Name>(), MaybeHandle<Map>(),
Type::Any(), MachineType::AnyTagged(),
kFullWriteBarrier};
return access;
}
// static
FieldAccess AccessBuilder::ForJSFunctionContext() {
FieldAccess access = {
kTaggedBase, JSFunction::kContextOffset, MaybeHandle<Name>(),
Type::Internal(), MachineType::AnyTagged(), kPointerWriteBarrier};
FieldAccess access = {kTaggedBase, JSFunction::kContextOffset,
MaybeHandle<Name>(), MaybeHandle<Map>(),
Type::Internal(), MachineType::AnyTagged(),
kPointerWriteBarrier};
return access;
}
// static
FieldAccess AccessBuilder::ForJSFunctionSharedFunctionInfo() {
FieldAccess access = {kTaggedBase,
JSFunction::kSharedFunctionInfoOffset,
Handle<Name>(),
Type::OtherInternal(),
MachineType::TaggedPointer(),
kPointerWriteBarrier};
FieldAccess access = {
kTaggedBase, JSFunction::kSharedFunctionInfoOffset,
Handle<Name>(), MaybeHandle<Map>(),
Type::OtherInternal(), MachineType::TaggedPointer(),
kPointerWriteBarrier};
return access;
}
// static
FieldAccess AccessBuilder::ForJSFunctionLiterals() {
FieldAccess access = {
kTaggedBase, JSFunction::kLiteralsOffset, Handle<Name>(),
Type::Internal(), MachineType::TaggedPointer(), kPointerWriteBarrier};
FieldAccess access = {kTaggedBase, JSFunction::kLiteralsOffset,
Handle<Name>(), MaybeHandle<Map>(),
Type::Internal(), MachineType::TaggedPointer(),
kPointerWriteBarrier};
return access;
}
// static
FieldAccess AccessBuilder::ForJSFunctionCodeEntry() {
FieldAccess access = {
kTaggedBase, JSFunction::kCodeEntryOffset, Handle<Name>(),
Type::OtherInternal(), MachineType::Pointer(), kNoWriteBarrier};
FieldAccess access = {kTaggedBase, JSFunction::kCodeEntryOffset,
Handle<Name>(), MaybeHandle<Map>(),
Type::OtherInternal(), MachineType::Pointer(),
kNoWriteBarrier};
return access;
}
// static
FieldAccess AccessBuilder::ForJSFunctionNextFunctionLink() {
FieldAccess access = {kTaggedBase,
JSFunction::kNextFunctionLinkOffset,
Handle<Name>(),
Type::Any(),
MachineType::AnyTagged(),
kPointerWriteBarrier};
FieldAccess access = {
kTaggedBase, JSFunction::kNextFunctionLinkOffset,
Handle<Name>(), MaybeHandle<Map>(),
Type::Any(), MachineType::AnyTagged(),
kPointerWriteBarrier};
return access;
}
// static
FieldAccess AccessBuilder::ForJSGeneratorObjectContext() {
FieldAccess access = {kTaggedBase,
JSGeneratorObject::kContextOffset,
Handle<Name>(),
Type::Internal(),
MachineType::TaggedPointer(),
FieldAccess access = {kTaggedBase, JSGeneratorObject::kContextOffset,
Handle<Name>(), MaybeHandle<Map>(),
Type::Internal(), MachineType::TaggedPointer(),
kPointerWriteBarrier};
return access;
}
// static
FieldAccess AccessBuilder::ForJSGeneratorObjectContinuation() {
FieldAccess access = {kTaggedBase,
JSGeneratorObject::kContinuationOffset,
Handle<Name>(),
Type::SignedSmall(),
MachineType::TaggedSigned(),
kNoWriteBarrier};
FieldAccess access = {
kTaggedBase, JSGeneratorObject::kContinuationOffset,
Handle<Name>(), MaybeHandle<Map>(),
Type::SignedSmall(), MachineType::TaggedSigned(),
kNoWriteBarrier};
return access;
}
// static
FieldAccess AccessBuilder::ForJSGeneratorObjectInputOrDebugPos() {
FieldAccess access = {kTaggedBase,
JSGeneratorObject::kInputOrDebugPosOffset,
Handle<Name>(),
Type::NonInternal(),
MachineType::AnyTagged(),
kFullWriteBarrier};
FieldAccess access = {
kTaggedBase, JSGeneratorObject::kInputOrDebugPosOffset,
Handle<Name>(), MaybeHandle<Map>(),
Type::NonInternal(), MachineType::AnyTagged(),
kFullWriteBarrier};
return access;
}
// static
FieldAccess AccessBuilder::ForJSGeneratorObjectRegisterFile() {
FieldAccess access = {kTaggedBase,
JSGeneratorObject::kRegisterFileOffset,
Handle<Name>(),
Type::Internal(),
MachineType::AnyTagged(),
kPointerWriteBarrier};
FieldAccess access = {
kTaggedBase, JSGeneratorObject::kRegisterFileOffset,
Handle<Name>(), MaybeHandle<Map>(),
Type::Internal(), MachineType::AnyTagged(),
kPointerWriteBarrier};
return access;
}
// static
FieldAccess AccessBuilder::ForJSGeneratorObjectResumeMode() {
FieldAccess access = {kTaggedBase,
JSGeneratorObject::kResumeModeOffset,
Handle<Name>(),
Type::SignedSmall(),
MachineType::TaggedSigned(),
kNoWriteBarrier};
FieldAccess access = {
kTaggedBase, JSGeneratorObject::kResumeModeOffset,
Handle<Name>(), MaybeHandle<Map>(),
Type::SignedSmall(), MachineType::TaggedSigned(),
kNoWriteBarrier};
return access;
}
......@@ -202,6 +197,7 @@ FieldAccess AccessBuilder::ForJSArrayLength(ElementsKind elements_kind) {
FieldAccess access = {kTaggedBase,
JSArray::kLengthOffset,
Handle<Name>(),
MaybeHandle<Map>(),
type_cache.kJSArrayLengthType,
MachineType::TaggedSigned(),
kFullWriteBarrier};
......@@ -218,30 +214,28 @@ FieldAccess AccessBuilder::ForJSArrayLength(ElementsKind elements_kind) {
// static
FieldAccess AccessBuilder::ForJSArrayBufferBackingStore() {
FieldAccess access = {kTaggedBase,
JSArrayBuffer::kBackingStoreOffset,
MaybeHandle<Name>(),
Type::OtherInternal(),
MachineType::Pointer(),
kNoWriteBarrier};
FieldAccess access = {
kTaggedBase, JSArrayBuffer::kBackingStoreOffset,
MaybeHandle<Name>(), MaybeHandle<Map>(),
Type::OtherInternal(), MachineType::Pointer(),
kNoWriteBarrier};
return access;
}
// static
FieldAccess AccessBuilder::ForJSArrayBufferBitField() {
FieldAccess access = {kTaggedBase, JSArrayBuffer::kBitFieldOffset,
MaybeHandle<Name>(), TypeCache::Get().kUint8,
MachineType::Uint32(), kNoWriteBarrier};
FieldAccess access = {
kTaggedBase, JSArrayBuffer::kBitFieldOffset, MaybeHandle<Name>(),
MaybeHandle<Map>(), TypeCache::Get().kUint8, MachineType::Uint32(),
kNoWriteBarrier};
return access;
}
// static
FieldAccess AccessBuilder::ForJSArrayBufferViewBuffer() {
FieldAccess access = {kTaggedBase,
JSArrayBufferView::kBufferOffset,
MaybeHandle<Name>(),
Type::OtherInternal(),
MachineType::TaggedPointer(),
FieldAccess access = {kTaggedBase, JSArrayBufferView::kBufferOffset,
MaybeHandle<Name>(), MaybeHandle<Map>(),
Type::OtherInternal(), MachineType::TaggedPointer(),
kPointerWriteBarrier};
return access;
}
......@@ -251,6 +245,7 @@ FieldAccess AccessBuilder::ForJSArrayBufferViewByteLength() {
FieldAccess access = {kTaggedBase,
JSArrayBufferView::kByteLengthOffset,
MaybeHandle<Name>(),
MaybeHandle<Map>(),
TypeCache::Get().kPositiveInteger,
MachineType::AnyTagged(),
kFullWriteBarrier};
......@@ -262,6 +257,7 @@ FieldAccess AccessBuilder::ForJSArrayBufferViewByteOffset() {
FieldAccess access = {kTaggedBase,
JSArrayBufferView::kByteOffsetOffset,
MaybeHandle<Name>(),
MaybeHandle<Map>(),
TypeCache::Get().kPositiveInteger,
MachineType::AnyTagged(),
kFullWriteBarrier};
......@@ -273,6 +269,7 @@ FieldAccess AccessBuilder::ForJSTypedArrayLength() {
FieldAccess access = {kTaggedBase,
JSTypedArray::kLengthOffset,
MaybeHandle<Name>(),
MaybeHandle<Map>(),
TypeCache::Get().kJSTypedArrayLengthType,
MachineType::TaggedSigned(),
kNoWriteBarrier};
......@@ -284,6 +281,7 @@ FieldAccess AccessBuilder::ForJSDateValue() {
FieldAccess access = {kTaggedBase,
JSDate::kValueOffset,
MaybeHandle<Name>(),
MaybeHandle<Map>(),
TypeCache::Get().kJSDateValueType,
MachineType::AnyTagged(),
kFullWriteBarrier};
......@@ -292,48 +290,51 @@ FieldAccess AccessBuilder::ForJSDateValue() {
// static
FieldAccess AccessBuilder::ForJSDateField(JSDate::FieldIndex index) {
FieldAccess access = {kTaggedBase,
JSDate::kValueOffset + index * kPointerSize,
MaybeHandle<Name>(),
Type::Number(),
MachineType::AnyTagged(),
kFullWriteBarrier};
FieldAccess access = {
kTaggedBase, JSDate::kValueOffset + index * kPointerSize,
MaybeHandle<Name>(), MaybeHandle<Map>(),
Type::Number(), MachineType::AnyTagged(),
kFullWriteBarrier};
return access;
}
// static
FieldAccess AccessBuilder::ForJSIteratorResultDone() {
FieldAccess access = {
kTaggedBase, JSIteratorResult::kDoneOffset, MaybeHandle<Name>(),
Type::NonInternal(), MachineType::AnyTagged(), kFullWriteBarrier};
FieldAccess access = {kTaggedBase, JSIteratorResult::kDoneOffset,
MaybeHandle<Name>(), MaybeHandle<Map>(),
Type::NonInternal(), MachineType::AnyTagged(),
kFullWriteBarrier};
return access;
}
// static
FieldAccess AccessBuilder::ForJSIteratorResultValue() {
FieldAccess access = {
kTaggedBase, JSIteratorResult::kValueOffset, MaybeHandle<Name>(),
Type::NonInternal(), MachineType::AnyTagged(), kFullWriteBarrier};
FieldAccess access = {kTaggedBase, JSIteratorResult::kValueOffset,
MaybeHandle<Name>(), MaybeHandle<Map>(),
Type::NonInternal(), MachineType::AnyTagged(),
kFullWriteBarrier};
return access;
}
// static
FieldAccess AccessBuilder::ForJSRegExpFlags() {
FieldAccess access = {
kTaggedBase, JSRegExp::kFlagsOffset, MaybeHandle<Name>(),
Type::NonInternal(), MachineType::AnyTagged(), kFullWriteBarrier};
FieldAccess access = {kTaggedBase, JSRegExp::kFlagsOffset,
MaybeHandle<Name>(), MaybeHandle<Map>(),
Type::NonInternal(), MachineType::AnyTagged(),
kFullWriteBarrier};
return access;
}
// static
FieldAccess AccessBuilder::ForJSRegExpSource() {
FieldAccess access = {
kTaggedBase, JSRegExp::kSourceOffset, MaybeHandle<Name>(),
Type::NonInternal(), MachineType::AnyTagged(), kFullWriteBarrier};
FieldAccess access = {kTaggedBase, JSRegExp::kSourceOffset,
MaybeHandle<Name>(), MaybeHandle<Map>(),
Type::NonInternal(), MachineType::AnyTagged(),
kFullWriteBarrier};
return access;
}
......@@ -343,6 +344,7 @@ FieldAccess AccessBuilder::ForFixedArrayLength() {
FieldAccess access = {kTaggedBase,
FixedArray::kLengthOffset,
MaybeHandle<Name>(),
MaybeHandle<Map>(),
TypeCache::Get().kFixedArrayLengthType,
MachineType::TaggedSigned(),
kNoWriteBarrier};
......@@ -351,12 +353,11 @@ FieldAccess AccessBuilder::ForFixedArrayLength() {
// static
FieldAccess AccessBuilder::ForFixedTypedArrayBaseBasePointer() {
FieldAccess access = {kTaggedBase,
FixedTypedArrayBase::kBasePointerOffset,
MaybeHandle<Name>(),
Type::OtherInternal(),
MachineType::AnyTagged(),
kPointerWriteBarrier};
FieldAccess access = {
kTaggedBase, FixedTypedArrayBase::kBasePointerOffset,
MaybeHandle<Name>(), MaybeHandle<Map>(),
Type::OtherInternal(), MachineType::AnyTagged(),
kPointerWriteBarrier};
return access;
}
......@@ -365,6 +366,7 @@ FieldAccess AccessBuilder::ForFixedTypedArrayBaseExternalPointer() {
FieldAccess access = {kTaggedBase,
FixedTypedArrayBase::kExternalPointerOffset,
MaybeHandle<Name>(),
MaybeHandle<Map>(),
Type::ExternalPointer(),
MachineType::Pointer(),
kNoWriteBarrier};
......@@ -373,53 +375,51 @@ FieldAccess AccessBuilder::ForFixedTypedArrayBaseExternalPointer() {
// static
FieldAccess AccessBuilder::ForDescriptorArrayEnumCache() {
FieldAccess access = {kTaggedBase,
DescriptorArray::kEnumCacheOffset,
Handle<Name>(),
Type::OtherInternal(),
MachineType::TaggedPointer(),
kPointerWriteBarrier};
FieldAccess access = {
kTaggedBase, DescriptorArray::kEnumCacheOffset,
Handle<Name>(), MaybeHandle<Map>(),
Type::OtherInternal(), MachineType::TaggedPointer(),
kPointerWriteBarrier};
return access;
}
// static
FieldAccess AccessBuilder::ForDescriptorArrayEnumCacheBridgeCache() {
FieldAccess access = {kTaggedBase,
DescriptorArray::kEnumCacheBridgeCacheOffset,
Handle<Name>(),
Type::OtherInternal(),
MachineType::TaggedPointer(),
kPointerWriteBarrier};
FieldAccess access = {
kTaggedBase, DescriptorArray::kEnumCacheBridgeCacheOffset,
Handle<Name>(), MaybeHandle<Map>(),
Type::OtherInternal(), MachineType::TaggedPointer(),
kPointerWriteBarrier};
return access;
}
// static
FieldAccess AccessBuilder::ForMapBitField() {
FieldAccess access = {kTaggedBase, Map::kBitFieldOffset,
Handle<Name>(), TypeCache::Get().kUint8,
MachineType::Uint8(), kNoWriteBarrier};
FieldAccess access = {
kTaggedBase, Map::kBitFieldOffset, Handle<Name>(),
MaybeHandle<Map>(), TypeCache::Get().kUint8, MachineType::Uint8(),
kNoWriteBarrier};
return access;
}
// static
FieldAccess AccessBuilder::ForMapBitField3() {
FieldAccess access = {kTaggedBase, Map::kBitField3Offset,
Handle<Name>(), TypeCache::Get().kInt32,
MachineType::Int32(), kNoWriteBarrier};
FieldAccess access = {
kTaggedBase, Map::kBitField3Offset, Handle<Name>(),
MaybeHandle<Map>(), TypeCache::Get().kInt32, MachineType::Int32(),
kNoWriteBarrier};
return access;
}
// static
FieldAccess AccessBuilder::ForMapDescriptors() {
FieldAccess access = {kTaggedBase,
Map::kDescriptorsOffset,
Handle<Name>(),
Type::OtherInternal(),
MachineType::TaggedPointer(),
FieldAccess access = {kTaggedBase, Map::kDescriptorsOffset,
Handle<Name>(), MaybeHandle<Map>(),
Type::OtherInternal(), MachineType::TaggedPointer(),
kPointerWriteBarrier};
return access;
}
......@@ -427,48 +427,47 @@ FieldAccess AccessBuilder::ForMapDescriptors() {
// static
FieldAccess AccessBuilder::ForMapInstanceType() {
FieldAccess access = {kTaggedBase, Map::kInstanceTypeOffset,
Handle<Name>(), TypeCache::Get().kUint8,
MachineType::Uint8(), kNoWriteBarrier};
FieldAccess access = {
kTaggedBase, Map::kInstanceTypeOffset, Handle<Name>(),
MaybeHandle<Map>(), TypeCache::Get().kUint8, MachineType::Uint8(),
kNoWriteBarrier};
return access;
}
// static
FieldAccess AccessBuilder::ForMapPrototype() {
FieldAccess access = {
kTaggedBase, Map::kPrototypeOffset, Handle<Name>(),
Type::Any(), MachineType::TaggedPointer(), kPointerWriteBarrier};
FieldAccess access = {kTaggedBase, Map::kPrototypeOffset,
Handle<Name>(), MaybeHandle<Map>(),
Type::Any(), MachineType::TaggedPointer(),
kPointerWriteBarrier};
return access;
}
// static
FieldAccess AccessBuilder::ForModuleRegularExports() {
FieldAccess access = {kTaggedBase,
Module::kRegularExportsOffset,
Handle<Name>(),
Type::OtherInternal(),
MachineType::TaggedPointer(),
FieldAccess access = {kTaggedBase, Module::kRegularExportsOffset,
Handle<Name>(), MaybeHandle<Map>(),
Type::OtherInternal(), MachineType::TaggedPointer(),
kPointerWriteBarrier};
return access;
}
// static
FieldAccess AccessBuilder::ForModuleRegularImports() {
FieldAccess access = {kTaggedBase,
Module::kRegularImportsOffset,
Handle<Name>(),
Type::OtherInternal(),
MachineType::TaggedPointer(),
FieldAccess access = {kTaggedBase, Module::kRegularImportsOffset,
Handle<Name>(), MaybeHandle<Map>(),
Type::OtherInternal(), MachineType::TaggedPointer(),
kPointerWriteBarrier};
return access;
}
// static
FieldAccess AccessBuilder::ForNameHashField() {
FieldAccess access = {kTaggedBase, Name::kHashFieldOffset,
Handle<Name>(), Type::Internal(),
MachineType::Uint32(), kNoWriteBarrier};
FieldAccess access = {kTaggedBase, Name::kHashFieldOffset,
Handle<Name>(), MaybeHandle<Map>(),
Type::Internal(), MachineType::Uint32(),
kNoWriteBarrier};
return access;
}
......@@ -477,6 +476,7 @@ FieldAccess AccessBuilder::ForStringLength() {
FieldAccess access = {kTaggedBase,
String::kLengthOffset,
Handle<Name>(),
MaybeHandle<Map>(),
TypeCache::Get().kStringLengthType,
MachineType::TaggedSigned(),
kNoWriteBarrier};
......@@ -485,33 +485,37 @@ FieldAccess AccessBuilder::ForStringLength() {
// static
FieldAccess AccessBuilder::ForConsStringFirst() {
FieldAccess access = {
kTaggedBase, ConsString::kFirstOffset, Handle<Name>(),
Type::String(), MachineType::TaggedPointer(), kPointerWriteBarrier};
FieldAccess access = {kTaggedBase, ConsString::kFirstOffset,
Handle<Name>(), MaybeHandle<Map>(),
Type::String(), MachineType::TaggedPointer(),
kPointerWriteBarrier};
return access;
}
// static
FieldAccess AccessBuilder::ForConsStringSecond() {
FieldAccess access = {
kTaggedBase, ConsString::kSecondOffset, Handle<Name>(),
Type::String(), MachineType::TaggedPointer(), kPointerWriteBarrier};
FieldAccess access = {kTaggedBase, ConsString::kSecondOffset,
Handle<Name>(), MaybeHandle<Map>(),
Type::String(), MachineType::TaggedPointer(),
kPointerWriteBarrier};
return access;
}
// static
FieldAccess AccessBuilder::ForSlicedStringOffset() {
FieldAccess access = {
kTaggedBase, SlicedString::kOffsetOffset, Handle<Name>(),
Type::SignedSmall(), MachineType::TaggedSigned(), kNoWriteBarrier};
FieldAccess access = {kTaggedBase, SlicedString::kOffsetOffset,
Handle<Name>(), MaybeHandle<Map>(),
Type::SignedSmall(), MachineType::TaggedSigned(),
kNoWriteBarrier};
return access;
}
// static
FieldAccess AccessBuilder::ForSlicedStringParent() {
FieldAccess access = {
kTaggedBase, SlicedString::kParentOffset, Handle<Name>(),
Type::String(), MachineType::TaggedPointer(), kPointerWriteBarrier};
FieldAccess access = {kTaggedBase, SlicedString::kParentOffset,
Handle<Name>(), MaybeHandle<Map>(),
Type::String(), MachineType::TaggedPointer(),
kPointerWriteBarrier};
return access;
}
......@@ -520,6 +524,7 @@ FieldAccess AccessBuilder::ForExternalStringResourceData() {
FieldAccess access = {kTaggedBase,
ExternalString::kResourceDataOffset,
Handle<Name>(),
MaybeHandle<Map>(),
Type::ExternalPointer(),
MachineType::Pointer(),
kNoWriteBarrier};
......@@ -558,23 +563,20 @@ ElementAccess AccessBuilder::ForSeqTwoByteStringCharacter() {
// static
FieldAccess AccessBuilder::ForJSGlobalObjectGlobalProxy() {
FieldAccess access = {kTaggedBase,
JSGlobalObject::kGlobalProxyOffset,
Handle<Name>(),
Type::Receiver(),
MachineType::TaggedPointer(),
FieldAccess access = {kTaggedBase, JSGlobalObject::kGlobalProxyOffset,
Handle<Name>(), MaybeHandle<Map>(),
Type::Receiver(), MachineType::TaggedPointer(),
kPointerWriteBarrier};
return access;
}
// static
FieldAccess AccessBuilder::ForJSGlobalObjectNativeContext() {
FieldAccess access = {kTaggedBase,
JSGlobalObject::kNativeContextOffset,
Handle<Name>(),
Type::Internal(),
MachineType::TaggedPointer(),
kPointerWriteBarrier};
FieldAccess access = {
kTaggedBase, JSGlobalObject::kNativeContextOffset,
Handle<Name>(), MaybeHandle<Map>(),
Type::Internal(), MachineType::TaggedPointer(),
kPointerWriteBarrier};
return access;
}
......@@ -583,6 +585,7 @@ FieldAccess AccessBuilder::ForJSArrayIteratorObject() {
FieldAccess access = {kTaggedBase,
JSArrayIterator::kIteratedObjectOffset,
Handle<Name>(),
MaybeHandle<Map>(),
Type::ReceiverOrUndefined(),
MachineType::TaggedPointer(),
kPointerWriteBarrier};
......@@ -597,6 +600,7 @@ FieldAccess AccessBuilder::ForJSArrayIteratorIndex(InstanceType instance_type,
FieldAccess access = {kTaggedBase,
JSArrayIterator::kNextIndexOffset,
Handle<Name>(),
MaybeHandle<Map>(),
TypeCache::Get().kPositiveSafeInteger,
MachineType::AnyTagged(),
kFullWriteBarrier};
......@@ -622,20 +626,20 @@ FieldAccess AccessBuilder::ForJSArrayIteratorIndex(InstanceType instance_type,
// static
FieldAccess AccessBuilder::ForJSArrayIteratorObjectMap() {
FieldAccess access = {kTaggedBase,
JSArrayIterator::kIteratedObjectMapOffset,
Handle<Name>(),
Type::OtherInternal(),
MachineType::TaggedPointer(),
kPointerWriteBarrier};
FieldAccess access = {
kTaggedBase, JSArrayIterator::kIteratedObjectMapOffset,
Handle<Name>(), MaybeHandle<Map>(),
Type::OtherInternal(), MachineType::TaggedPointer(),
kPointerWriteBarrier};
return access;
}
// static
FieldAccess AccessBuilder::ForJSStringIteratorString() {
FieldAccess access = {
kTaggedBase, JSStringIterator::kStringOffset, Handle<Name>(),
Type::String(), MachineType::TaggedPointer(), kPointerWriteBarrier};
FieldAccess access = {kTaggedBase, JSStringIterator::kStringOffset,
Handle<Name>(), MaybeHandle<Map>(),
Type::String(), MachineType::TaggedPointer(),
kPointerWriteBarrier};
return access;
}
......@@ -644,6 +648,7 @@ FieldAccess AccessBuilder::ForJSStringIteratorIndex() {
FieldAccess access = {kTaggedBase,
JSStringIterator::kNextIndexOffset,
Handle<Name>(),
MaybeHandle<Map>(),
TypeCache::Get().kStringLengthType,
MachineType::TaggedSigned(),
kNoWriteBarrier};
......@@ -652,30 +657,31 @@ FieldAccess AccessBuilder::ForJSStringIteratorIndex() {
// static
FieldAccess AccessBuilder::ForValue() {
FieldAccess access = {
kTaggedBase, JSValue::kValueOffset, Handle<Name>(),
Type::NonInternal(), MachineType::AnyTagged(), kFullWriteBarrier};
FieldAccess access = {kTaggedBase, JSValue::kValueOffset,
Handle<Name>(), MaybeHandle<Map>(),
Type::NonInternal(), MachineType::AnyTagged(),
kFullWriteBarrier};
return access;
}
// static
FieldAccess AccessBuilder::ForArgumentsLength() {
FieldAccess access = {
kTaggedBase, JSArgumentsObject::kLengthOffset, Handle<Name>(),
Type::NonInternal(), MachineType::AnyTagged(), kFullWriteBarrier};
FieldAccess access = {kTaggedBase, JSArgumentsObject::kLengthOffset,
Handle<Name>(), MaybeHandle<Map>(),
Type::NonInternal(), MachineType::AnyTagged(),
kFullWriteBarrier};
return access;
}
// static
FieldAccess AccessBuilder::ForArgumentsCallee() {
FieldAccess access = {kTaggedBase,
JSSloppyArgumentsObject::kCalleeOffset,
Handle<Name>(),
Type::NonInternal(),
MachineType::AnyTagged(),
kPointerWriteBarrier};
FieldAccess access = {
kTaggedBase, JSSloppyArgumentsObject::kCalleeOffset,
Handle<Name>(), MaybeHandle<Map>(),
Type::NonInternal(), MachineType::AnyTagged(),
kPointerWriteBarrier};
return access;
}
......@@ -683,11 +689,9 @@ FieldAccess AccessBuilder::ForArgumentsCallee() {
// static
FieldAccess AccessBuilder::ForFixedArraySlot(size_t index) {
int offset = FixedArray::OffsetOfElementAt(static_cast<int>(index));
FieldAccess access = {kTaggedBase,
offset,
Handle<Name>(),
Type::NonInternal(),
MachineType::AnyTagged(),
FieldAccess access = {kTaggedBase, offset,
Handle<Name>(), MaybeHandle<Map>(),
Type::NonInternal(), MachineType::AnyTagged(),
kFullWriteBarrier};
return access;
}
......@@ -695,9 +699,10 @@ FieldAccess AccessBuilder::ForFixedArraySlot(size_t index) {
// static
FieldAccess AccessBuilder::ForCellValue() {
FieldAccess access = {
kTaggedBase, Cell::kValueOffset, Handle<Name>(),
Type::Any(), MachineType::AnyTagged(), kFullWriteBarrier};
FieldAccess access = {kTaggedBase, Cell::kValueOffset,
Handle<Name>(), MaybeHandle<Map>(),
Type::Any(), MachineType::AnyTagged(),
kFullWriteBarrier};
return access;
}
......@@ -706,31 +711,29 @@ FieldAccess AccessBuilder::ForContextSlot(size_t index) {
int offset = Context::kHeaderSize + static_cast<int>(index) * kPointerSize;
DCHECK_EQ(offset,
Context::SlotOffset(static_cast<int>(index)) + kHeapObjectTag);
FieldAccess access = {kTaggedBase,
offset,
Handle<Name>(),
Type::Any(),
MachineType::AnyTagged(),
FieldAccess access = {kTaggedBase, offset,
Handle<Name>(), MaybeHandle<Map>(),
Type::Any(), MachineType::AnyTagged(),
kFullWriteBarrier};
return access;
}
// static
FieldAccess AccessBuilder::ForContextExtensionScopeInfo() {
FieldAccess access = {kTaggedBase,
ContextExtension::kScopeInfoOffset,
Handle<Name>(),
Type::OtherInternal(),
MachineType::AnyTagged(),
kFullWriteBarrier};
FieldAccess access = {
kTaggedBase, ContextExtension::kScopeInfoOffset,
Handle<Name>(), MaybeHandle<Map>(),
Type::OtherInternal(), MachineType::AnyTagged(),
kFullWriteBarrier};
return access;
}
// static
FieldAccess AccessBuilder::ForContextExtensionExtension() {
FieldAccess access = {
kTaggedBase, ContextExtension::kExtensionOffset, Handle<Name>(),
Type::Any(), MachineType::AnyTagged(), kFullWriteBarrier};
FieldAccess access = {kTaggedBase, ContextExtension::kExtensionOffset,
Handle<Name>(), MaybeHandle<Map>(),
Type::Any(), MachineType::AnyTagged(),
kFullWriteBarrier};
return access;
}
......
......@@ -1186,9 +1186,10 @@ Node* JSCreateLowering::AllocateFastLiteral(
Handle<Name> property_name(
boilerplate_map->instance_descriptors()->GetKey(i), isolate());
FieldIndex index = FieldIndex::ForDescriptor(*boilerplate_map, i);
FieldAccess access = {
kTaggedBase, index.offset(), property_name,
Type::Any(), MachineType::AnyTagged(), kFullWriteBarrier};
FieldAccess access = {kTaggedBase, index.offset(),
property_name, MaybeHandle<Map>(),
Type::Any(), MachineType::AnyTagged(),
kFullWriteBarrier};
Node* value;
if (boilerplate->IsUnboxedDoubleField(index)) {
access.machine_type = MachineType::Float64();
......
......@@ -49,7 +49,8 @@ Reduction JSGlobalObjectSpecialization::Reduce(Node* node) {
namespace {
FieldAccess ForPropertyCellValue(MachineRepresentation representation,
Type* type, Handle<Name> name) {
Type* type, MaybeHandle<Map> map,
Handle<Name> name) {
WriteBarrierKind kind = kFullWriteBarrier;
if (representation == MachineRepresentation::kTaggedSigned) {
kind = kNoWriteBarrier;
......@@ -57,8 +58,8 @@ FieldAccess ForPropertyCellValue(MachineRepresentation representation,
kind = kPointerWriteBarrier;
}
MachineType r = MachineType::TypeForRepresentation(representation);
FieldAccess access = {kTaggedBase, PropertyCell::kValueOffset, name, type, r,
kind};
FieldAccess access = {
kTaggedBase, PropertyCell::kValueOffset, name, map, type, r, kind};
return access;
}
} // namespace
......@@ -115,6 +116,7 @@ Reduction JSGlobalObjectSpecialization::ReduceJSLoadGlobal(Node* node) {
}
// Load from constant type cell can benefit from type feedback.
MaybeHandle<Map> map;
Type* property_cell_value_type = Type::NonInternal();
MachineRepresentation representation = MachineRepresentation::kTagged;
if (property_details.cell_type() == PropertyCellType::kConstantType) {
......@@ -126,18 +128,24 @@ Reduction JSGlobalObjectSpecialization::ReduceJSLoadGlobal(Node* node) {
property_cell_value_type = Type::Number();
representation = MachineRepresentation::kTaggedPointer;
} else {
// TODO(turbofan): Track the property_cell_value_map on the FieldAccess
// below and use it in LoadElimination to eliminate map checks.
Handle<Map> property_cell_value_map(
Handle<HeapObject>::cast(property_cell_value)->map(), isolate());
property_cell_value_type = Type::For(property_cell_value_map);
representation = MachineRepresentation::kTaggedPointer;
// We can only use the property cell value map for map check elimination
// if it's stable, i.e. the HeapObject wasn't mutated without the cell
// state being updated.
if (property_cell_value_map->is_stable()) {
dependencies()->AssumeMapStable(property_cell_value_map);
map = property_cell_value_map;
}
}
}
Node* value = effect =
graph()->NewNode(simplified()->LoadField(ForPropertyCellValue(
representation, property_cell_value_type, name)),
jsgraph()->HeapConstant(property_cell), effect, control);
Node* value = effect = graph()->NewNode(
simplified()->LoadField(ForPropertyCellValue(
representation, property_cell_value_type, map, name)),
jsgraph()->HeapConstant(property_cell), effect, control);
ReplaceWithValue(node, value, effect, control);
return Replace(value);
}
......@@ -218,10 +226,11 @@ Reduction JSGlobalObjectSpecialization::ReduceJSStoreGlobal(Node* node) {
property_cell_value_type = Type::SignedSmall();
representation = MachineRepresentation::kTaggedSigned;
}
effect = graph()->NewNode(
simplified()->StoreField(ForPropertyCellValue(
representation, property_cell_value_type, name)),
jsgraph()->HeapConstant(property_cell), value, effect, control);
effect = graph()->NewNode(simplified()->StoreField(ForPropertyCellValue(
representation, property_cell_value_type,
MaybeHandle<Map>(), name)),
jsgraph()->HeapConstant(property_cell), value,
effect, control);
break;
}
case PropertyCellType::kMutable: {
......@@ -230,7 +239,8 @@ Reduction JSGlobalObjectSpecialization::ReduceJSStoreGlobal(Node* node) {
dependencies()->AssumePropertyCell(property_cell);
effect = graph()->NewNode(
simplified()->StoreField(ForPropertyCellValue(
MachineRepresentation::kTagged, Type::NonInternal(), name)),
MachineRepresentation::kTagged, Type::NonInternal(),
MaybeHandle<Map>(), name)),
jsgraph()->HeapConstant(property_cell), value, effect, control);
break;
}
......
......@@ -1095,6 +1095,7 @@ JSNativeContextSpecialization::BuildPropertyAccess(
kTaggedBase,
field_index.offset(),
name,
MaybeHandle<Map>(),
field_type,
MachineType::TypeForRepresentation(field_representation),
kFullWriteBarrier};
......@@ -1105,6 +1106,7 @@ JSNativeContextSpecialization::BuildPropertyAccess(
FieldAccess const storage_access = {kTaggedBase,
field_index.offset(),
name,
MaybeHandle<Map>(),
Type::OtherInternal(),
MachineType::TaggedPointer(),
kPointerWriteBarrier};
......@@ -1114,9 +1116,18 @@ JSNativeContextSpecialization::BuildPropertyAccess(
field_access.offset = HeapNumber::kValueOffset;
field_access.name = MaybeHandle<Name>();
}
} else if (field_representation ==
MachineRepresentation::kTaggedPointer) {
// Remember the map of the field value, if its map is stable. This is
// used by the LoadElimination to eliminate map checks on the result.
Handle<Map> field_map;
if (access_info.field_map().ToHandle(&field_map)) {
if (field_map->is_stable()) {
dependencies()->AssumeMapStable(field_map);
field_access.map = field_map;
}
}
}
// TODO(turbofan): Track the field_map (if any) on the {field_access} and
// use it in LoadElimination to eliminate map checks.
value = effect = graph()->NewNode(simplified()->LoadField(field_access),
storage, effect, control);
} else {
......@@ -1153,6 +1164,7 @@ JSNativeContextSpecialization::BuildPropertyAccess(
FieldAccess const storage_access = {kTaggedBase,
field_index.offset(),
name,
MaybeHandle<Map>(),
Type::OtherInternal(),
MachineType::TaggedPointer(),
kPointerWriteBarrier};
......
......@@ -744,6 +744,10 @@ Reduction LoadElimination::ReduceLoadField(Node* node) {
state = state->AddField(object, field_index, node, zone());
}
}
Handle<Map> field_map;
if (access.map.ToHandle(&field_map)) {
state = state->AddMaps(node, ZoneHandleSet<Map>(field_map), zone());
}
return UpdateState(node, state);
}
......
......@@ -92,6 +92,7 @@ bool operator==(FieldAccess const& lhs, FieldAccess const& rhs) {
// really only relevant for eliminating loads and they don't care about the
// write barrier mode.
return lhs.base_is_tagged == rhs.base_is_tagged && lhs.offset == rhs.offset &&
lhs.map.address() == rhs.map.address() &&
lhs.machine_type == rhs.machine_type;
}
......@@ -118,6 +119,10 @@ std::ostream& operator<<(std::ostream& os, FieldAccess const& access) {
name->Print(os);
os << ", ";
}
Handle<Map> map;
if (access.map.ToHandle(&map)) {
os << Brief(*map) << ", ";
}
#endif
access.type->PrintTo(os);
os << ", " << access.machine_type << ", " << access.write_barrier_kind << "]";
......
......@@ -65,6 +65,7 @@ struct FieldAccess {
BaseTaggedness base_is_tagged; // specifies if the base pointer is tagged.
int offset; // offset of the field, without tag.
MaybeHandle<Name> name; // debugging only.
MaybeHandle<Map> map; // map of the field value (if known).
Type* type; // type of the field.
MachineType machine_type; // machine type of the field.
WriteBarrierKind write_barrier_kind; // write barrier hint.
......
......@@ -148,11 +148,9 @@ class EscapeAnalysisTest : public TypedGraphTest {
}
FieldAccess FieldAccessAtIndex(int offset) {
FieldAccess access = {kTaggedBase,
offset,
MaybeHandle<Name>(),
Type::Any(),
MachineType::AnyTagged(),
FieldAccess access = {kTaggedBase, offset,
MaybeHandle<Name>(), MaybeHandle<Map>(),
Type::Any(), MachineType::AnyTagged(),
kFullWriteBarrier};
return access;
}
......
......@@ -125,11 +125,9 @@ TEST_F(LoadEliminationTest, LoadFieldAndLoadField) {
Node* object = Parameter(Type::Any(), 0);
Node* effect = graph()->start();
Node* control = graph()->start();
FieldAccess const access = {kTaggedBase,
kPointerSize,
MaybeHandle<Name>(),
Type::Any(),
MachineType::AnyTagged(),
FieldAccess const access = {kTaggedBase, kPointerSize,
MaybeHandle<Name>(), MaybeHandle<Map>(),
Type::Any(), MachineType::AnyTagged(),
kNoWriteBarrier};
StrictMock<MockAdvancedReducerEditor> editor;
......@@ -154,11 +152,9 @@ TEST_F(LoadEliminationTest, StoreFieldAndLoadField) {
Node* value = Parameter(Type::Any(), 1);
Node* effect = graph()->start();
Node* control = graph()->start();
FieldAccess access = {kTaggedBase,
kPointerSize,
MaybeHandle<Name>(),
Type::Any(),
MachineType::AnyTagged(),
FieldAccess access = {kTaggedBase, kPointerSize,
MaybeHandle<Name>(), MaybeHandle<Map>(),
Type::Any(), MachineType::AnyTagged(),
kNoWriteBarrier};
StrictMock<MockAdvancedReducerEditor> editor;
......@@ -184,11 +180,9 @@ TEST_F(LoadEliminationTest, StoreFieldAndStoreElementAndLoadField) {
Node* index = Parameter(Type::UnsignedSmall(), 2);
Node* effect = graph()->start();
Node* control = graph()->start();
FieldAccess access = {kTaggedBase,
kPointerSize,
MaybeHandle<Name>(),
Type::Any(),
MachineType::AnyTagged(),
FieldAccess access = {kTaggedBase, kPointerSize,
MaybeHandle<Name>(), MaybeHandle<Map>(),
Type::Any(), MachineType::AnyTagged(),
kNoWriteBarrier};
StrictMock<MockAdvancedReducerEditor> editor;
......@@ -288,11 +282,9 @@ TEST_F(LoadEliminationTest, LoadFieldOnFalseBranchOfDiamond) {
Node* check = Parameter(Type::Boolean(), 1);
Node* effect = graph()->start();
Node* control = graph()->start();
FieldAccess const access = {kTaggedBase,
kPointerSize,
MaybeHandle<Name>(),
Type::Any(),
MachineType::AnyTagged(),
FieldAccess const access = {kTaggedBase, kPointerSize,
MaybeHandle<Name>(), MaybeHandle<Map>(),
Type::Any(), MachineType::AnyTagged(),
kNoWriteBarrier};
StrictMock<MockAdvancedReducerEditor> editor;
......@@ -326,11 +318,9 @@ TEST_F(LoadEliminationTest, LoadFieldOnTrueBranchOfDiamond) {
Node* check = Parameter(Type::Boolean(), 1);
Node* effect = graph()->start();
Node* control = graph()->start();
FieldAccess const access = {kTaggedBase,
kPointerSize,
MaybeHandle<Name>(),
Type::Any(),
MachineType::AnyTagged(),
FieldAccess const access = {kTaggedBase, kPointerSize,
MaybeHandle<Name>(), MaybeHandle<Map>(),
Type::Any(), MachineType::AnyTagged(),
kNoWriteBarrier};
StrictMock<MockAdvancedReducerEditor> editor;
......@@ -364,11 +354,9 @@ TEST_F(LoadEliminationTest, LoadFieldWithTypeMismatch) {
Node* value = Parameter(Type::Signed32(), 1);
Node* effect = graph()->start();
Node* control = graph()->start();
FieldAccess const access = {kTaggedBase,
kPointerSize,
MaybeHandle<Name>(),
Type::Unsigned31(),
MachineType::AnyTagged(),
FieldAccess const access = {kTaggedBase, kPointerSize,
MaybeHandle<Name>(), MaybeHandle<Map>(),
Type::Unsigned31(), MachineType::AnyTagged(),
kNoWriteBarrier};
StrictMock<MockAdvancedReducerEditor> editor;
......@@ -422,11 +410,9 @@ TEST_F(LoadEliminationTest, AliasAnalysisForFinishRegion) {
Node* value1 = Parameter(Type::Signed32(), 1);
Node* effect = graph()->start();
Node* control = graph()->start();
FieldAccess const access = {kTaggedBase,
kPointerSize,
MaybeHandle<Name>(),
Type::Signed32(),
MachineType::AnyTagged(),
FieldAccess const access = {kTaggedBase, kPointerSize,
MaybeHandle<Name>(), MaybeHandle<Map>(),
Type::Signed32(), MachineType::AnyTagged(),
kNoWriteBarrier};
StrictMock<MockAdvancedReducerEditor> editor;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment