Commit 39db77c6 authored by Ross McIlroy's avatar Ross McIlroy Committed by Commit Bot

[TurboFan] Add ObjectIsSymbol simplified operator.

Used by ReduceJSEqualTypeOf, and will also be used to lower a new 
TestTypeof bytecode in a followup CL.

BUG=v8:5267

Change-Id: I990aa6ac8ac0b9bd01080dda1764c5bfe3a4d7cf
Reviewed-on: https://chromium-review.googlesource.com/454797Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Ross McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#43802}
parent 09369c5e
......@@ -741,6 +741,9 @@ bool EffectControlLinearizer::TryWireInStateEffect(Node* node,
case IrOpcode::kObjectIsString:
result = LowerObjectIsString(node);
break;
case IrOpcode::kObjectIsSymbol:
result = LowerObjectIsSymbol(node);
break;
case IrOpcode::kObjectIsUndetectable:
result = LowerObjectIsUndetectable(node);
break;
......@@ -1890,6 +1893,28 @@ Node* EffectControlLinearizer::LowerObjectIsString(Node* node) {
return done.PhiAt(0);
}
Node* EffectControlLinearizer::LowerObjectIsSymbol(Node* node) {
Node* value = node->InputAt(0);
auto if_smi = __ MakeDeferredLabel<1>();
auto done = __ MakeLabel<2>(MachineRepresentation::kBit);
Node* check = ObjectIsSmi(value);
__ GotoIf(check, &if_smi);
Node* value_map = __ LoadField(AccessBuilder::ForMap(), value);
Node* value_instance_type =
__ LoadField(AccessBuilder::ForMapInstanceType(), value_map);
Node* vfalse =
__ Word32Equal(value_instance_type, __ Uint32Constant(SYMBOL_TYPE));
__ Goto(&done, vfalse);
__ Bind(&if_smi);
__ Goto(&done, __ Int32Constant(0));
__ Bind(&done);
return done.PhiAt(0);
}
Node* EffectControlLinearizer::LowerObjectIsUndetectable(Node* node) {
Node* value = node->InputAt(0);
......
......@@ -88,6 +88,7 @@ class V8_EXPORT_PRIVATE EffectControlLinearizer {
Node* LowerObjectIsReceiver(Node* node);
Node* LowerObjectIsSmi(Node* node);
Node* LowerObjectIsString(Node* node);
Node* LowerObjectIsSymbol(Node* node);
Node* LowerObjectIsUndetectable(Node* node);
Node* LowerArgumentsFrame(Node* node);
Node* LowerArgumentsLength(Node* node);
......
......@@ -845,6 +845,7 @@ bool EscapeStatusAnalysis::CheckUsesForEscape(Node* uses, Node* rep,
case IrOpcode::kObjectIsNumber:
case IrOpcode::kObjectIsReceiver:
case IrOpcode::kObjectIsString:
case IrOpcode::kObjectIsSymbol:
case IrOpcode::kObjectIsUndetectable:
if (SetEscaped(rep)) {
TRACE("Setting #%d (%s) to escaped because of use by #%d (%s)\n",
......
......@@ -889,6 +889,8 @@ Reduction JSTypedLowering::ReduceJSEqualTypeOf(Node* node) {
jsgraph()->NullConstant()));
} else if (String::Equals(type, factory()->string_string())) {
value = graph()->NewNode(simplified()->ObjectIsString(), input);
} else if (String::Equals(type, factory()->symbol_string())) {
value = graph()->NewNode(simplified()->ObjectIsSymbol(), input);
} else if (String::Equals(type, factory()->undefined_string())) {
value = graph()->NewNode(
common()->Select(MachineRepresentation::kTagged),
......
......@@ -339,6 +339,7 @@
V(ObjectIsReceiver) \
V(ObjectIsSmi) \
V(ObjectIsString) \
V(ObjectIsSymbol) \
V(ObjectIsUndetectable) \
V(ArgumentsFrame) \
V(ArgumentsLength) \
......
......@@ -2620,6 +2620,10 @@ class RepresentationSelector {
VisitObjectIs(node, Type::String(), lowering);
return;
}
case IrOpcode::kObjectIsSymbol: {
VisitObjectIs(node, Type::Symbol(), lowering);
return;
}
case IrOpcode::kObjectIsUndetectable: {
VisitObjectIs(node, Type::Undetectable(), lowering);
return;
......
......@@ -482,6 +482,7 @@ UnicodeEncoding UnicodeEncodingOf(const Operator* op) {
V(ObjectIsReceiver, Operator::kNoProperties, 1, 0) \
V(ObjectIsSmi, Operator::kNoProperties, 1, 0) \
V(ObjectIsString, Operator::kNoProperties, 1, 0) \
V(ObjectIsSymbol, Operator::kNoProperties, 1, 0) \
V(ObjectIsUndetectable, Operator::kNoProperties, 1, 0) \
V(ConvertTaggedHoleToUndefined, Operator::kNoProperties, 1, 0) \
V(ReferenceEqual, Operator::kCommutative, 2, 0) \
......
......@@ -420,6 +420,7 @@ class V8_EXPORT_PRIVATE SimplifiedOperatorBuilder final
const Operator* ObjectIsReceiver();
const Operator* ObjectIsSmi();
const Operator* ObjectIsString();
const Operator* ObjectIsSymbol();
const Operator* ObjectIsUndetectable();
const Operator* ArgumentsFrame();
......
......@@ -290,6 +290,7 @@ class Typer::Visitor : public Reducer {
static Type* ObjectIsReceiver(Type*, Typer*);
static Type* ObjectIsSmi(Type*, Typer*);
static Type* ObjectIsString(Type*, Typer*);
static Type* ObjectIsSymbol(Type*, Typer*);
static Type* ObjectIsUndetectable(Type*, Typer*);
static ComparisonOutcome JSCompareTyper(Type*, Type*, Typer*);
......@@ -540,6 +541,12 @@ Type* Typer::Visitor::ObjectIsString(Type* type, Typer* t) {
return Type::Boolean();
}
Type* Typer::Visitor::ObjectIsSymbol(Type* type, Typer* t) {
if (type->Is(Type::Symbol())) return t->singleton_true_;
if (!type->Maybe(Type::Symbol())) return t->singleton_false_;
return Type::Boolean();
}
Type* Typer::Visitor::ObjectIsUndetectable(Type* type, Typer* t) {
if (type->Is(Type::Undetectable())) return t->singleton_true_;
if (!type->Maybe(Type::Undetectable())) return t->singleton_false_;
......@@ -1943,6 +1950,10 @@ Type* Typer::Visitor::TypeObjectIsString(Node* node) {
return TypeUnaryOp(node, ObjectIsString);
}
Type* Typer::Visitor::TypeObjectIsSymbol(Node* node) {
return TypeUnaryOp(node, ObjectIsSymbol);
}
Type* Typer::Visitor::TypeObjectIsUndetectable(Node* node) {
return TypeUnaryOp(node, ObjectIsUndetectable);
}
......
......@@ -959,6 +959,7 @@ void Verifier::Visitor::Check(Node* node) {
case IrOpcode::kObjectIsReceiver:
case IrOpcode::kObjectIsSmi:
case IrOpcode::kObjectIsString:
case IrOpcode::kObjectIsSymbol:
case IrOpcode::kObjectIsUndetectable:
case IrOpcode::kArrayBufferWasNeutered:
CheckValueInputIs(node, 0, Type::Any());
......
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