[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:
bmeurer 2017-01-19 02:26:17 -08:00 committed by Commit bot
parent 7682837501
commit c9a980d59a
2 changed files with 60 additions and 56 deletions

View File

@ -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();

View File

@ -129,7 +129,8 @@ namespace compiler {
V(ExternalPointer, 1u << 25) \
\
V(Signed31, kUnsigned30 | kNegative31) \
V(Signed32, kSigned31 | kOtherUnsigned31 | kOtherSigned32) \
V(Signed32, kSigned31 | kOtherUnsigned31 | \
kOtherSigned32) \
V(Signed32OrMinusZero, kSigned32 | kMinusZero) \
V(Signed32OrMinusZeroOrNaN, kSigned32 | kMinusZero | kNaN) \
V(Negative32, kNegative31 | kOtherSigned32) \
@ -153,17 +154,23 @@ namespace compiler {
V(NullOrNumber, kNull | kNumber) \
V(NullOrUndefined, kNull | kUndefined) \
V(Undetectable, kNullOrUndefined | kOtherUndetectable) \
V(NumberOrOddball, kNumber | kNullOrUndefined | kBoolean | kHole) \
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(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(DetectableObject, kFunction | kBoundFunction | kOtherCallable | \
kOtherObject) \
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) \
@ -171,8 +178,8 @@ namespace compiler {
V(ReceiverOrUndefined, kReceiver | kUndefined) \
V(ReceiverOrNullOrUndefined, kReceiver | kNull | kUndefined) \
V(StringOrReceiver, kString | kReceiver) \
V(Unique, kBoolean | kUniqueName | kNull | kUndefined | \
kReceiver) \
V(Unique, kBoolean | kUniqueName | kNull | \
kUndefined | kReceiver) \
V(NonStringUniqueOrHole, kBoolean | kHole | kNull | kReceiver | \
kSymbol | kUndefined) \
V(Internal, kHole | kExternalPointer | kOtherInternal) \