Reviewers: jarin,
Description:
[turbofan] Lower to ToNumber with actual binary operation whenever possible.
We can lower to ToNumber plus actual binary operation instead of a
generic BinaryOpIC whenever one side is known to be a primitive. The
deoptimization problem can be solved by just reusing the frame state
from the JSBinaryOp node for the JSToNumber node.
[email protected]
Please review this at https://codereview.chromium.org/706863003/
Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+14, -32 lines):
M src/compiler/js-typed-lowering.cc
Index: src/compiler/js-typed-lowering.cc
diff --git a/src/compiler/js-typed-lowering.cc
b/src/compiler/js-typed-lowering.cc
index
970e31394aa93e51730863f665442d535039914f..f902ceeb51af24223b3f562ac739ab306e4cdedf
100644
--- a/src/compiler/js-typed-lowering.cc
+++ b/src/compiler/js-typed-lowering.cc
@@ -228,21 +228,14 @@ Reduction JSTypedLowering::ReduceJSAdd(Node* node) {
return r.ChangeToPureOperator(simplified()->NumberAdd());
}
Type* maybe_string = Type::Union(Type::String(), Type::Receiver(),
zone());
- if (r.BothInputsAre(Type::Primitive()) &&
r.NeitherInputCanBe(maybe_string)) {
+ if (r.OneInputIs(Type::Primitive()) &&
r.NeitherInputCanBe(maybe_string)) {
// JSAdd(x:-string, y:-string) => NumberAdd(ToNumber(x), ToNumber(y))
+ // TODO(jarin): Move frame state from node to the ToNumber conversion
which
+ // can be observable once JSToNumber is supported for lazy
deoptimization.
r.ConvertInputsToNumber();
return r.ChangeToPureOperator(simplified()->NumberAdd());
}
#if 0
- // TODO(turbofan): General ToNumber disabled for now because:
- // a) The inserted ToNumber operation screws up observability of
valueOf.
- // b) Deoptimization at ToNumber doesn't have corresponding bailout id.
- Type* maybe_string = Type::Union(Type::String(), Type::Receiver(),
zone());
- if (r.NeitherInputCanBe(maybe_string)) {
- ...
- }
-#endif
-#if 0
// TODO(turbofan): Lowering of StringAdd is disabled for now because:
// a) The inserted ToString operation screws up valueOf vs. toString
order.
// b) Deoptimization at ToString doesn't have corresponding bailout id.
@@ -262,22 +255,15 @@ Reduction JSTypedLowering::ReduceJSAdd(Node* node) {
Reduction JSTypedLowering::ReduceNumberBinop(Node* node,
const Operator* numberOp) {
JSBinopReduction r(this, node);
- if (r.BothInputsAre(Type::Primitive())) {
- r.ConvertInputsToNumber();
- return r.ChangeToPureOperator(numberOp);
- }
-#if 0
- // TODO(turbofan): General ToNumber disabled for now because:
- // a) The inserted ToNumber operation screws up observability of
valueOf.
- // b) Deoptimization at ToNumber doesn't have corresponding bailout id.
if (r.OneInputIs(Type::Primitive())) {
// If at least one input is a primitive, then insert appropriate
conversions
// to number and reduce this operator to the given numeric one.
// TODO(turbofan): make this heuristic configurable for code size.
+ // TODO(jarin): Move frame state from node to the ToNumber conversion
which
+ // can be observable once JSToNumber is supported for lazy
deoptimization.
r.ConvertInputsToNumber();
return r.ChangeToPureOperator(numberOp);
}
-#endif
// TODO(turbofan): relax/remove the effects of this operator in other
cases.
return NoChange();
}
@@ -287,7 +273,9 @@ Reduction JSTypedLowering::ReduceI32Binop(Node* node,
bool left_signed,
bool right_signed,
const Operator* intOp) {
JSBinopReduction r(this, node);
- if (r.BothInputsAre(Type::Primitive())) {
+ if (r.OneInputIs(Type::Primitive())) {
+ // TODO(jarin): Move frame state from node to the ToNumber conversion
which
+ // can be observable once JSToNumber is supported for lazy
deoptimization.
// TODO(titzer): some Smi bitwise operations don't really require going
// all the way to int32, which can save tagging/untagging for some
// operations
@@ -303,7 +291,9 @@ Reduction JSTypedLowering::ReduceI32Binop(Node* node,
bool left_signed,
Reduction JSTypedLowering::ReduceI32Shift(Node* node, bool left_signed,
const Operator* shift_op) {
JSBinopReduction r(this, node);
- if (r.BothInputsAre(Type::Primitive())) {
+ if (r.OneInputIs(Type::Primitive())) {
+ // TODO(jarin): Move frame state from node to the ToNumber conversion
which
+ // can be observable once JSToNumber is supported for lazy
deoptimization.
r.ConvertInputsForShift(left_signed);
return r.ChangeToPureOperator(shift_op);
}
@@ -336,18 +326,10 @@ Reduction JSTypedLowering::ReduceJSComparison(Node*
node) {
}
return r.ChangeToPureOperator(stringOp);
}
-#if 0
- // TODO(turbofan): General ToNumber disabled for now because:
- // a) The inserted ToNumber operation screws up observability of
valueOf.
- // b) Deoptimization at ToNumber doesn't have corresponding bailout id.
- Type* maybe_string = Type::Union(Type::String(), Type::Receiver(),
zone());
- if (r.OneInputCannotBe(maybe_string)) {
- // If one input cannot be a string, then emit a number comparison.
- ...
- }
-#endif
Type* maybe_string = Type::Union(Type::String(), Type::Receiver(),
zone());
- if (r.BothInputsAre(Type::Primitive()) &&
r.OneInputCannotBe(maybe_string)) {
+ if (r.OneInputIs(Type::Primitive()) && r.OneInputCannotBe(maybe_string))
{
+ // TODO(jarin): Move frame state from node to the ToNumber conversion
which
+ // can be observable once JSToNumber is supported for lazy
deoptimization.
const Operator* less_than;
const Operator* less_than_or_equal;
if (r.BothInputsAre(Type::Unsigned32())) {
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.