[turbofan] Improve constant-folding for typeof.
Especially support constant-folding typeof for detectable and undetectable receivers. BUG=v8:5267,v8:5270 R=jarin@chromium.org Review-Url: https://codereview.chromium.org/2646743002 Cr-Commit-Position: refs/heads/master@{#42494}
This commit is contained in:
parent
7682837501
commit
c9a980d59a
@ -861,18 +861,15 @@ Reduction JSTypedLowering::ReduceJSTypeOf(Node* node) {
|
||||
return Replace(jsgraph()->Constant(f->string_string()));
|
||||
} else if (type->Is(Type::Symbol())) {
|
||||
return Replace(jsgraph()->Constant(f->symbol_string()));
|
||||
} else if (type->Is(Type::Union(Type::Undefined(), Type::OtherUndetectable(),
|
||||
graph()->zone()))) {
|
||||
} else if (type->Is(Type::OtherUndetectableOrUndefined())) {
|
||||
return Replace(jsgraph()->Constant(f->undefined_string()));
|
||||
} else if (type->Is(Type::Null())) {
|
||||
} else if (type->Is(Type::NonCallableOrNull())) {
|
||||
return Replace(jsgraph()->Constant(f->object_string()));
|
||||
} else if (type->Is(Type::Function())) {
|
||||
return Replace(jsgraph()->Constant(f->function_string()));
|
||||
} else if (type->IsHeapConstant()) {
|
||||
return Replace(jsgraph()->Constant(
|
||||
Object::TypeOf(isolate(), type->AsHeapConstant()->Value())));
|
||||
} else if (type->IsOtherNumberConstant()) {
|
||||
return Replace(jsgraph()->Constant(f->number_string()));
|
||||
}
|
||||
|
||||
return NoChange();
|
||||
|
@ -128,57 +128,64 @@ namespace compiler {
|
||||
V(OtherInternal, 1u << 24) \
|
||||
V(ExternalPointer, 1u << 25) \
|
||||
\
|
||||
V(Signed31, kUnsigned30 | kNegative31) \
|
||||
V(Signed32, kSigned31 | kOtherUnsigned31 | kOtherSigned32) \
|
||||
V(Signed32OrMinusZero, kSigned32 | kMinusZero) \
|
||||
V(Signed32OrMinusZeroOrNaN, kSigned32 | kMinusZero | kNaN) \
|
||||
V(Negative32, kNegative31 | kOtherSigned32) \
|
||||
V(Unsigned31, kUnsigned30 | kOtherUnsigned31) \
|
||||
V(Unsigned32, kUnsigned30 | kOtherUnsigned31 | \
|
||||
kOtherUnsigned32) \
|
||||
V(Unsigned32OrMinusZero, kUnsigned32 | kMinusZero) \
|
||||
V(Unsigned32OrMinusZeroOrNaN, kUnsigned32 | kMinusZero | kNaN) \
|
||||
V(Integral32, kSigned32 | kUnsigned32) \
|
||||
V(Integral32OrMinusZeroOrNaN, kIntegral32 | kMinusZero | kNaN) \
|
||||
V(PlainNumber, kIntegral32 | kOtherNumber) \
|
||||
V(OrderedNumber, kPlainNumber | kMinusZero) \
|
||||
V(MinusZeroOrNaN, kMinusZero | kNaN) \
|
||||
V(Number, kOrderedNumber | kNaN) \
|
||||
V(String, kInternalizedString | kOtherString) \
|
||||
V(UniqueName, kSymbol | kInternalizedString) \
|
||||
V(Name, kSymbol | kString) \
|
||||
V(BooleanOrNumber, kBoolean | kNumber) \
|
||||
V(BooleanOrNullOrNumber, kBooleanOrNumber | kNull) \
|
||||
V(BooleanOrNullOrUndefined, kBoolean | kNull | kUndefined) \
|
||||
V(NullOrNumber, kNull | kNumber) \
|
||||
V(NullOrUndefined, kNull | kUndefined) \
|
||||
V(Undetectable, kNullOrUndefined | kOtherUndetectable) \
|
||||
V(NumberOrOddball, kNumber | kNullOrUndefined | kBoolean | kHole) \
|
||||
V(NumberOrSimdOrString, kNumber | kSimd | kString) \
|
||||
V(NumberOrString, kNumber | kString) \
|
||||
V(NumberOrUndefined, kNumber | kUndefined) \
|
||||
V(PlainPrimitive, kNumberOrString | kBoolean | kNullOrUndefined) \
|
||||
V(Primitive, kSymbol | kSimd | kPlainPrimitive) \
|
||||
V(Proxy, kCallableProxy | kOtherProxy) \
|
||||
V(Callable, kFunction | kBoundFunction | kOtherCallable | \
|
||||
kCallableProxy | kOtherUndetectable) \
|
||||
V(DetectableObject, kFunction | kBoundFunction | kOtherCallable | \
|
||||
kOtherObject) \
|
||||
V(DetectableReceiver, kDetectableObject | kProxy) \
|
||||
V(DetectableReceiverOrNull, kDetectableReceiver | kNull) \
|
||||
V(Object, kDetectableObject | kOtherUndetectable) \
|
||||
V(Receiver, kObject | kProxy) \
|
||||
V(ReceiverOrUndefined, kReceiver | kUndefined) \
|
||||
V(ReceiverOrNullOrUndefined, kReceiver | kNull | kUndefined) \
|
||||
V(StringOrReceiver, kString | kReceiver) \
|
||||
V(Unique, kBoolean | kUniqueName | kNull | kUndefined | \
|
||||
kReceiver) \
|
||||
V(NonStringUniqueOrHole, kBoolean | kHole | kNull | kReceiver | \
|
||||
kSymbol | kUndefined) \
|
||||
V(Internal, kHole | kExternalPointer | kOtherInternal) \
|
||||
V(NonInternal, kPrimitive | kReceiver) \
|
||||
V(NonNumber, kUnique | kString | kInternal) \
|
||||
V(Any, 0xfffffffeu)
|
||||
V(Signed31, kUnsigned30 | kNegative31) \
|
||||
V(Signed32, kSigned31 | kOtherUnsigned31 | \
|
||||
kOtherSigned32) \
|
||||
V(Signed32OrMinusZero, kSigned32 | kMinusZero) \
|
||||
V(Signed32OrMinusZeroOrNaN, kSigned32 | kMinusZero | kNaN) \
|
||||
V(Negative32, kNegative31 | kOtherSigned32) \
|
||||
V(Unsigned31, kUnsigned30 | kOtherUnsigned31) \
|
||||
V(Unsigned32, kUnsigned30 | kOtherUnsigned31 | \
|
||||
kOtherUnsigned32) \
|
||||
V(Unsigned32OrMinusZero, kUnsigned32 | kMinusZero) \
|
||||
V(Unsigned32OrMinusZeroOrNaN, kUnsigned32 | kMinusZero | kNaN) \
|
||||
V(Integral32, kSigned32 | kUnsigned32) \
|
||||
V(Integral32OrMinusZeroOrNaN, kIntegral32 | kMinusZero | kNaN) \
|
||||
V(PlainNumber, kIntegral32 | kOtherNumber) \
|
||||
V(OrderedNumber, kPlainNumber | kMinusZero) \
|
||||
V(MinusZeroOrNaN, kMinusZero | kNaN) \
|
||||
V(Number, kOrderedNumber | kNaN) \
|
||||
V(String, kInternalizedString | kOtherString) \
|
||||
V(UniqueName, kSymbol | kInternalizedString) \
|
||||
V(Name, kSymbol | kString) \
|
||||
V(BooleanOrNumber, kBoolean | kNumber) \
|
||||
V(BooleanOrNullOrNumber, kBooleanOrNumber | kNull) \
|
||||
V(BooleanOrNullOrUndefined, kBoolean | kNull | kUndefined) \
|
||||
V(NullOrNumber, kNull | kNumber) \
|
||||
V(NullOrUndefined, kNull | kUndefined) \
|
||||
V(Undetectable, kNullOrUndefined | kOtherUndetectable) \
|
||||
V(NumberOrOddball, kNumber | kNullOrUndefined | kBoolean | \
|
||||
kHole) \
|
||||
V(NumberOrSimdOrString, kNumber | kSimd | kString) \
|
||||
V(NumberOrString, kNumber | kString) \
|
||||
V(NumberOrUndefined, kNumber | kUndefined) \
|
||||
V(PlainPrimitive, kNumberOrString | kBoolean | \
|
||||
kNullOrUndefined) \
|
||||
V(Primitive, kSymbol | kSimd | kPlainPrimitive) \
|
||||
V(OtherUndetectableOrUndefined, kOtherUndetectable | kUndefined) \
|
||||
V(Proxy, kCallableProxy | kOtherProxy) \
|
||||
V(Callable, kFunction | kBoundFunction | \
|
||||
kOtherCallable | kCallableProxy | \
|
||||
kOtherUndetectable) \
|
||||
V(NonCallable, kOtherObject | kOtherProxy) \
|
||||
V(NonCallableOrNull, kNonCallable | kNull) \
|
||||
V(DetectableObject, kFunction | kBoundFunction | \
|
||||
kOtherCallable | kOtherObject) \
|
||||
V(DetectableReceiver, kDetectableObject | kProxy) \
|
||||
V(DetectableReceiverOrNull, kDetectableReceiver | kNull) \
|
||||
V(Object, kDetectableObject | kOtherUndetectable) \
|
||||
V(Receiver, kObject | kProxy) \
|
||||
V(ReceiverOrUndefined, kReceiver | kUndefined) \
|
||||
V(ReceiverOrNullOrUndefined, kReceiver | kNull | kUndefined) \
|
||||
V(StringOrReceiver, kString | kReceiver) \
|
||||
V(Unique, kBoolean | kUniqueName | kNull | \
|
||||
kUndefined | kReceiver) \
|
||||
V(NonStringUniqueOrHole, kBoolean | kHole | kNull | kReceiver | \
|
||||
kSymbol | kUndefined) \
|
||||
V(Internal, kHole | kExternalPointer | kOtherInternal) \
|
||||
V(NonInternal, kPrimitive | kReceiver) \
|
||||
V(NonNumber, kUnique | kString | kInternal) \
|
||||
V(Any, 0xfffffffeu)
|
||||
|
||||
// clang-format on
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user