Commit 9f292086 authored by bmeurer's avatar bmeurer Committed by Commit bot

[turbofan] Add PlainPrimitiveToNumber simplified operator.

TEST=unittests

Review URL: https://codereview.chromium.org/845333002

Cr-Commit-Position: refs/heads/master@{#26038}
parent c09b26d1
...@@ -148,6 +148,7 @@ ...@@ -148,6 +148,7 @@
V(NumberModulus) \ V(NumberModulus) \
V(NumberToInt32) \ V(NumberToInt32) \
V(NumberToUint32) \ V(NumberToUint32) \
V(PlainPrimitiveToNumber) \
V(ReferenceEqual) \ V(ReferenceEqual) \
V(StringEqual) \ V(StringEqual) \
V(StringLessThan) \ V(StringLessThan) \
......
...@@ -745,6 +745,22 @@ class RepresentationSelector { ...@@ -745,6 +745,22 @@ class RepresentationSelector {
} }
break; break;
} }
case IrOpcode::kPlainPrimitiveToNumber: {
VisitUnop(node, kMachAnyTagged, kTypeNumber | kRepTagged);
if (lower()) {
// PlainPrimitiveToNumber(x) => Call(ToNumberStub, x, no-context)
Operator::Properties properties = node->op()->properties();
Callable callable = CodeFactory::ToNumber(jsgraph_->isolate());
CallDescriptor::Flags flags = CallDescriptor::kNoFlags;
CallDescriptor* desc = Linkage::GetStubCallDescriptor(
callable.descriptor(), 0, flags, properties, jsgraph_->zone());
node->set_op(jsgraph_->common()->Call(desc));
node->InsertInput(jsgraph_->zone(), 0,
+jsgraph_->HeapConstant(callable.code()));
node->AppendInput(jsgraph_->zone(), jsgraph_->NoContextConstant());
}
break;
}
case IrOpcode::kReferenceEqual: { case IrOpcode::kReferenceEqual: {
VisitBinop(node, kMachAnyTagged, kRepBit); VisitBinop(node, kMachAnyTagged, kRepBit);
if (lower()) node->set_op(lowering->machine()->WordEqual()); if (lower()) node->set_op(lowering->machine()->WordEqual());
......
...@@ -157,35 +157,36 @@ const ElementAccess& ElementAccessOf(const Operator* op) { ...@@ -157,35 +157,36 @@ const ElementAccess& ElementAccessOf(const Operator* op) {
} }
#define PURE_OP_LIST(V) \ #define PURE_OP_LIST(V) \
V(AnyToBoolean, Operator::kNoProperties, 1) \ V(AnyToBoolean, Operator::kNoProperties, 1) \
V(BooleanNot, Operator::kNoProperties, 1) \ V(BooleanNot, Operator::kNoProperties, 1) \
V(BooleanToNumber, Operator::kNoProperties, 1) \ V(BooleanToNumber, Operator::kNoProperties, 1) \
V(NumberEqual, Operator::kCommutative, 2) \ V(NumberEqual, Operator::kCommutative, 2) \
V(NumberLessThan, Operator::kNoProperties, 2) \ V(NumberLessThan, Operator::kNoProperties, 2) \
V(NumberLessThanOrEqual, Operator::kNoProperties, 2) \ V(NumberLessThanOrEqual, Operator::kNoProperties, 2) \
V(NumberAdd, Operator::kCommutative, 2) \ V(NumberAdd, Operator::kCommutative, 2) \
V(NumberSubtract, Operator::kNoProperties, 2) \ V(NumberSubtract, Operator::kNoProperties, 2) \
V(NumberMultiply, Operator::kCommutative, 2) \ V(NumberMultiply, Operator::kCommutative, 2) \
V(NumberDivide, Operator::kNoProperties, 2) \ V(NumberDivide, Operator::kNoProperties, 2) \
V(NumberModulus, Operator::kNoProperties, 2) \ V(NumberModulus, Operator::kNoProperties, 2) \
V(NumberToInt32, Operator::kNoProperties, 1) \ V(NumberToInt32, Operator::kNoProperties, 1) \
V(NumberToUint32, Operator::kNoProperties, 1) \ V(NumberToUint32, Operator::kNoProperties, 1) \
V(StringEqual, Operator::kCommutative, 2) \ V(PlainPrimitiveToNumber, Operator::kNoProperties, 1) \
V(StringLessThan, Operator::kNoProperties, 2) \ V(StringEqual, Operator::kCommutative, 2) \
V(StringLessThanOrEqual, Operator::kNoProperties, 2) \ V(StringLessThan, Operator::kNoProperties, 2) \
V(StringAdd, Operator::kNoProperties, 2) \ V(StringLessThanOrEqual, Operator::kNoProperties, 2) \
V(ChangeTaggedToInt32, Operator::kNoProperties, 1) \ V(StringAdd, Operator::kNoProperties, 2) \
V(ChangeTaggedToUint32, Operator::kNoProperties, 1) \ V(ChangeTaggedToInt32, Operator::kNoProperties, 1) \
V(ChangeTaggedToFloat64, Operator::kNoProperties, 1) \ V(ChangeTaggedToUint32, Operator::kNoProperties, 1) \
V(ChangeInt32ToTagged, Operator::kNoProperties, 1) \ V(ChangeTaggedToFloat64, Operator::kNoProperties, 1) \
V(ChangeUint32ToTagged, Operator::kNoProperties, 1) \ V(ChangeInt32ToTagged, Operator::kNoProperties, 1) \
V(ChangeFloat64ToTagged, Operator::kNoProperties, 1) \ V(ChangeUint32ToTagged, Operator::kNoProperties, 1) \
V(ChangeBitToBool, Operator::kNoProperties, 1) \ V(ChangeFloat64ToTagged, Operator::kNoProperties, 1) \
V(ChangeBoolToBit, Operator::kNoProperties, 1) \ V(ChangeBitToBool, Operator::kNoProperties, 1) \
V(ChangeWord32ToBit, Operator::kNoProperties, 1) \ V(ChangeBoolToBit, Operator::kNoProperties, 1) \
V(ChangeWord64ToBit, Operator::kNoProperties, 1) \ V(ChangeWord32ToBit, Operator::kNoProperties, 1) \
V(ObjectIsSmi, Operator::kNoProperties, 1) \ V(ChangeWord64ToBit, Operator::kNoProperties, 1) \
V(ObjectIsSmi, Operator::kNoProperties, 1) \
V(ObjectIsNonNegativeSmi, Operator::kNoProperties, 1) V(ObjectIsNonNegativeSmi, Operator::kNoProperties, 1)
......
...@@ -144,6 +144,8 @@ class SimplifiedOperatorBuilder FINAL { ...@@ -144,6 +144,8 @@ class SimplifiedOperatorBuilder FINAL {
const Operator* NumberToInt32(); const Operator* NumberToInt32();
const Operator* NumberToUint32(); const Operator* NumberToUint32();
const Operator* PlainPrimitiveToNumber();
const Operator* ReferenceEqual(Type* type); const Operator* ReferenceEqual(Type* type);
const Operator* StringEqual(); const Operator* StringEqual();
......
...@@ -1462,7 +1462,7 @@ Bounds Typer::Visitor::TypeBooleanNot(Node* node) { ...@@ -1462,7 +1462,7 @@ Bounds Typer::Visitor::TypeBooleanNot(Node* node) {
Bounds Typer::Visitor::TypeBooleanToNumber(Node* node) { Bounds Typer::Visitor::TypeBooleanToNumber(Node* node) {
return Bounds(Type::None(zone()), typer_->zero_or_one); return TypeUnaryOp(node, ToNumber);
} }
...@@ -1516,6 +1516,11 @@ Bounds Typer::Visitor::TypeNumberToUint32(Node* node) { ...@@ -1516,6 +1516,11 @@ Bounds Typer::Visitor::TypeNumberToUint32(Node* node) {
} }
Bounds Typer::Visitor::TypePlainPrimitiveToNumber(Node* node) {
return TypeUnaryOp(node, ToNumber);
}
Bounds Typer::Visitor::TypeReferenceEqual(Node* node) { Bounds Typer::Visitor::TypeReferenceEqual(Node* node) {
return Bounds(Type::None(zone()), Type::Boolean(zone())); return Bounds(Type::None(zone()), Type::Boolean(zone()));
} }
......
...@@ -540,6 +540,11 @@ void Verifier::Visitor::Pre(Node* node) { ...@@ -540,6 +540,11 @@ void Verifier::Visitor::Pre(Node* node) {
CheckValueInputIs(node, 0, Type::Number()); CheckValueInputIs(node, 0, Type::Number());
CheckUpperIs(node, Type::Unsigned32()); CheckUpperIs(node, Type::Unsigned32());
break; break;
case IrOpcode::kPlainPrimitiveToNumber:
// PlainPrimitive -> Number
CheckValueInputIs(node, 0, Type::PlainPrimitive());
CheckUpperIs(node, Type::Number());
break;
case IrOpcode::kStringEqual: case IrOpcode::kStringEqual:
case IrOpcode::kStringLessThan: case IrOpcode::kStringLessThan:
case IrOpcode::kStringLessThanOrEqual: case IrOpcode::kStringLessThanOrEqual:
......
...@@ -51,6 +51,7 @@ const PureOperator kPureOperators[] = { ...@@ -51,6 +51,7 @@ const PureOperator kPureOperators[] = {
PURE(NumberModulus, Operator::kNoProperties, 2), PURE(NumberModulus, Operator::kNoProperties, 2),
PURE(NumberToInt32, Operator::kNoProperties, 1), PURE(NumberToInt32, Operator::kNoProperties, 1),
PURE(NumberToUint32, Operator::kNoProperties, 1), PURE(NumberToUint32, Operator::kNoProperties, 1),
PURE(PlainPrimitiveToNumber, Operator::kNoProperties, 1),
PURE(StringEqual, Operator::kCommutative, 2), PURE(StringEqual, Operator::kCommutative, 2),
PURE(StringLessThan, Operator::kNoProperties, 2), PURE(StringLessThan, Operator::kNoProperties, 2),
PURE(StringLessThanOrEqual, Operator::kNoProperties, 2), PURE(StringLessThanOrEqual, Operator::kNoProperties, 2),
......
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