Store TypeCache as pointer instead of reference

Apart from being more in-line with the style guide, this allows to use
DEFINE_LAZY_LEAKY_OBJECT_GETTER for defining {TypeCache::Get}.

R=tebbi@chromium.org

Bug: v8:8562
Change-Id: I016b28624950ce9404180fc1ca1a232551f75cd0
Reviewed-on: https://chromium-review.googlesource.com/c/1392201
Reviewed-by: Tobias Tebbi <tebbi@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58500}
This commit is contained in:
Clemens Hammacher 2019-01-02 15:50:17 +01:00 committed by Commit Bot
parent 080416f091
commit 088bdc00e4
22 changed files with 249 additions and 250 deletions

View File

@ -32,9 +32,12 @@ FieldAccess AccessBuilder::ForExternalTaggedValue() {
// static
FieldAccess AccessBuilder::ForExternalUint8Value() {
FieldAccess access = {kUntaggedBase, 0,
MaybeHandle<Name>(), MaybeHandle<Map>(),
TypeCache::Get().kUint8, MachineType::Uint8(),
FieldAccess access = {kUntaggedBase,
0,
MaybeHandle<Name>(),
MaybeHandle<Map>(),
TypeCache::Get()->kUint8,
MachineType::Uint8(),
kNoWriteBarrier};
return access;
}
@ -53,7 +56,7 @@ FieldAccess AccessBuilder::ForMap() {
FieldAccess AccessBuilder::ForHeapNumberValue() {
FieldAccess access = {
kTaggedBase, HeapNumber::kValueOffset, MaybeHandle<Name>(),
MaybeHandle<Map>(), TypeCache::Get().kFloat64, MachineType::Float64(),
MaybeHandle<Map>(), TypeCache::Get()->kFloat64, MachineType::Float64(),
kNoWriteBarrier};
return access;
}
@ -62,7 +65,7 @@ FieldAccess AccessBuilder::ForHeapNumberValue() {
FieldAccess AccessBuilder::ForBigIntBitfield() {
FieldAccess access = {
kTaggedBase, BigInt::kBitfieldOffset, MaybeHandle<Name>(),
MaybeHandle<Map>(), TypeCache::Get().kInt32, MachineType::Uint32(),
MaybeHandle<Map>(), TypeCache::Get()->kInt32, MachineType::Uint32(),
kNoWriteBarrier};
return access;
}
@ -133,7 +136,7 @@ FieldAccess AccessBuilder::ForJSCollectionIteratorIndex() {
JSCollectionIterator::kIndexOffset,
MaybeHandle<Name>(),
MaybeHandle<Map>(),
TypeCache::Get().kFixedArrayLengthType,
TypeCache::Get()->kFixedArrayLengthType,
MachineType::TaggedSigned(),
kNoWriteBarrier};
return access;
@ -316,19 +319,19 @@ FieldAccess AccessBuilder::ForJSAsyncGeneratorObjectIsAwaiting() {
// static
FieldAccess AccessBuilder::ForJSArrayLength(ElementsKind elements_kind) {
TypeCache const& type_cache = TypeCache::Get();
TypeCache const* type_cache = TypeCache::Get();
FieldAccess access = {kTaggedBase,
JSArray::kLengthOffset,
Handle<Name>(),
MaybeHandle<Map>(),
type_cache.kJSArrayLengthType,
type_cache->kJSArrayLengthType,
MachineType::TaggedSigned(),
kFullWriteBarrier};
if (IsDoubleElementsKind(elements_kind)) {
access.type = type_cache.kFixedDoubleArrayLengthType;
access.type = type_cache->kFixedDoubleArrayLengthType;
access.write_barrier_kind = kNoWriteBarrier;
} else if (IsFastElementsKind(elements_kind)) {
access.type = type_cache.kFixedArrayLengthType;
access.type = type_cache->kFixedArrayLengthType;
access.write_barrier_kind = kNoWriteBarrier;
}
return access;
@ -349,7 +352,7 @@ FieldAccess AccessBuilder::ForJSArrayBufferBackingStore() {
FieldAccess AccessBuilder::ForJSArrayBufferBitField() {
FieldAccess access = {
kTaggedBase, JSArrayBuffer::kBitFieldOffset, MaybeHandle<Name>(),
MaybeHandle<Map>(), TypeCache::Get().kUint8, MachineType::Uint32(),
MaybeHandle<Map>(), TypeCache::Get()->kUint8, MachineType::Uint32(),
kNoWriteBarrier};
return access;
}
@ -369,7 +372,7 @@ FieldAccess AccessBuilder::ForJSArrayBufferViewByteLength() {
JSArrayBufferView::kByteLengthOffset,
MaybeHandle<Name>(),
MaybeHandle<Map>(),
TypeCache::Get().kJSArrayBufferViewByteLengthType,
TypeCache::Get()->kJSArrayBufferViewByteLengthType,
MachineType::UintPtr(),
kNoWriteBarrier};
return access;
@ -381,7 +384,7 @@ FieldAccess AccessBuilder::ForJSArrayBufferViewByteOffset() {
JSArrayBufferView::kByteOffsetOffset,
MaybeHandle<Name>(),
MaybeHandle<Map>(),
TypeCache::Get().kJSArrayBufferViewByteOffsetType,
TypeCache::Get()->kJSArrayBufferViewByteOffsetType,
MachineType::UintPtr(),
kNoWriteBarrier};
return access;
@ -393,7 +396,7 @@ FieldAccess AccessBuilder::ForJSTypedArrayLength() {
JSTypedArray::kLengthOffset,
MaybeHandle<Name>(),
MaybeHandle<Map>(),
TypeCache::Get().kJSTypedArrayLengthType,
TypeCache::Get()->kJSTypedArrayLengthType,
MachineType::TaggedSigned(),
kNoWriteBarrier};
return access;
@ -405,7 +408,7 @@ FieldAccess AccessBuilder::ForJSDateValue() {
JSDate::kValueOffset,
MaybeHandle<Name>(),
MaybeHandle<Map>(),
TypeCache::Get().kJSDateValueType,
TypeCache::Get()->kJSDateValueType,
MachineType::AnyTagged(),
kFullWriteBarrier};
return access;
@ -484,7 +487,7 @@ FieldAccess AccessBuilder::ForFixedArrayLength() {
FixedArray::kLengthOffset,
MaybeHandle<Name>(),
MaybeHandle<Map>(),
TypeCache::Get().kFixedArrayLengthType,
TypeCache::Get()->kFixedArrayLengthType,
MachineType::TaggedSigned(),
kNoWriteBarrier};
return access;
@ -537,7 +540,7 @@ FieldAccess AccessBuilder::ForDescriptorArrayEnumCache() {
FieldAccess AccessBuilder::ForMapBitField() {
FieldAccess access = {
kTaggedBase, Map::kBitFieldOffset, Handle<Name>(),
MaybeHandle<Map>(), TypeCache::Get().kUint8, MachineType::Uint8(),
MaybeHandle<Map>(), TypeCache::Get()->kUint8, MachineType::Uint8(),
kNoWriteBarrier};
return access;
}
@ -546,7 +549,7 @@ FieldAccess AccessBuilder::ForMapBitField() {
FieldAccess AccessBuilder::ForMapBitField2() {
FieldAccess access = {
kTaggedBase, Map::kBitField2Offset, Handle<Name>(),
MaybeHandle<Map>(), TypeCache::Get().kUint8, MachineType::Uint8(),
MaybeHandle<Map>(), TypeCache::Get()->kUint8, MachineType::Uint8(),
kNoWriteBarrier};
return access;
}
@ -555,7 +558,7 @@ FieldAccess AccessBuilder::ForMapBitField2() {
FieldAccess AccessBuilder::ForMapBitField3() {
FieldAccess access = {
kTaggedBase, Map::kBitField3Offset, Handle<Name>(),
MaybeHandle<Map>(), TypeCache::Get().kInt32, MachineType::Int32(),
MaybeHandle<Map>(), TypeCache::Get()->kInt32, MachineType::Int32(),
kNoWriteBarrier};
return access;
}
@ -575,7 +578,7 @@ FieldAccess AccessBuilder::ForMapDescriptors() {
FieldAccess AccessBuilder::ForMapInstanceType() {
FieldAccess access = {
kTaggedBase, Map::kInstanceTypeOffset, Handle<Name>(),
MaybeHandle<Map>(), TypeCache::Get().kUint16, MachineType::Uint16(),
MaybeHandle<Map>(), TypeCache::Get()->kUint16, MachineType::Uint16(),
kNoWriteBarrier};
return access;
}
@ -623,7 +626,7 @@ FieldAccess AccessBuilder::ForStringLength() {
String::kLengthOffset,
Handle<Name>(),
MaybeHandle<Map>(),
TypeCache::Get().kStringLengthType,
TypeCache::Get()->kStringLengthType,
MachineType::Uint32(),
kNoWriteBarrier};
return access;
@ -688,14 +691,14 @@ FieldAccess AccessBuilder::ForExternalStringResourceData() {
// static
ElementAccess AccessBuilder::ForExternalOneByteStringCharacter() {
ElementAccess access = {kUntaggedBase, 0, TypeCache::Get().kUint8,
ElementAccess access = {kUntaggedBase, 0, TypeCache::Get()->kUint8,
MachineType::Uint8(), kNoWriteBarrier};
return access;
}
// static
ElementAccess AccessBuilder::ForExternalTwoByteStringCharacter() {
ElementAccess access = {kUntaggedBase, 0, TypeCache::Get().kUint16,
ElementAccess access = {kUntaggedBase, 0, TypeCache::Get()->kUint16,
MachineType::Uint16(), kNoWriteBarrier};
return access;
}
@ -703,7 +706,7 @@ ElementAccess AccessBuilder::ForExternalTwoByteStringCharacter() {
// static
ElementAccess AccessBuilder::ForSeqOneByteStringCharacter() {
ElementAccess access = {kTaggedBase, SeqOneByteString::kHeaderSize,
TypeCache::Get().kUint8, MachineType::Uint8(),
TypeCache::Get()->kUint8, MachineType::Uint8(),
kNoWriteBarrier};
return access;
}
@ -711,7 +714,7 @@ ElementAccess AccessBuilder::ForSeqOneByteStringCharacter() {
// static
ElementAccess AccessBuilder::ForSeqTwoByteStringCharacter() {
ElementAccess access = {kTaggedBase, SeqTwoByteString::kHeaderSize,
TypeCache::Get().kUint16, MachineType::Uint16(),
TypeCache::Get()->kUint16, MachineType::Uint16(),
kNoWriteBarrier};
return access;
}
@ -763,7 +766,7 @@ FieldAccess AccessBuilder::ForJSArrayIteratorNextIndex() {
JSArrayIterator::kNextIndexOffset,
Handle<Name>(),
MaybeHandle<Map>(),
TypeCache::Get().kPositiveSafeInteger,
TypeCache::Get()->kPositiveSafeInteger,
MachineType::AnyTagged(),
kFullWriteBarrier};
return access;
@ -775,7 +778,7 @@ FieldAccess AccessBuilder::ForJSArrayIteratorKind() {
JSArrayIterator::kKindOffset,
Handle<Name>(),
MaybeHandle<Map>(),
TypeCache::Get().kJSArrayIteratorKindType,
TypeCache::Get()->kJSArrayIteratorKindType,
MachineType::TaggedSigned(),
kNoWriteBarrier};
return access;
@ -796,7 +799,7 @@ FieldAccess AccessBuilder::ForJSStringIteratorIndex() {
JSStringIterator::kNextIndexOffset,
Handle<Name>(),
MaybeHandle<Map>(),
TypeCache::Get().kStringLengthType,
TypeCache::Get()->kStringLengthType,
MachineType::TaggedSigned(),
kNoWriteBarrier};
return access;
@ -887,7 +890,7 @@ ElementAccess AccessBuilder::ForFixedArrayElement(
access.write_barrier_kind = kNoWriteBarrier;
break;
case HOLEY_SMI_ELEMENTS:
access.type = TypeCache::Get().kHoleySmi;
access.type = TypeCache::Get()->kHoleySmi;
break;
case PACKED_ELEMENTS:
access.type = Type::NonInternal();
@ -914,7 +917,7 @@ ElementAccess AccessBuilder::ForFixedArrayElement(
// static
ElementAccess AccessBuilder::ForFixedDoubleArrayElement() {
ElementAccess access = {kTaggedBase, FixedDoubleArray::kHeaderSize,
TypeCache::Get().kFloat64, MachineType::Float64(),
TypeCache::Get()->kFloat64, MachineType::Float64(),
kNoWriteBarrier};
return access;
}
@ -1061,7 +1064,7 @@ FieldAccess AccessBuilder::ForOrderedHashMapOrSetNumberOfBuckets() {
OrderedHashMap::NumberOfBucketsOffset(),
MaybeHandle<Name>(),
MaybeHandle<Map>(),
TypeCache::Get().kFixedArrayLengthType,
TypeCache::Get()->kFixedArrayLengthType,
MachineType::TaggedSigned(),
kNoWriteBarrier};
return access;
@ -1077,7 +1080,7 @@ FieldAccess AccessBuilder::ForOrderedHashMapOrSetNumberOfDeletedElements() {
OrderedHashMap::NumberOfDeletedElementsOffset(),
MaybeHandle<Name>(),
MaybeHandle<Map>(),
TypeCache::Get().kFixedArrayLengthType,
TypeCache::Get()->kFixedArrayLengthType,
MachineType::TaggedSigned(),
kNoWriteBarrier};
return access;
@ -1093,7 +1096,7 @@ FieldAccess AccessBuilder::ForOrderedHashMapOrSetNumberOfElements() {
OrderedHashMap::NumberOfElementsOffset(),
MaybeHandle<Name>(),
MaybeHandle<Map>(),
TypeCache::Get().kFixedArrayLengthType,
TypeCache::Get()->kFixedArrayLengthType,
MachineType::TaggedSigned(),
kNoWriteBarrier};
return access;

View File

@ -391,7 +391,7 @@ bool AccessInfoFactory::ComputePropertyAccessInfo(
field_type = Type::SignedSmall();
field_representation = MachineRepresentation::kTaggedSigned;
} else if (details_representation.IsDouble()) {
field_type = type_cache_.kFloat64;
field_type = type_cache_->kFloat64;
field_representation = MachineRepresentation::kFloat64;
} else if (details_representation.IsHeapObject()) {
// Extract the field type from the property details (make sure its
@ -652,13 +652,13 @@ bool AccessInfoFactory::LookupSpecialFieldAccessor(
// in case of other fast elements, and [0, kMaxUInt32] in
// case of other arrays.
if (IsDoubleElementsKind(map->elements_kind())) {
field_type = type_cache_.kFixedDoubleArrayLengthType;
field_type = type_cache_->kFixedDoubleArrayLengthType;
field_representation = MachineRepresentation::kTaggedSigned;
} else if (IsFastElementsKind(map->elements_kind())) {
field_type = type_cache_.kFixedArrayLengthType;
field_type = type_cache_->kFixedArrayLengthType;
field_representation = MachineRepresentation::kTaggedSigned;
} else {
field_type = type_cache_.kJSArrayLengthType;
field_type = type_cache_->kJSArrayLengthType;
}
}
// Special fields are always mutable.
@ -698,7 +698,7 @@ bool AccessInfoFactory::LookupTransition(Handle<Map> map, Handle<Name> name,
field_type = Type::SignedSmall();
field_representation = MachineRepresentation::kTaggedSigned;
} else if (details_representation.IsDouble()) {
field_type = type_cache_.kFloat64;
field_type = type_cache_->kFloat64;
field_representation = MachineRepresentation::kFloat64;
} else if (details_representation.IsHeapObject()) {
// Extract the field type from the property details (make sure its

View File

@ -181,7 +181,7 @@ class AccessInfoFactory final {
CompilationDependencies* const dependencies_;
Handle<Context> const native_context_;
Isolate* const isolate_;
TypeCache const& type_cache_;
TypeCache const* type_cache_;
Zone* const zone_;
DISALLOW_COPY_AND_ASSIGN(AccessInfoFactory);

View File

@ -335,7 +335,7 @@ void EscapeAnalysisReducer::Finalize() {
jsgraph()->simplified()->NumberSubtract(), arguments_length,
index);
NodeProperties::SetType(offset,
TypeCache::Get().kArgumentsLengthType);
TypeCache::Get()->kArgumentsLengthType);
NodeProperties::ReplaceValueInput(load, arguments_frame, 0);
NodeProperties::ReplaceValueInput(load, offset, 1);
NodeProperties::ChangeOp(load, load_stack_op);

View File

@ -2164,10 +2164,10 @@ Node* JSCallReducer::DoFilterPostCallbackWork(ElementsKind kind, Node** control,
simplified()->LoadField(AccessBuilder::ForJSObjectElements()), a, etrue,
if_true);
DCHECK(TypeCache::Get().kFixedDoubleArrayLengthType.Is(
TypeCache::Get().kFixedArrayLengthType));
DCHECK(TypeCache::Get()->kFixedDoubleArrayLengthType.Is(
TypeCache::Get()->kFixedArrayLengthType));
Node* checked_to = etrue = graph()->NewNode(
common()->TypeGuard(TypeCache::Get().kFixedArrayLengthType), to, etrue,
common()->TypeGuard(TypeCache::Get()->kFixedArrayLengthType), to, etrue,
if_true);
Node* elements_length = etrue = graph()->NewNode(
simplified()->LoadField(AccessBuilder::ForFixedArrayLength()), elements,
@ -5042,11 +5042,11 @@ Reduction JSCallReducer::ReduceArrayIteratorPrototypeNext(Node* node) {
// latter case we even know that it's a Smi in UnsignedSmall range.
FieldAccess index_access = AccessBuilder::ForJSArrayIteratorNextIndex();
if (IsFixedTypedArrayElementsKind(elements_kind)) {
index_access.type = TypeCache::Get().kJSTypedArrayLengthType;
index_access.type = TypeCache::Get()->kJSTypedArrayLengthType;
index_access.machine_type = MachineType::TaggedSigned();
index_access.write_barrier_kind = kNoWriteBarrier;
} else {
index_access.type = TypeCache::Get().kJSArrayLengthType;
index_access.type = TypeCache::Get()->kJSArrayLengthType;
}
Node* index = effect = graph()->NewNode(simplified()->LoadField(index_access),
iterator, effect, control);
@ -6512,7 +6512,7 @@ Reduction JSCallReducer::ReduceCollectionIteratorPrototypeNext(
jsgraph()->NoContextConstant(), effect);
index = effect = graph()->NewNode(
common()->TypeGuard(TypeCache::Get().kFixedArrayLengthType), index,
common()->TypeGuard(TypeCache::Get()->kFixedArrayLengthType), index,
effect, control);
// Update the {index} and {table} on the {receiver}.
@ -6576,7 +6576,7 @@ Reduction JSCallReducer::ReduceCollectionIteratorPrototypeNext(
common()->Phi(MachineRepresentation::kTagged, 2), index, index, loop);
Node* index = effect = graph()->NewNode(
common()->TypeGuard(TypeCache::Get().kFixedArrayLengthType), iloop,
common()->TypeGuard(TypeCache::Get()->kFixedArrayLengthType), iloop,
eloop, control);
{
Node* check0 = graph()->NewNode(simplified()->NumberLessThan(), index,

View File

@ -251,7 +251,7 @@ class V8_EXPORT_PRIVATE JSNativeContextSpecialization final
CompilationDependencies* const dependencies_;
Zone* const zone_;
Zone* const shared_zone_;
TypeCache const& type_cache_;
TypeCache const* type_cache_;
DISALLOW_COPY_AND_ASSIGN(JSNativeContextSpecialization);
};

View File

@ -608,7 +608,7 @@ Reduction JSTypedLowering::ReduceJSAdd(Node* node) {
}
control = graph()->NewNode(common()->IfTrue(), branch);
length = effect =
graph()->NewNode(common()->TypeGuard(type_cache_.kStringLengthType),
graph()->NewNode(common()->TypeGuard(type_cache_->kStringLengthType),
length, effect, control);
}
@ -923,7 +923,7 @@ Reduction JSTypedLowering::ReduceJSToName(Node* node) {
Reduction JSTypedLowering::ReduceJSToLength(Node* node) {
Node* input = NodeProperties::GetValueInput(node, 0);
Type input_type = NodeProperties::GetType(input);
if (input_type.Is(type_cache_.kIntegerOrMinusZero)) {
if (input_type.Is(type_cache_->kIntegerOrMinusZero)) {
if (input_type.IsNone() || input_type.Max() <= 0.0) {
input = jsgraph()->ZeroConstant();
} else if (input_type.Min() >= kMaxSafeInteger) {
@ -2227,9 +2227,9 @@ Reduction JSTypedLowering::ReduceJSParseInt(Node* node) {
Type radix_type = NodeProperties::GetType(radix);
// We need kTenOrUndefined and kZeroOrUndefined because
// the type representing {0,10} would become the range 1-10.
if (value_type.Is(type_cache_.kSafeInteger) &&
(radix_type.Is(type_cache_.kTenOrUndefined) ||
radix_type.Is(type_cache_.kZeroOrUndefined))) {
if (value_type.Is(type_cache_->kSafeInteger) &&
(radix_type.Is(type_cache_->kTenOrUndefined) ||
radix_type.Is(type_cache_->kZeroOrUndefined))) {
// Number.parseInt(a:safe-integer) -> a
// Number.parseInt(a:safe-integer,b:#0\/undefined) -> a
// Number.parseInt(a:safe-integer,b:#10\/undefined) -> a

View File

@ -101,7 +101,7 @@ class V8_EXPORT_PRIVATE JSTypedLowering final
JSHeapBroker* broker_;
Type empty_string_type_;
Type pointer_comparable_type_;
TypeCache const& type_cache_;
TypeCache const* type_cache_;
};
} // namespace compiler

View File

@ -39,7 +39,7 @@ OperationTyper::OperationTyper(JSHeapBroker* broker, Zone* zone)
falsish_ = Type::Union(
Type::Undetectable(),
Type::Union(Type::Union(singleton_false_, cache_.kZeroish, zone),
Type::Union(Type::Union(singleton_false_, cache_->kZeroish, zone),
Type::Union(singleton_empty_string_, Type::Hole(), zone),
zone),
zone);
@ -130,7 +130,7 @@ Type OperationTyper::WeakenRange(Type previous_range, Type current_range) {
Type OperationTyper::Rangify(Type type) {
if (type.IsRange()) return type; // Shortcut.
if (!type.Is(cache_.kInteger)) {
if (!type.Is(cache_->kInteger)) {
return type; // Give up on non-integer types.
}
return Type::Range(type.Min(), type.Max(), zone());
@ -234,7 +234,7 @@ Type OperationTyper::MultiplyRanger(double lhs_min, double lhs_max,
// have to do a different check:
for (int i = 0; i < 4; ++i) {
if (std::isnan(results[i])) {
return cache_.kIntegerOrMinusZeroOrNaN;
return cache_->kIntegerOrMinusZeroOrNaN;
}
}
double min = array_min(results, 4);
@ -284,7 +284,7 @@ Type OperationTyper::ToNumber(Type type) {
DCHECK(type.Is(Type::NumberOrOddball()));
if (type.Maybe(Type::Null())) {
// ToNumber(null) => +0
type = Type::Union(type, cache_.kSingletonZero, zone());
type = Type::Union(type, cache_->kSingletonZero, zone());
}
if (type.Maybe(Type::Undefined())) {
// ToNumber(undefined) => NaN
@ -292,11 +292,11 @@ Type OperationTyper::ToNumber(Type type) {
}
if (type.Maybe(singleton_false_)) {
// ToNumber(false) => +0
type = Type::Union(type, cache_.kSingletonZero, zone());
type = Type::Union(type, cache_->kSingletonZero, zone());
}
if (type.Maybe(singleton_true_)) {
// ToNumber(true) => +1
type = Type::Union(type, cache_.kSingletonOne, zone());
type = Type::Union(type, cache_->kSingletonOne, zone());
}
return Type::Intersect(type, Type::Number(), zone());
}
@ -309,7 +309,7 @@ Type OperationTyper::ToNumberConvertBigInt(Type type) {
type = ToNumber(Type::Intersect(type, Type::NonBigInt(), zone()));
// Any BigInt is rounded to an integer Number in the range [-inf, inf].
return maybe_bigint ? Type::Union(type, cache_.kInteger, zone()) : type;
return maybe_bigint ? Type::Union(type, cache_->kInteger, zone()) : type;
}
Type OperationTyper::ToNumeric(Type type) {
@ -334,7 +334,7 @@ Type OperationTyper::NumberAbs(Type type) {
double const max = type.Max();
double const min = type.Min();
if (min < 0) {
if (type.Is(cache_.kInteger)) {
if (type.Is(cache_->kInteger)) {
type =
Type::Range(0.0, std::max(std::fabs(min), std::fabs(max)), zone());
} else {
@ -344,7 +344,7 @@ Type OperationTyper::NumberAbs(Type type) {
}
if (maybe_minuszero) {
type = Type::Union(type, cache_.kSingletonZero, zone());
type = Type::Union(type, cache_->kSingletonZero, zone());
}
if (maybe_nan) {
type = Type::Union(type, Type::NaN(), zone());
@ -389,15 +389,15 @@ Type OperationTyper::NumberCbrt(Type type) {
Type OperationTyper::NumberCeil(Type type) {
DCHECK(type.Is(Type::Number()));
if (type.Is(cache_.kIntegerOrMinusZeroOrNaN)) return type;
if (type.Is(cache_->kIntegerOrMinusZeroOrNaN)) return type;
type = Type::Intersect(type, Type::NaN(), zone());
type = Type::Union(type, cache_.kIntegerOrMinusZero, zone());
type = Type::Union(type, cache_->kIntegerOrMinusZero, zone());
return type;
}
Type OperationTyper::NumberClz32(Type type) {
DCHECK(type.Is(Type::Number()));
return cache_.kZeroToThirtyTwo;
return cache_->kZeroToThirtyTwo;
}
Type OperationTyper::NumberCos(Type type) {
@ -422,9 +422,9 @@ Type OperationTyper::NumberExpm1(Type type) {
Type OperationTyper::NumberFloor(Type type) {
DCHECK(type.Is(Type::Number()));
if (type.Is(cache_.kIntegerOrMinusZeroOrNaN)) return type;
if (type.Is(cache_->kIntegerOrMinusZeroOrNaN)) return type;
type = Type::Intersect(type, Type::MinusZeroOrNaN(), zone());
type = Type::Union(type, cache_.kInteger, zone());
type = Type::Union(type, cache_->kInteger, zone());
return type;
}
@ -455,28 +455,28 @@ Type OperationTyper::NumberLog10(Type type) {
Type OperationTyper::NumberRound(Type type) {
DCHECK(type.Is(Type::Number()));
if (type.Is(cache_.kIntegerOrMinusZeroOrNaN)) return type;
if (type.Is(cache_->kIntegerOrMinusZeroOrNaN)) return type;
type = Type::Intersect(type, Type::NaN(), zone());
type = Type::Union(type, cache_.kIntegerOrMinusZero, zone());
type = Type::Union(type, cache_->kIntegerOrMinusZero, zone());
return type;
}
Type OperationTyper::NumberSign(Type type) {
DCHECK(type.Is(Type::Number()));
if (type.Is(cache_.kZeroish)) return type;
if (type.Is(cache_->kZeroish)) return type;
bool maybe_minuszero = type.Maybe(Type::MinusZero());
bool maybe_nan = type.Maybe(Type::NaN());
type = Type::Intersect(type, Type::PlainNumber(), zone());
if (type.IsNone()) {
// Do nothing.
} else if (type.Max() < 0.0) {
type = cache_.kSingletonMinusOne;
type = cache_->kSingletonMinusOne;
} else if (type.Max() <= 0.0) {
type = cache_.kMinusOneOrZero;
type = cache_->kMinusOneOrZero;
} else if (type.Min() > 0.0) {
type = cache_.kSingletonOne;
type = cache_->kSingletonOne;
} else if (type.Min() >= 0.0) {
type = cache_.kZeroOrOne;
type = cache_->kZeroOrOne;
} else {
type = Type::Range(-1.0, 1.0, zone());
}
@ -513,16 +513,16 @@ Type OperationTyper::NumberTanh(Type type) {
Type OperationTyper::NumberTrunc(Type type) {
DCHECK(type.Is(Type::Number()));
if (type.Is(cache_.kIntegerOrMinusZeroOrNaN)) return type;
if (type.Is(cache_->kIntegerOrMinusZeroOrNaN)) return type;
type = Type::Intersect(type, Type::NaN(), zone());
type = Type::Union(type, cache_.kIntegerOrMinusZero, zone());
type = Type::Union(type, cache_->kIntegerOrMinusZero, zone());
return type;
}
Type OperationTyper::NumberToBoolean(Type type) {
DCHECK(type.Is(Type::Number()));
if (type.IsNone()) return type;
if (type.Is(cache_.kZeroish)) return singleton_false_;
if (type.Is(cache_->kZeroish)) return singleton_false_;
if (type.Is(Type::PlainNumber()) && (type.Max() < 0 || 0 < type.Min())) {
return singleton_true_; // Ruled out nan, -0 and +0.
}
@ -533,9 +533,9 @@ Type OperationTyper::NumberToInt32(Type type) {
DCHECK(type.Is(Type::Number()));
if (type.Is(Type::Signed32())) return type;
if (type.Is(cache_.kZeroish)) return cache_.kSingletonZero;
if (type.Is(cache_->kZeroish)) return cache_->kSingletonZero;
if (type.Is(signed32ish_)) {
return Type::Intersect(Type::Union(type, cache_.kSingletonZero, zone()),
return Type::Intersect(Type::Union(type, cache_->kSingletonZero, zone()),
Type::Signed32(), zone());
}
return Type::Signed32();
@ -545,7 +545,7 @@ Type OperationTyper::NumberToString(Type type) {
DCHECK(type.Is(Type::Number()));
if (type.IsNone()) return type;
if (type.Is(Type::NaN())) return singleton_NaN_string_;
if (type.Is(cache_.kZeroOrMinusZero)) return singleton_zero_string_;
if (type.Is(cache_->kZeroOrMinusZero)) return singleton_zero_string_;
return Type::String();
}
@ -553,9 +553,9 @@ Type OperationTyper::NumberToUint32(Type type) {
DCHECK(type.Is(Type::Number()));
if (type.Is(Type::Unsigned32())) return type;
if (type.Is(cache_.kZeroish)) return cache_.kSingletonZero;
if (type.Is(cache_->kZeroish)) return cache_->kSingletonZero;
if (type.Is(unsigned32ish_)) {
return Type::Intersect(Type::Union(type, cache_.kSingletonZero, zone()),
return Type::Intersect(Type::Union(type, cache_->kSingletonZero, zone()),
Type::Unsigned32(), zone());
}
return Type::Unsigned32();
@ -564,8 +564,8 @@ Type OperationTyper::NumberToUint32(Type type) {
Type OperationTyper::NumberToUint8Clamped(Type type) {
DCHECK(type.Is(Type::Number()));
if (type.Is(cache_.kUint8)) return type;
return cache_.kUint8;
if (type.Is(cache_->kUint8)) return type;
return cache_->kUint8;
}
Type OperationTyper::NumberSilenceNaN(Type type) {
@ -590,12 +590,12 @@ Type OperationTyper::NumberAdd(Type lhs, Type rhs) {
// Addition can yield minus zero only if both inputs can be minus zero.
bool maybe_minuszero = true;
if (lhs.Maybe(Type::MinusZero())) {
lhs = Type::Union(lhs, cache_.kSingletonZero, zone());
lhs = Type::Union(lhs, cache_->kSingletonZero, zone());
} else {
maybe_minuszero = false;
}
if (rhs.Maybe(Type::MinusZero())) {
rhs = Type::Union(rhs, cache_.kSingletonZero, zone());
rhs = Type::Union(rhs, cache_->kSingletonZero, zone());
} else {
maybe_minuszero = false;
}
@ -605,7 +605,7 @@ Type OperationTyper::NumberAdd(Type lhs, Type rhs) {
lhs = Type::Intersect(lhs, Type::PlainNumber(), zone());
rhs = Type::Intersect(rhs, Type::PlainNumber(), zone());
if (!lhs.IsNone() && !rhs.IsNone()) {
if (lhs.Is(cache_.kInteger) && rhs.Is(cache_.kInteger)) {
if (lhs.Is(cache_->kInteger) && rhs.Is(cache_->kInteger)) {
type = AddRanger(lhs.Min(), lhs.Max(), rhs.Min(), rhs.Max());
} else {
if ((lhs.Maybe(minus_infinity_) && rhs.Maybe(infinity_)) ||
@ -636,11 +636,11 @@ Type OperationTyper::NumberSubtract(Type lhs, Type rhs) {
// can be zero.
bool maybe_minuszero = false;
if (lhs.Maybe(Type::MinusZero())) {
lhs = Type::Union(lhs, cache_.kSingletonZero, zone());
maybe_minuszero = rhs.Maybe(cache_.kSingletonZero);
lhs = Type::Union(lhs, cache_->kSingletonZero, zone());
maybe_minuszero = rhs.Maybe(cache_->kSingletonZero);
}
if (rhs.Maybe(Type::MinusZero())) {
rhs = Type::Union(rhs, cache_.kSingletonZero, zone());
rhs = Type::Union(rhs, cache_->kSingletonZero, zone());
}
// We can give more precise types for integers.
@ -648,7 +648,7 @@ Type OperationTyper::NumberSubtract(Type lhs, Type rhs) {
lhs = Type::Intersect(lhs, Type::PlainNumber(), zone());
rhs = Type::Intersect(rhs, Type::PlainNumber(), zone());
if (!lhs.IsNone() && !rhs.IsNone()) {
if (lhs.Is(cache_.kInteger) && rhs.Is(cache_.kInteger)) {
if (lhs.Is(cache_->kInteger) && rhs.Is(cache_->kInteger)) {
type = SubtractRanger(lhs.Min(), lhs.Max(), rhs.Min(), rhs.Max());
} else {
if ((lhs.Maybe(infinity_) && rhs.Maybe(infinity_)) ||
@ -672,7 +672,7 @@ Type OperationTyper::SpeculativeSafeIntegerAdd(Type lhs, Type rhs) {
// In either case the result will be in the safe integer range, so we
// can bake in the type here. This needs to be in sync with
// SimplifiedLowering::VisitSpeculativeAdditiveOp.
return Type::Intersect(result, cache_.kSafeIntegerOrMinusZero, zone());
return Type::Intersect(result, cache_->kSafeIntegerOrMinusZero, zone());
}
Type OperationTyper::SpeculativeSafeIntegerSubtract(Type lhs, Type rhs) {
@ -682,7 +682,7 @@ Type OperationTyper::SpeculativeSafeIntegerSubtract(Type lhs, Type rhs) {
// In either case the result will be in the safe integer range, so we
// can bake in the type here. This needs to be in sync with
// SimplifiedLowering::VisitSpeculativeAdditiveOp.
return Type::Intersect(result, cache_.kSafeIntegerOrMinusZero, zone());
return Type::Intersect(result, cache_->kSafeIntegerOrMinusZero, zone());
}
Type OperationTyper::NumberMultiply(Type lhs, Type rhs) {
@ -696,9 +696,9 @@ Type OperationTyper::NumberMultiply(Type lhs, Type rhs) {
// NaN * x = NaN (regardless of sign of x)
// 0 * Infinity = NaN (regardless of signs)
bool maybe_nan = lhs.Maybe(Type::NaN()) || rhs.Maybe(Type::NaN()) ||
(lhs.Maybe(cache_.kZeroish) &&
(lhs.Maybe(cache_->kZeroish) &&
(rhs.Min() == -V8_INFINITY || rhs.Max() == V8_INFINITY)) ||
(rhs.Maybe(cache_.kZeroish) &&
(rhs.Maybe(cache_->kZeroish) &&
(lhs.Min() == -V8_INFINITY || lhs.Max() == V8_INFINITY));
lhs = Type::Intersect(lhs, Type::OrderedNumber(), zone());
DCHECK(!lhs.IsNone());
@ -708,19 +708,19 @@ Type OperationTyper::NumberMultiply(Type lhs, Type rhs) {
// Try to rule out -0.
bool maybe_minuszero = lhs.Maybe(Type::MinusZero()) ||
rhs.Maybe(Type::MinusZero()) ||
(lhs.Maybe(cache_.kZeroish) && rhs.Min() < 0.0) ||
(rhs.Maybe(cache_.kZeroish) && lhs.Min() < 0.0);
(lhs.Maybe(cache_->kZeroish) && rhs.Min() < 0.0) ||
(rhs.Maybe(cache_->kZeroish) && lhs.Min() < 0.0);
if (lhs.Maybe(Type::MinusZero())) {
lhs = Type::Union(lhs, cache_.kSingletonZero, zone());
lhs = Type::Union(lhs, cache_->kSingletonZero, zone());
lhs = Type::Intersect(lhs, Type::PlainNumber(), zone());
}
if (rhs.Maybe(Type::MinusZero())) {
rhs = Type::Union(rhs, cache_.kSingletonZero, zone());
rhs = Type::Union(rhs, cache_->kSingletonZero, zone());
rhs = Type::Intersect(rhs, Type::PlainNumber(), zone());
}
// Compute the effective type, utilizing range information if possible.
Type type = (lhs.Is(cache_.kInteger) && rhs.Is(cache_.kInteger))
Type type = (lhs.Is(cache_->kInteger) && rhs.Is(cache_->kInteger))
? MultiplyRanger(lhs.Min(), lhs.Max(), rhs.Min(), rhs.Max())
: Type::OrderedNumber();
@ -738,7 +738,7 @@ Type OperationTyper::NumberDivide(Type lhs, Type rhs) {
if (lhs.Is(Type::NaN()) || rhs.Is(Type::NaN())) return Type::NaN();
// Division is tricky, so all we do is try ruling out -0 and NaN.
bool maybe_nan = lhs.Maybe(Type::NaN()) || rhs.Maybe(cache_.kZeroish) ||
bool maybe_nan = lhs.Maybe(Type::NaN()) || rhs.Maybe(cache_->kZeroish) ||
((lhs.Min() == -V8_INFINITY || lhs.Max() == +V8_INFINITY) &&
(rhs.Min() == -V8_INFINITY || rhs.Max() == +V8_INFINITY));
lhs = Type::Intersect(lhs, Type::OrderedNumber(), zone());
@ -748,8 +748,8 @@ Type OperationTyper::NumberDivide(Type lhs, Type rhs) {
// Try to rule out -0.
bool maybe_minuszero =
!lhs.Is(cache_.kInteger) ||
(lhs.Maybe(cache_.kZeroish) && rhs.Min() < 0.0) ||
!lhs.Is(cache_->kInteger) ||
(lhs.Maybe(cache_->kZeroish) && rhs.Min() < 0.0) ||
(rhs.Min() == -V8_INFINITY || rhs.Max() == +V8_INFINITY);
// Take into account the -0 and NaN information computed earlier.
@ -767,17 +767,17 @@ Type OperationTyper::NumberModulus(Type lhs, Type rhs) {
// Modulus can yield NaN if either {lhs} or {rhs} are NaN, or
// {lhs} is not finite, or the {rhs} is a zero value.
bool maybe_nan = lhs.Maybe(Type::NaN()) || rhs.Maybe(cache_.kZeroish) ||
bool maybe_nan = lhs.Maybe(Type::NaN()) || rhs.Maybe(cache_->kZeroish) ||
lhs.Min() == -V8_INFINITY || lhs.Max() == +V8_INFINITY;
// Deal with -0 inputs, only the signbit of {lhs} matters for the result.
bool maybe_minuszero = false;
if (lhs.Maybe(Type::MinusZero())) {
maybe_minuszero = true;
lhs = Type::Union(lhs, cache_.kSingletonZero, zone());
lhs = Type::Union(lhs, cache_->kSingletonZero, zone());
}
if (rhs.Maybe(Type::MinusZero())) {
rhs = Type::Union(rhs, cache_.kSingletonZero, zone());
rhs = Type::Union(rhs, cache_->kSingletonZero, zone());
}
// Rule out NaN and -0, and check what we can do with the remaining type info.
@ -787,7 +787,7 @@ Type OperationTyper::NumberModulus(Type lhs, Type rhs) {
// We can only derive a meaningful type if both {lhs} and {rhs} are inhabited,
// and the {rhs} is not 0, otherwise the result is NaN independent of {lhs}.
if (!lhs.IsNone() && !rhs.Is(cache_.kSingletonZero)) {
if (!lhs.IsNone() && !rhs.Is(cache_->kSingletonZero)) {
// Determine the bounds of {lhs} and {rhs}.
double const lmin = lhs.Min();
double const lmax = lhs.Max();
@ -798,7 +798,7 @@ Type OperationTyper::NumberModulus(Type lhs, Type rhs) {
if (lmin < 0.0) maybe_minuszero = true;
// For integer inputs {lhs} and {rhs} we can infer a precise type.
if (lhs.Is(cache_.kInteger) && rhs.Is(cache_.kInteger)) {
if (lhs.Is(cache_->kInteger) && rhs.Is(cache_->kInteger)) {
double labs = std::max(std::abs(lmin), std::abs(lmax));
double rabs = std::max(std::abs(rmin), std::abs(rmax)) - 1;
double abs = std::min(labs, rabs);
@ -1038,8 +1038,8 @@ Type OperationTyper::NumberMax(Type lhs, Type rhs) {
DCHECK(!lhs.IsNone());
rhs = Type::Intersect(rhs, Type::OrderedNumber(), zone());
DCHECK(!rhs.IsNone());
if (lhs.Is(cache_.kIntegerOrMinusZero) &&
rhs.Is(cache_.kIntegerOrMinusZero)) {
if (lhs.Is(cache_->kIntegerOrMinusZero) &&
rhs.Is(cache_->kIntegerOrMinusZero)) {
// TODO(turbofan): This could still be improved in ruling out -0 when
// one of the inputs' min is 0.
double max = std::max(lhs.Max(), rhs.Max());
@ -1070,8 +1070,8 @@ Type OperationTyper::NumberMin(Type lhs, Type rhs) {
DCHECK(!lhs.IsNone());
rhs = Type::Intersect(rhs, Type::OrderedNumber(), zone());
DCHECK(!rhs.IsNone());
if (lhs.Is(cache_.kIntegerOrMinusZero) &&
rhs.Is(cache_.kIntegerOrMinusZero)) {
if (lhs.Is(cache_->kIntegerOrMinusZero) &&
rhs.Is(cache_->kIntegerOrMinusZero)) {
double max = std::min(lhs.Max(), rhs.Max());
double min = std::min(lhs.Min(), rhs.Min());
type = Type::Union(type, Type::Range(min, max, zone()), zone());
@ -1206,11 +1206,11 @@ Type OperationTyper::StrictEqual(Type lhs, Type rhs) {
}
Type OperationTyper::CheckBounds(Type index, Type length) {
DCHECK(length.Is(cache_.kPositiveSafeInteger));
if (length.Is(cache_.kSingletonZero)) return Type::None();
DCHECK(length.Is(cache_->kPositiveSafeInteger));
if (length.Is(cache_->kSingletonZero)) return Type::None();
Type mask = Type::Range(0.0, length.Max() - 1, zone());
if (index.Maybe(Type::MinusZero())) {
index = Type::Union(index, cache_.kSingletonZero, zone());
index = Type::Union(index, cache_->kSingletonZero, zone());
}
return Type::Intersect(index, mask, zone());
}

View File

@ -93,7 +93,7 @@ class V8_EXPORT_PRIVATE OperationTyper {
Zone* zone() const { return zone_; }
Zone* const zone_;
TypeCache const& cache_;
TypeCache const* cache_;
Type infinity_;
Type minus_infinity_;

View File

@ -252,9 +252,9 @@ Node* RepresentationChanger::GetTaggedSignedRepresentationFor(
node = InsertTruncateInt64ToInt32(node);
op = simplified()->ChangeInt32ToTagged();
} else if (use_info.type_check() == TypeCheckKind::kSignedSmall) {
if (output_type.Is(cache_.kPositiveSafeInteger)) {
if (output_type.Is(cache_->kPositiveSafeInteger)) {
op = simplified()->CheckedUint64ToTaggedSigned(use_info.feedback());
} else if (output_type.Is(cache_.kSafeInteger)) {
} else if (output_type.Is(cache_->kSafeInteger)) {
op = simplified()->CheckedInt64ToTaggedSigned(use_info.feedback());
} else {
return TypeError(node, output_rep, output_type,
@ -388,7 +388,7 @@ Node* RepresentationChanger::GetTaggedPointerRepresentationFor(
}
op = simplified()->ChangeFloat64ToTaggedPointer();
} else if (output_rep == MachineRepresentation::kWord64) {
if (output_type.Is(cache_.kSafeInteger)) {
if (output_type.Is(cache_->kSafeInteger)) {
// int64 -> float64 -> tagged pointer
op = machine()->ChangeInt64ToFloat64();
node = jsgraph()->graph()->NewNode(op, node);
@ -491,10 +491,10 @@ Node* RepresentationChanger::GetTaggedRepresentationFor(
// int64 -> uint32 -> tagged
node = InsertTruncateInt64ToInt32(node);
op = simplified()->ChangeUint32ToTagged();
} else if (output_type.Is(cache_.kPositiveSafeInteger)) {
} else if (output_type.Is(cache_->kPositiveSafeInteger)) {
// uint64 -> tagged
op = simplified()->ChangeUint64ToTagged();
} else if (output_type.Is(cache_.kSafeInteger)) {
} else if (output_type.Is(cache_->kSafeInteger)) {
// int64 -> tagged
op = simplified()->ChangeInt64ToTagged();
} else {
@ -588,7 +588,7 @@ Node* RepresentationChanger::GetFloat32RepresentationFor(
} else if (output_rep == MachineRepresentation::kFloat64) {
op = machine()->TruncateFloat64ToFloat32();
} else if (output_rep == MachineRepresentation::kWord64) {
if (output_type.Is(cache_.kSafeInteger)) {
if (output_type.Is(cache_->kSafeInteger)) {
// int64 -> float64 -> float32
op = machine()->ChangeInt64ToFloat64();
node = jsgraph()->graph()->NewNode(op, node);
@ -665,7 +665,7 @@ Node* RepresentationChanger::GetFloat64RepresentationFor(
} else if (output_rep == MachineRepresentation::kFloat32) {
op = machine()->ChangeFloat32ToFloat64();
} else if (output_rep == MachineRepresentation::kWord64) {
if (output_type.Is(cache_.kSafeInteger)) {
if (output_type.Is(cache_->kSafeInteger)) {
op = machine()->ChangeInt64ToFloat64();
}
}
@ -841,14 +841,14 @@ Node* RepresentationChanger::GetWord32RepresentationFor(
if (output_type.Is(Type::Signed32()) ||
output_type.Is(Type::Unsigned32())) {
op = machine()->TruncateInt64ToInt32();
} else if (output_type.Is(cache_.kSafeInteger) &&
} else if (output_type.Is(cache_->kSafeInteger) &&
use_info.truncation().IsUsedAsWord32()) {
op = machine()->TruncateInt64ToInt32();
} else if (use_info.type_check() == TypeCheckKind::kSignedSmall ||
use_info.type_check() == TypeCheckKind::kSigned32) {
if (output_type.Is(cache_.kPositiveSafeInteger)) {
if (output_type.Is(cache_->kPositiveSafeInteger)) {
op = simplified()->CheckedUint64ToInt32(use_info.feedback());
} else if (output_type.Is(cache_.kSafeInteger)) {
} else if (output_type.Is(cache_->kSafeInteger)) {
op = simplified()->CheckedInt64ToInt32(use_info.feedback());
} else {
return TypeError(node, output_rep, output_type,
@ -989,11 +989,11 @@ Node* RepresentationChanger::GetWord64RepresentationFor(
MachineRepresentation::kWord64);
}
} else if (output_rep == MachineRepresentation::kFloat32) {
if (output_type.Is(cache_.kInt64)) {
if (output_type.Is(cache_->kInt64)) {
// float32 -> float64 -> int64
node = InsertChangeFloat32ToFloat64(node);
op = machine()->ChangeFloat64ToInt64();
} else if (output_type.Is(cache_.kUint64)) {
} else if (output_type.Is(cache_->kUint64)) {
// float32 -> float64 -> uint64
node = InsertChangeFloat32ToFloat64(node);
op = machine()->ChangeFloat64ToUint64();
@ -1010,9 +1010,9 @@ Node* RepresentationChanger::GetWord64RepresentationFor(
MachineRepresentation::kWord64);
}
} else if (output_rep == MachineRepresentation::kFloat64) {
if (output_type.Is(cache_.kInt64)) {
if (output_type.Is(cache_->kInt64)) {
op = machine()->ChangeFloat64ToInt64();
} else if (output_type.Is(cache_.kUint64)) {
} else if (output_type.Is(cache_->kUint64)) {
op = machine()->ChangeFloat64ToUint64();
} else if (use_info.type_check() == TypeCheckKind::kSigned64) {
op = simplified()->CheckedFloat64ToInt64(
@ -1032,7 +1032,7 @@ Node* RepresentationChanger::GetWord64RepresentationFor(
MachineRepresentation::kWord64);
}
} else if (CanBeTaggedPointer(output_rep)) {
if (output_type.Is(cache_.kInt64)) {
if (output_type.Is(cache_->kInt64)) {
op = simplified()->ChangeTaggedToInt64();
} else if (use_info.type_check() == TypeCheckKind::kSigned64) {
op = simplified()->CheckedTaggedToInt64(

View File

@ -302,7 +302,7 @@ class RepresentationChanger final {
}
private:
TypeCache const& cache_;
TypeCache const* cache_;
JSGraph* jsgraph_;
Isolate* isolate_;

View File

@ -552,7 +552,7 @@ class RepresentationSelector {
Type Weaken(Node* node, Type previous_type, Type current_type) {
// If the types have nothing to do with integers, return the types.
Type const integer = type_cache_.kInteger;
Type const integer = type_cache_->kInteger;
if (!previous_type.Maybe(integer)) {
return current_type;
}
@ -1073,7 +1073,7 @@ class RepresentationSelector {
}
void MaskShiftOperand(Node* node, Type rhs_type) {
if (!rhs_type.Is(type_cache_.kZeroToThirtyOne)) {
if (!rhs_type.Is(type_cache_->kZeroToThirtyOne)) {
Node* const rhs = NodeProperties::GetValueInput(node, 1);
node->ReplaceInput(1,
graph()->NewNode(jsgraph_->machine()->Word32And(), rhs,
@ -1102,7 +1102,7 @@ class RepresentationSelector {
}
// Word64 representation is only valid for safe integer values.
if (rep == MachineRepresentation::kWord64) {
DCHECK(type.Is(TypeCache::Get().kSafeInteger));
DCHECK(type.Is(TypeCache::Get()->kSafeInteger));
return MachineType(rep, MachineSemantic::kInt64);
}
MachineType machine_type(rep, DeoptValueSemanticOf(type));
@ -1316,8 +1316,8 @@ class RepresentationSelector {
Type left_upper = GetUpperBound(node->InputAt(0));
Type right_upper = GetUpperBound(node->InputAt(1));
if (left_upper.Is(type_cache_.kAdditiveSafeIntegerOrMinusZero) &&
right_upper.Is(type_cache_.kAdditiveSafeIntegerOrMinusZero)) {
if (left_upper.Is(type_cache_->kAdditiveSafeIntegerOrMinusZero) &&
right_upper.Is(type_cache_->kAdditiveSafeIntegerOrMinusZero)) {
// Only eliminate the node if its typing rule can be satisfied, namely
// that a safe integer is produced.
if (truncation.IsUnused()) return VisitUnused(node);
@ -1392,7 +1392,7 @@ class RepresentationSelector {
void VisitSpeculativeAdditiveOp(Node* node, Truncation truncation,
SimplifiedLowering* lowering) {
if (BothInputsAre(node, type_cache_.kAdditiveSafeIntegerOrMinusZero) &&
if (BothInputsAre(node, type_cache_->kAdditiveSafeIntegerOrMinusZero) &&
(GetUpperBound(node).Is(Type::Signed32()) ||
GetUpperBound(node).Is(Type::Unsigned32()) ||
truncation.IsUsedAsWord32())) {
@ -1580,7 +1580,7 @@ class RepresentationSelector {
}
}
} else {
DCHECK(length_type.Is(type_cache_.kPositiveSafeInteger));
DCHECK(length_type.Is(type_cache_->kPositiveSafeInteger));
VisitBinop(node,
UseInfo::CheckedSigned64AsWord64(kIdentifyZeros, p.feedback()),
UseInfo::Word64(), MachineRepresentation::kWord64);
@ -1742,7 +1742,7 @@ class RepresentationSelector {
rhs_type.Is(Type::Unsigned32OrMinusZero())) ||
(lhs_type.Is(Type::Unsigned32OrMinusZeroOrNaN()) &&
rhs_type.Is(Type::Unsigned32OrMinusZeroOrNaN()) &&
OneInputCannotBe(node, type_cache_.kZeroish))) {
OneInputCannotBe(node, type_cache_->kZeroish))) {
// => unsigned Int32Cmp
VisitBinop(node, UseInfo::TruncatingWord32(),
MachineRepresentation::kBit);
@ -1753,7 +1753,7 @@ class RepresentationSelector {
rhs_type.Is(Type::Signed32OrMinusZero())) ||
(lhs_type.Is(Type::Signed32OrMinusZeroOrNaN()) &&
rhs_type.Is(Type::Signed32OrMinusZeroOrNaN()) &&
OneInputCannotBe(node, type_cache_.kZeroish))) {
OneInputCannotBe(node, type_cache_->kZeroish))) {
// => signed Int32Cmp
VisitBinop(node, UseInfo::TruncatingWord32(),
MachineRepresentation::kBit);
@ -1883,9 +1883,9 @@ class RepresentationSelector {
case IrOpcode::kNumberAdd:
case IrOpcode::kNumberSubtract: {
if (TypeOf(node->InputAt(0))
.Is(type_cache_.kAdditiveSafeIntegerOrMinusZero) &&
.Is(type_cache_->kAdditiveSafeIntegerOrMinusZero) &&
TypeOf(node->InputAt(1))
.Is(type_cache_.kAdditiveSafeIntegerOrMinusZero) &&
.Is(type_cache_->kAdditiveSafeIntegerOrMinusZero) &&
(TypeOf(node).Is(Type::Signed32()) ||
TypeOf(node).Is(Type::Unsigned32()) ||
truncation.IsUsedAsWord32())) {
@ -1893,8 +1893,8 @@ class RepresentationSelector {
VisitWord32TruncatingBinop(node);
if (lower()) ChangeToPureOp(node, Int32Op(node));
} else if (jsgraph_->machine()->Is64() &&
BothInputsAre(node, type_cache_.kSafeInteger) &&
GetUpperBound(node).Is(type_cache_.kSafeInteger)) {
BothInputsAre(node, type_cache_->kSafeInteger) &&
GetUpperBound(node).Is(type_cache_->kSafeInteger)) {
// => Int64Add/Sub
VisitInt64Binop(node);
if (lower()) ChangeToPureOp(node, Int64Op(node));
@ -1911,7 +1911,7 @@ class RepresentationSelector {
NodeProperties::GetType(node).Is(Type::Unsigned32()) ||
(truncation.IsUsedAsWord32() &&
NodeProperties::GetType(node).Is(
type_cache_.kSafeIntegerOrMinusZero)))) {
type_cache_->kSafeIntegerOrMinusZero)))) {
// Multiply reduces to Int32Mul if the inputs are integers, and
// (a) the output is either known to be Signed32, or
// (b) the output is known to be Unsigned32, or
@ -1966,7 +1966,7 @@ class RepresentationSelector {
(TypeOf(node).Is(Type::Signed32()) ||
TypeOf(node).Is(Type::Unsigned32()) ||
(truncation.IsUsedAsWord32() &&
TypeOf(node).Is(type_cache_.kSafeIntegerOrMinusZero)))) {
TypeOf(node).Is(type_cache_->kSafeIntegerOrMinusZero)))) {
// Multiply reduces to Int32Mul if the inputs are integers, and
// (a) the output is either known to be Signed32, or
// (b) the output is known to be Unsigned32, or
@ -2208,7 +2208,7 @@ class RepresentationSelector {
case IrOpcode::kSpeculativeNumberShiftRightLogical: {
NumberOperationHint hint = NumberOperationHintOf(node->op());
Type rhs_type = GetUpperBound(node->InputAt(1));
if (rhs_type.Is(type_cache_.kZeroish) &&
if (rhs_type.Is(type_cache_->kZeroish) &&
(hint == NumberOperationHint::kSignedSmall ||
hint == NumberOperationHint::kSigned32) &&
!truncation.IsUsedAsWord32()) {
@ -2256,7 +2256,7 @@ class RepresentationSelector {
VisitUnop(node, UseInfo::TruncatingWord32(),
MachineRepresentation::kWord32);
if (lower()) DeferReplacement(node, lowering->Int32Abs(node));
} else if (input_type.Is(type_cache_.kPositiveIntegerOrNaN)) {
} else if (input_type.Is(type_cache_->kPositiveIntegerOrNaN)) {
VisitUnop(node, UseInfo::TruncatingFloat64(kIdentifyZeros),
MachineRepresentation::kFloat64);
if (lower()) DeferReplacement(node, node->InputAt(0));
@ -2315,8 +2315,8 @@ class RepresentationSelector {
MachineRepresentation::kWord32);
}
} else if (jsgraph_->machine()->Is64() &&
lhs_type.Is(type_cache_.kSafeInteger) &&
rhs_type.Is(type_cache_.kSafeInteger)) {
lhs_type.Is(type_cache_->kSafeInteger) &&
rhs_type.Is(type_cache_->kSafeInteger)) {
VisitInt64Binop(node);
if (lower()) {
lowering->DoMax(node, lowering->machine()->Int64LessThan(),
@ -2373,8 +2373,8 @@ class RepresentationSelector {
MachineRepresentation::kWord32);
}
} else if (jsgraph_->machine()->Is64() &&
lhs_type.Is(type_cache_.kSafeInteger) &&
rhs_type.Is(type_cache_.kSafeInteger)) {
lhs_type.Is(type_cache_->kSafeInteger) &&
rhs_type.Is(type_cache_->kSafeInteger)) {
VisitInt64Binop(node);
if (lower()) {
lowering->DoMin(node, lowering->machine()->Int64LessThan(),
@ -2421,7 +2421,7 @@ class RepresentationSelector {
VisitUnop(node, UseInfo::TruncatingFloat64(truncation.identify_zeros()),
MachineRepresentation::kFloat64);
if (lower()) {
if (input_type.Is(type_cache_.kIntegerOrMinusZeroOrNaN)) {
if (input_type.Is(type_cache_->kIntegerOrMinusZeroOrNaN)) {
DeferReplacement(node, node->InputAt(0));
} else if (node->opcode() == IrOpcode::kNumberRound) {
DeferReplacement(node, lowering->Float64Round(node));
@ -2530,7 +2530,7 @@ class RepresentationSelector {
}
case IrOpcode::kNumberToUint8Clamped: {
Type const input_type = TypeOf(node->InputAt(0));
if (input_type.Is(type_cache_.kUint8OrMinusZeroOrNaN)) {
if (input_type.Is(type_cache_->kUint8OrMinusZeroOrNaN)) {
VisitUnop(node, UseInfo::TruncatingWord32(),
MachineRepresentation::kWord32);
if (lower()) DeferReplacement(node, node->InputAt(0));
@ -2542,7 +2542,7 @@ class RepresentationSelector {
VisitUnop(node, UseInfo::TruncatingWord32(),
MachineRepresentation::kWord32);
if (lower()) lowering->DoSigned32ToUint8Clamped(node);
} else if (input_type.Is(type_cache_.kIntegerOrMinusZeroOrNaN)) {
} else if (input_type.Is(type_cache_->kIntegerOrMinusZeroOrNaN)) {
VisitUnop(node, UseInfo::TruncatingFloat64(),
MachineRepresentation::kFloat64);
if (lower()) lowering->DoIntegerToUint8Clamped(node);
@ -2993,7 +2993,7 @@ class RepresentationSelector {
}
case IrOpcode::kObjectIsFiniteNumber: {
Type const input_type = GetUpperBound(node->InputAt(0));
if (input_type.Is(type_cache_.kSafeInteger)) {
if (input_type.Is(type_cache_->kSafeInteger)) {
VisitUnop(node, UseInfo::None(), MachineRepresentation::kBit);
if (lower()) {
DeferReplacement(node, lowering->jsgraph()->Int32Constant(1));
@ -3022,7 +3022,7 @@ class RepresentationSelector {
}
case IrOpcode::kObjectIsSafeInteger: {
Type const input_type = GetUpperBound(node->InputAt(0));
if (input_type.Is(type_cache_.kSafeInteger)) {
if (input_type.Is(type_cache_->kSafeInteger)) {
VisitUnop(node, UseInfo::None(), MachineRepresentation::kBit);
if (lower()) {
DeferReplacement(node, lowering->jsgraph()->Int32Constant(1));
@ -3049,7 +3049,7 @@ class RepresentationSelector {
}
case IrOpcode::kObjectIsInteger: {
Type const input_type = GetUpperBound(node->InputAt(0));
if (input_type.Is(type_cache_.kSafeInteger)) {
if (input_type.Is(type_cache_->kSafeInteger)) {
VisitUnop(node, UseInfo::None(), MachineRepresentation::kBit);
if (lower()) {
DeferReplacement(node, lowering->jsgraph()->Int32Constant(1));
@ -3471,7 +3471,7 @@ class RepresentationSelector {
// position information via the SourcePositionWrapper like all other reducers.
SourcePositionTable* source_positions_;
NodeOriginTable* node_origins_;
TypeCache const& type_cache_;
TypeCache const* type_cache_;
OperationTyper op_typer_; // helper for the feedback typer
NodeInfo* GetInfo(Node* node) {

View File

@ -49,7 +49,7 @@ class V8_EXPORT_PRIVATE SimplifiedLowering final {
JSGraph* const jsgraph_;
JSHeapBroker* broker_;
Zone* const zone_;
TypeCache const& type_cache_;
TypeCache const* type_cache_;
SetOncePointer<Node> to_number_code_;
SetOncePointer<Node> to_number_convert_big_int_code_;
SetOncePointer<Node> to_numeric_code_;

View File

@ -10,11 +10,7 @@ namespace v8 {
namespace internal {
namespace compiler {
// static
TypeCache const& TypeCache::Get() {
static base::LeakyObject<TypeCache> type_cache;
return *type_cache.get();
}
DEFINE_LAZY_LEAKY_OBJECT_GETTER(const TypeCache, TypeCache::Get);
} // namespace compiler
} // namespace internal

View File

@ -22,7 +22,7 @@ class TypeCache final {
Zone zone_;
public:
static TypeCache const& Get();
static TypeCache const* Get();
TypeCache() : zone_(&allocator, ZONE_NAME) {}

View File

@ -244,7 +244,7 @@ Reduction TypedOptimization::ReduceLoadField(Node* node) {
Reduction TypedOptimization::ReduceNumberFloor(Node* node) {
Node* const input = NodeProperties::GetValueInput(node, 0);
Type const input_type = NodeProperties::GetType(input);
if (input_type.Is(type_cache_.kIntegerOrMinusZeroOrNaN)) {
if (input_type.Is(type_cache_->kIntegerOrMinusZeroOrNaN)) {
return Replace(input);
}
if (input_type.Is(Type::PlainNumber()) &&
@ -280,7 +280,7 @@ Reduction TypedOptimization::ReduceNumberFloor(Node* node) {
Reduction TypedOptimization::ReduceNumberRoundop(Node* node) {
Node* const input = NodeProperties::GetValueInput(node, 0);
Type const input_type = NodeProperties::GetType(input);
if (input_type.Is(type_cache_.kIntegerOrMinusZeroOrNaN)) {
if (input_type.Is(type_cache_->kIntegerOrMinusZeroOrNaN)) {
return Replace(input);
}
return NoChange();
@ -298,7 +298,7 @@ Reduction TypedOptimization::ReduceNumberSilenceNaN(Node* node) {
Reduction TypedOptimization::ReduceNumberToUint8Clamped(Node* node) {
Node* const input = NodeProperties::GetValueInput(node, 0);
Type const input_type = NodeProperties::GetType(input);
if (input_type.Is(type_cache_.kUint8)) {
if (input_type.Is(type_cache_->kUint8)) {
return Replace(input);
}
return NoChange();
@ -402,7 +402,7 @@ TypedOptimization::TryReduceStringComparisonOfStringFromSingleCharCode(
const Operator* comparison_op = NumberComparisonFor(comparison->op());
Node* from_char_code_repl = NodeProperties::GetValueInput(from_char_code, 0);
Type from_char_code_repl_type = NodeProperties::GetType(from_char_code_repl);
if (!from_char_code_repl_type.Is(type_cache_.kUint16)) {
if (!from_char_code_repl_type.Is(type_cache_->kUint16)) {
// Convert to signed int32 to satisfy type of {NumberBitwiseAnd}.
from_char_code_repl =
graph()->NewNode(simplified()->NumberToInt32(), from_char_code_repl);
@ -448,14 +448,14 @@ Reduction TypedOptimization::ReduceStringComparison(Node* node) {
Node* right = NodeProperties::GetValueInput(rhs, 0);
Type left_type = NodeProperties::GetType(left);
Type right_type = NodeProperties::GetType(right);
if (!left_type.Is(type_cache_.kUint16)) {
if (!left_type.Is(type_cache_->kUint16)) {
// Convert to signed int32 to satisfy type of {NumberBitwiseAnd}.
left = graph()->NewNode(simplified()->NumberToInt32(), left);
left = graph()->NewNode(
simplified()->NumberBitwiseAnd(), left,
jsgraph()->Constant(std::numeric_limits<uint16_t>::max()));
}
if (!right_type.Is(type_cache_.kUint16)) {
if (!right_type.Is(type_cache_->kUint16)) {
// Convert to signed int32 to satisfy type of {NumberBitwiseAnd}.
right = graph()->NewNode(simplified()->NumberToInt32(), right);
right = graph()->NewNode(

View File

@ -86,7 +86,7 @@ class V8_EXPORT_PRIVATE TypedOptimization final
JSHeapBroker* broker_;
Type const true_type_;
Type const false_type_;
TypeCache const& type_cache_;
TypeCache const* type_cache_;
DISALLOW_COPY_AND_ASSIGN(TypedOptimization);
};

View File

@ -498,7 +498,7 @@ Type Typer::Visitor::FalsifyUndefined(ComparisonOutcome outcome, Typer* t) {
Type Typer::Visitor::BitwiseNot(Type type, Typer* t) {
type = ToNumeric(type, t);
if (type.Is(Type::Number())) {
return NumberBitwiseXor(type, t->cache_.kSingletonMinusOne, t);
return NumberBitwiseXor(type, t->cache_->kSingletonMinusOne, t);
}
return Type::Numeric();
}
@ -506,7 +506,7 @@ Type Typer::Visitor::BitwiseNot(Type type, Typer* t) {
Type Typer::Visitor::Decrement(Type type, Typer* t) {
type = ToNumeric(type, t);
if (type.Is(Type::Number())) {
return NumberSubtract(type, t->cache_.kSingletonOne, t);
return NumberSubtract(type, t->cache_->kSingletonOne, t);
}
return Type::Numeric();
}
@ -514,7 +514,7 @@ Type Typer::Visitor::Decrement(Type type, Typer* t) {
Type Typer::Visitor::Increment(Type type, Typer* t) {
type = ToNumeric(type, t);
if (type.Is(Type::Number())) {
return NumberAdd(type, t->cache_.kSingletonOne, t);
return NumberAdd(type, t->cache_->kSingletonOne, t);
}
return Type::Numeric();
}
@ -522,7 +522,7 @@ Type Typer::Visitor::Increment(Type type, Typer* t) {
Type Typer::Visitor::Negate(Type type, Typer* t) {
type = ToNumeric(type, t);
if (type.Is(Type::Number())) {
return NumberMultiply(type, t->cache_.kSingletonMinusOne, t);
return NumberMultiply(type, t->cache_->kSingletonMinusOne, t);
}
return Type::Numeric();
}
@ -545,13 +545,13 @@ Type Typer::Visitor::ToBoolean(Type type, Typer* t) {
Type Typer::Visitor::ToInteger(Type type, Typer* t) {
// ES6 section 7.1.4 ToInteger ( argument )
type = ToNumber(type, t);
if (type.Is(t->cache_.kIntegerOrMinusZero)) return type;
if (type.Is(t->cache_.kIntegerOrMinusZeroOrNaN)) {
if (type.Is(t->cache_->kIntegerOrMinusZero)) return type;
if (type.Is(t->cache_->kIntegerOrMinusZeroOrNaN)) {
return Type::Union(
Type::Intersect(type, t->cache_.kIntegerOrMinusZero, t->zone()),
t->cache_.kSingletonZero, t->zone());
Type::Intersect(type, t->cache_->kIntegerOrMinusZero, t->zone()),
t->cache_->kSingletonZero, t->zone());
}
return t->cache_.kIntegerOrMinusZero;
return t->cache_->kIntegerOrMinusZero;
}
@ -813,8 +813,8 @@ Type Typer::Visitor::TypeInductionVariablePhi(Node* node) {
// We only handle integer induction variables (otherwise ranges
// do not apply and we cannot do anything).
if (!initial_type.Is(typer_->cache_.kInteger) ||
!increment_type.Is(typer_->cache_.kInteger)) {
if (!initial_type.Is(typer_->cache_->kInteger) ||
!increment_type.Is(typer_->cache_->kInteger)) {
// Fallback to normal phi typing, but ensure monotonicity.
// (Unfortunately, without baking in the previous type, monotonicity might
// be violated because we might not yet have retyped the incrementing
@ -830,7 +830,7 @@ Type Typer::Visitor::TypeInductionVariablePhi(Node* node) {
// If we do not have enough type information for the initial value or
// the increment, just return the initial value's type.
if (initial_type.IsNone() ||
increment_type.Is(typer_->cache_.kSingletonZero)) {
increment_type.Is(typer_->cache_->kSingletonZero)) {
return initial_type;
}
@ -861,7 +861,7 @@ Type Typer::Visitor::TypeInductionVariablePhi(Node* node) {
for (auto bound : induction_var->upper_bounds()) {
Type bound_type = TypeOrNone(bound.bound);
// If the type is not an integer, just skip the bound.
if (!bound_type.Is(typer_->cache_.kInteger)) continue;
if (!bound_type.Is(typer_->cache_->kInteger)) continue;
// If the type is not inhabited, then we can take the initial value.
if (bound_type.IsNone()) {
max = initial_type.Max();
@ -881,7 +881,7 @@ Type Typer::Visitor::TypeInductionVariablePhi(Node* node) {
for (auto bound : induction_var->lower_bounds()) {
Type bound_type = TypeOrNone(bound.bound);
// If the type is not an integer, just skip the bound.
if (!bound_type.Is(typer_->cache_.kInteger)) continue;
if (!bound_type.Is(typer_->cache_->kInteger)) continue;
// If the type is not inhabited, then we can take the initial value.
if (bound_type.IsNone()) {
min = initial_type.Min();
@ -898,7 +898,7 @@ Type Typer::Visitor::TypeInductionVariablePhi(Node* node) {
} else {
// Shortcut: If the increment can be both positive and negative,
// the variable can go arbitrarily far, so just return integer.
return typer_->cache_.kInteger;
return typer_->cache_->kInteger;
}
if (FLAG_trace_turbo_loop) {
StdoutStream{} << std::setprecision(10) << "Loop ("
@ -1338,7 +1338,7 @@ Type Typer::Visitor::Weaken(Node* node, Type current_type, Type previous_type) {
STATIC_ASSERT(arraysize(kWeakenMinLimits) == arraysize(kWeakenMaxLimits));
// If the types have nothing to do with integers, return the types.
Type const integer = typer_->cache_.kInteger;
Type const integer = typer_->cache_->kInteger;
if (!previous_type.Maybe(integer)) {
return current_type;
}
@ -1499,7 +1499,7 @@ Type Typer::Visitor::JSCallTyper(Type fun, Typer* t) {
case BuiltinFunctionId::kMathCeil:
case BuiltinFunctionId::kMathRound:
case BuiltinFunctionId::kMathTrunc:
return t->cache_.kIntegerOrMinusZeroOrNaN;
return t->cache_->kIntegerOrMinusZeroOrNaN;
// Unary math functions.
case BuiltinFunctionId::kMathAbs:
case BuiltinFunctionId::kMathExp:
@ -1523,7 +1523,7 @@ Type Typer::Visitor::JSCallTyper(Type fun, Typer* t) {
case BuiltinFunctionId::kMathTan:
return Type::Number();
case BuiltinFunctionId::kMathSign:
return t->cache_.kMinusOneToOneOrMinusZeroOrNaN;
return t->cache_->kMinusOneToOneOrMinusZeroOrNaN;
// Binary math functions.
case BuiltinFunctionId::kMathAtan2:
case BuiltinFunctionId::kMathPow:
@ -1533,29 +1533,29 @@ Type Typer::Visitor::JSCallTyper(Type fun, Typer* t) {
case BuiltinFunctionId::kMathImul:
return Type::Signed32();
case BuiltinFunctionId::kMathClz32:
return t->cache_.kZeroToThirtyTwo;
return t->cache_->kZeroToThirtyTwo;
// Date functions.
case BuiltinFunctionId::kDateNow:
return t->cache_.kTimeValueType;
return t->cache_->kTimeValueType;
case BuiltinFunctionId::kDateGetDate:
return t->cache_.kJSDateDayType;
return t->cache_->kJSDateDayType;
case BuiltinFunctionId::kDateGetDay:
return t->cache_.kJSDateWeekdayType;
return t->cache_->kJSDateWeekdayType;
case BuiltinFunctionId::kDateGetFullYear:
return t->cache_.kJSDateYearType;
return t->cache_->kJSDateYearType;
case BuiltinFunctionId::kDateGetHours:
return t->cache_.kJSDateHourType;
return t->cache_->kJSDateHourType;
case BuiltinFunctionId::kDateGetMilliseconds:
return Type::Union(Type::Range(0.0, 999.0, t->zone()), Type::NaN(),
t->zone());
case BuiltinFunctionId::kDateGetMinutes:
return t->cache_.kJSDateMinuteType;
return t->cache_->kJSDateMinuteType;
case BuiltinFunctionId::kDateGetMonth:
return t->cache_.kJSDateMonthType;
return t->cache_->kJSDateMonthType;
case BuiltinFunctionId::kDateGetSeconds:
return t->cache_.kJSDateSecondType;
return t->cache_->kJSDateSecondType;
case BuiltinFunctionId::kDateGetTime:
return t->cache_.kJSDateValueType;
return t->cache_->kJSDateValueType;
// Symbol functions.
case BuiltinFunctionId::kSymbolConstructor:
@ -1580,7 +1580,7 @@ Type Typer::Visitor::JSCallTyper(Type fun, Typer* t) {
case BuiltinFunctionId::kNumberParseFloat:
return Type::Number();
case BuiltinFunctionId::kNumberParseInt:
return t->cache_.kIntegerOrMinusZeroOrNaN;
return t->cache_->kIntegerOrMinusZeroOrNaN;
case BuiltinFunctionId::kNumberToString:
return Type::String();
@ -1665,7 +1665,7 @@ Type Typer::Visitor::JSCallTyper(Type fun, Typer* t) {
case BuiltinFunctionId::kArrayMap:
return Type::Receiver();
case BuiltinFunctionId::kArrayPush:
return t->cache_.kPositiveSafeInteger;
return t->cache_->kPositiveSafeInteger;
case BuiltinFunctionId::kArrayReverse:
case BuiltinFunctionId::kArraySlice:
return Type::Receiver();
@ -1674,7 +1674,7 @@ Type Typer::Visitor::JSCallTyper(Type fun, Typer* t) {
case BuiltinFunctionId::kArraySplice:
return Type::Receiver();
case BuiltinFunctionId::kArrayUnshift:
return t->cache_.kPositiveSafeInteger;
return t->cache_->kPositiveSafeInteger;
// ArrayBuffer functions.
case BuiltinFunctionId::kArrayBufferIsView:
@ -1836,7 +1836,7 @@ Type Typer::Visitor::TypeJSForInPrepare(Node* node) {
Type const cache_type =
Type::Union(Type::SignedSmall(), Type::OtherInternal(), zone());
Type const cache_array = Type::OtherInternal();
Type const cache_length = typer_->cache_.kFixedArrayLengthType;
Type const cache_length = typer_->cache_->kFixedArrayLengthType;
return Type::Tuple(cache_type, cache_array, cache_length, zone());
}
@ -2011,7 +2011,7 @@ Type Typer::Visitor::TypeStringToUpperCaseIntl(Node* node) {
}
Type Typer::Visitor::TypeStringCharCodeAt(Node* node) {
return typer_->cache_.kUint16;
return typer_->cache_->kUint16;
}
Type Typer::Visitor::TypeStringCodePointAt(Node* node) {
@ -2031,13 +2031,13 @@ Type Typer::Visitor::TypeStringIndexOf(Node* node) {
}
Type Typer::Visitor::TypeStringLength(Node* node) {
return typer_->cache_.kStringLengthType;
return typer_->cache_->kStringLengthType;
}
Type Typer::Visitor::TypeStringSubstring(Node* node) { return Type::String(); }
Type Typer::Visitor::TypePoisonIndex(Node* node) {
return Type::Union(Operand(node, 0), typer_->cache_.kSingletonZero, zone());
return Type::Union(Operand(node, 0), typer_->cache_->kSingletonZero, zone());
}
Type Typer::Visitor::TypeCheckBounds(Node* node) {
@ -2138,7 +2138,7 @@ Type Typer::Visitor::TypeLoadTypedElement(Node* node) {
switch (ExternalArrayTypeOf(node->op())) {
#define TYPED_ARRAY_CASE(ElemType, type, TYPE, ctype) \
case kExternal##ElemType##Array: \
return typer_->cache_.k##ElemType;
return typer_->cache_->k##ElemType;
TYPED_ARRAYS(TYPED_ARRAY_CASE)
#undef TYPED_ARRAY_CASE
}
@ -2149,7 +2149,7 @@ Type Typer::Visitor::TypeLoadDataViewElement(Node* node) {
switch (ExternalArrayTypeOf(node->op())) {
#define TYPED_ARRAY_CASE(ElemType, type, TYPE, ctype) \
case kExternal##ElemType##Array: \
return typer_->cache_.k##ElemType;
return typer_->cache_->k##ElemType;
TYPED_ARRAYS(TYPED_ARRAY_CASE)
#undef TYPED_ARRAY_CASE
}
@ -2263,7 +2263,7 @@ Type Typer::Visitor::TypeObjectIsUndetectable(Node* node) {
}
Type Typer::Visitor::TypeArgumentsLength(Node* node) {
return TypeCache::Get().kArgumentsLengthType;
return TypeCache::Get()->kArgumentsLengthType;
}
Type Typer::Visitor::TypeArgumentsFrame(Node* node) {

View File

@ -46,7 +46,7 @@ class V8_EXPORT_PRIVATE Typer {
Flags const flags_;
Graph* const graph_;
Decorator* decorator_;
TypeCache const& cache_;
TypeCache const* cache_;
JSHeapBroker* broker_;
OperationTyper operation_typer_;

View File

@ -1110,7 +1110,7 @@ void Verifier::Visitor::Check(Node* node, const AllNodes& all) {
CheckTypeIs(node, Type::Number());
break;
case IrOpcode::kStringConcat:
CheckValueInputIs(node, 0, TypeCache::Get().kStringLengthType);
CheckValueInputIs(node, 0, TypeCache::Get()->kStringLengthType);
CheckValueInputIs(node, 1, Type::String());
CheckValueInputIs(node, 2, Type::String());
CheckTypeIs(node, Type::String());
@ -1159,7 +1159,7 @@ void Verifier::Visitor::Check(Node* node, const AllNodes& all) {
break;
case IrOpcode::kStringLength:
CheckValueInputIs(node, 0, Type::String());
CheckTypeIs(node, TypeCache::Get().kStringLengthType);
CheckTypeIs(node, TypeCache::Get()->kStringLengthType);
break;
case IrOpcode::kStringToLowerCaseIntl:
case IrOpcode::kStringToUpperCaseIntl:
@ -1245,7 +1245,7 @@ void Verifier::Visitor::Check(Node* node, const AllNodes& all) {
break;
case IrOpcode::kArgumentsLength:
CheckValueInputIs(node, 0, Type::ExternalPointer());
CheckTypeIs(node, TypeCache::Get().kArgumentsLengthType);
CheckTypeIs(node, TypeCache::Get()->kArgumentsLengthType);
break;
case IrOpcode::kArgumentsFrame:
CheckTypeIs(node, Type::ExternalPointer());
@ -1263,7 +1263,7 @@ void Verifier::Visitor::Check(Node* node, const AllNodes& all) {
CheckTypeIs(node, Type::OtherInternal());
break;
case IrOpcode::kNewConsString:
CheckValueInputIs(node, 0, TypeCache::Get().kStringLengthType);
CheckValueInputIs(node, 0, TypeCache::Get()->kStringLengthType);
CheckValueInputIs(node, 1, Type::String());
CheckValueInputIs(node, 2, Type::String());
CheckTypeIs(node, Type::String());
@ -1421,8 +1421,8 @@ void Verifier::Visitor::Check(Node* node, const AllNodes& all) {
case IrOpcode::kCheckBounds:
CheckValueInputIs(node, 0, Type::Any());
CheckValueInputIs(node, 1, TypeCache::Get().kPositiveSafeInteger);
CheckTypeIs(node, TypeCache::Get().kPositiveSafeInteger);
CheckValueInputIs(node, 1, TypeCache::Get()->kPositiveSafeInteger);
CheckTypeIs(node, TypeCache::Get()->kPositiveSafeInteger);
break;
case IrOpcode::kPoisonIndex:
CheckValueInputIs(node, 0, Type::Unsigned32());

View File

@ -289,7 +289,7 @@ TEST(ToInt64_constant) {
Node* n = r.jsgraph()->Constant(*i);
Node* use = r.Return(n);
Node* c = r.changer()->GetRepresentationFor(
n, MachineRepresentation::kTagged, TypeCache::Get().kSafeInteger, use,
n, MachineRepresentation::kTagged, TypeCache::Get()->kSafeInteger, use,
UseInfo(MachineRepresentation::kWord64, Truncation::None()));
r.CheckInt64Constant(c, *i);
}
@ -367,13 +367,13 @@ static void CheckChange(IrOpcode::Value expected, MachineRepresentation from,
TEST(Word64) {
CheckChange(IrOpcode::kChangeInt32ToInt64, MachineRepresentation::kWord8,
TypeCache::Get().kInt8, MachineRepresentation::kWord64);
TypeCache::Get()->kInt8, MachineRepresentation::kWord64);
CheckChange(IrOpcode::kChangeUint32ToUint64, MachineRepresentation::kWord8,
TypeCache::Get().kUint8, MachineRepresentation::kWord64);
TypeCache::Get()->kUint8, MachineRepresentation::kWord64);
CheckChange(IrOpcode::kChangeInt32ToInt64, MachineRepresentation::kWord16,
TypeCache::Get().kInt16, MachineRepresentation::kWord64);
TypeCache::Get()->kInt16, MachineRepresentation::kWord64);
CheckChange(IrOpcode::kChangeUint32ToUint64, MachineRepresentation::kWord16,
TypeCache::Get().kUint16, MachineRepresentation::kWord64);
TypeCache::Get()->kUint16, MachineRepresentation::kWord64);
CheckChange(IrOpcode::kChangeInt32ToInt64, MachineRepresentation::kWord32,
Type::Signed32(), MachineRepresentation::kWord64);
CheckChange(IrOpcode::kChangeUint32ToUint64, MachineRepresentation::kWord32,
@ -384,15 +384,15 @@ TEST(Word64) {
CheckChange(IrOpcode::kTruncateInt64ToInt32, MachineRepresentation::kWord64,
Type::Unsigned32(), MachineRepresentation::kWord32);
CheckChange(IrOpcode::kTruncateInt64ToInt32, MachineRepresentation::kWord64,
TypeCache::Get().kSafeInteger, MachineRepresentation::kWord32,
TypeCache::Get()->kSafeInteger, MachineRepresentation::kWord32,
UseInfo::TruncatingWord32());
CheckChange(
IrOpcode::kCheckedInt64ToInt32, MachineRepresentation::kWord64,
TypeCache::Get().kSafeInteger, MachineRepresentation::kWord32,
TypeCache::Get()->kSafeInteger, MachineRepresentation::kWord32,
UseInfo::CheckedSigned32AsWord32(kIdentifyZeros, VectorSlotPair()));
CheckChange(
IrOpcode::kCheckedUint64ToInt32, MachineRepresentation::kWord64,
TypeCache::Get().kPositiveSafeInteger, MachineRepresentation::kWord32,
TypeCache::Get()->kPositiveSafeInteger, MachineRepresentation::kWord32,
UseInfo::CheckedSigned32AsWord32(kIdentifyZeros, VectorSlotPair()));
CheckChange(IrOpcode::kChangeFloat64ToInt64, MachineRepresentation::kFloat64,
@ -400,11 +400,11 @@ TEST(Word64) {
CheckChange(IrOpcode::kChangeFloat64ToInt64, MachineRepresentation::kFloat64,
Type::Unsigned32(), MachineRepresentation::kWord64);
CheckChange(IrOpcode::kChangeFloat64ToInt64, MachineRepresentation::kFloat64,
TypeCache::Get().kSafeInteger, MachineRepresentation::kWord64);
TypeCache::Get()->kSafeInteger, MachineRepresentation::kWord64);
CheckChange(IrOpcode::kChangeFloat64ToInt64, MachineRepresentation::kFloat64,
TypeCache::Get().kInt64, MachineRepresentation::kWord64);
TypeCache::Get()->kInt64, MachineRepresentation::kWord64);
CheckChange(IrOpcode::kChangeFloat64ToUint64, MachineRepresentation::kFloat64,
TypeCache::Get().kUint64, MachineRepresentation::kWord64);
TypeCache::Get()->kUint64, MachineRepresentation::kWord64);
CheckChange(
IrOpcode::kCheckedFloat64ToInt64, MachineRepresentation::kFloat64,
Type::Number(), MachineRepresentation::kWord64,
@ -415,7 +415,7 @@ TEST(Word64) {
CheckChange(IrOpcode::kChangeInt64ToFloat64, MachineRepresentation::kWord64,
Type::Unsigned32(), MachineRepresentation::kFloat64);
CheckChange(IrOpcode::kChangeInt64ToFloat64, MachineRepresentation::kWord64,
TypeCache::Get().kSafeInteger, MachineRepresentation::kFloat64);
TypeCache::Get()->kSafeInteger, MachineRepresentation::kFloat64);
CheckTwoChanges(IrOpcode::kChangeFloat32ToFloat64,
IrOpcode::kChangeFloat64ToInt64,
@ -427,11 +427,11 @@ TEST(Word64) {
MachineRepresentation::kWord64);
CheckTwoChanges(IrOpcode::kChangeFloat32ToFloat64,
IrOpcode::kChangeFloat64ToInt64,
MachineRepresentation::kFloat32, TypeCache::Get().kInt64,
MachineRepresentation::kFloat32, TypeCache::Get()->kInt64,
MachineRepresentation::kWord64);
CheckTwoChanges(IrOpcode::kChangeFloat32ToFloat64,
IrOpcode::kChangeFloat64ToUint64,
MachineRepresentation::kFloat32, TypeCache::Get().kUint64,
MachineRepresentation::kFloat32, TypeCache::Get()->kUint64,
MachineRepresentation::kWord64);
CheckTwoChanges(
IrOpcode::kChangeFloat32ToFloat64, IrOpcode::kCheckedFloat64ToInt64,
@ -449,9 +449,9 @@ TEST(Word64) {
CheckChange(IrOpcode::kChangeTaggedToInt64, MachineRepresentation::kTagged,
Type::Unsigned32(), MachineRepresentation::kWord64);
CheckChange(IrOpcode::kChangeTaggedToInt64, MachineRepresentation::kTagged,
TypeCache::Get().kSafeInteger, MachineRepresentation::kWord64);
TypeCache::Get()->kSafeInteger, MachineRepresentation::kWord64);
CheckChange(IrOpcode::kChangeTaggedToInt64, MachineRepresentation::kTagged,
TypeCache::Get().kInt64, MachineRepresentation::kWord64);
TypeCache::Get()->kInt64, MachineRepresentation::kWord64);
CheckChange(IrOpcode::kChangeTaggedSignedToInt64,
MachineRepresentation::kTaggedSigned, Type::SignedSmall(),
MachineRepresentation::kWord64);
@ -477,9 +477,9 @@ TEST(Word64) {
MachineRepresentation::kWord64, Type::Unsigned32(),
MachineRepresentation::kTagged);
CheckChange(IrOpcode::kChangeInt64ToTagged, MachineRepresentation::kWord64,
TypeCache::Get().kSafeInteger, MachineRepresentation::kTagged);
TypeCache::Get()->kSafeInteger, MachineRepresentation::kTagged);
CheckChange(IrOpcode::kChangeUint64ToTagged, MachineRepresentation::kWord64,
TypeCache::Get().kPositiveSafeInteger,
TypeCache::Get()->kPositiveSafeInteger,
MachineRepresentation::kTagged);
CheckTwoChanges(IrOpcode::kTruncateInt64ToInt32,
@ -493,18 +493,18 @@ TEST(Word64) {
MachineRepresentation::kTaggedSigned);
}
CheckChange(IrOpcode::kCheckedInt64ToTaggedSigned,
MachineRepresentation::kWord64, TypeCache::Get().kSafeInteger,
MachineRepresentation::kWord64, TypeCache::Get()->kSafeInteger,
MachineRepresentation::kTaggedSigned,
UseInfo::CheckedSignedSmallAsTaggedSigned(VectorSlotPair()));
CheckChange(IrOpcode::kCheckedUint64ToTaggedSigned,
MachineRepresentation::kWord64,
TypeCache::Get().kPositiveSafeInteger,
TypeCache::Get()->kPositiveSafeInteger,
MachineRepresentation::kTaggedSigned,
UseInfo::CheckedSignedSmallAsTaggedSigned(VectorSlotPair()));
CheckTwoChanges(IrOpcode::kChangeInt64ToFloat64,
IrOpcode::kChangeFloat64ToTaggedPointer,
MachineRepresentation::kWord64, TypeCache::Get().kSafeInteger,
CheckTwoChanges(
IrOpcode::kChangeInt64ToFloat64, IrOpcode::kChangeFloat64ToTaggedPointer,
MachineRepresentation::kWord64, TypeCache::Get()->kSafeInteger,
MachineRepresentation::kTaggedPointer);
}