Chromium Code Reviews| Index: src/compiler/js-typed-lowering.cc | 
| diff --git a/src/compiler/js-typed-lowering.cc b/src/compiler/js-typed-lowering.cc | 
| index 869096232ffac2c1d3d93f1474068f8d308add49..9f1e7eb8914b5ae824a080718fcebee55c70d58a 100644 | 
| --- a/src/compiler/js-typed-lowering.cc | 
| +++ b/src/compiler/js-typed-lowering.cc | 
| @@ -222,14 +222,23 @@ class JSBinopReduction { | 
| Reduction JSTypedLowering::ReduceJSAdd(Node* node) { | 
| JSBinopReduction r(this, node); | 
| - if (r.OneInputIs(Type::String())) { | 
| - r.ConvertInputsToString(); | 
| - return r.ChangeToPureOperator(simplified()->StringAdd()); | 
| + if (r.BothInputsAre(Type::Number())) { | 
| + // JSAdd(x:number, y:number) => NumberAdd(x, y) | 
| + return r.ChangeToPureOperator(simplified()->NumberAdd()); | 
| } | 
| - if (r.NeitherInputCanBe(Type::String())) { | 
| + Type* maybe_string = Type::Union(Type::String(), Type::Receiver(), zone()); | 
| + if (r.NeitherInputCanBe(maybe_string)) { | 
| + // JSAdd(x:-string, y:-string) => NumberAdd(ToNumber(x), ToNumber(y)) | 
| 
 
Michael Starzinger
2014/09/11 14:25:44
I convinced myself that this is correct for ES5, c
 
rossberg
2014/09/11 14:50:19
It seems correct, as long as ToNumber(symbol) thro
 
 | 
| r.ConvertInputsToNumber(); | 
| return r.ChangeToPureOperator(simplified()->NumberAdd()); | 
| } | 
| + if (r.OneInputIs(Type::String())) { | 
| + // JSAdd(x:string, y:string) => StringAdd(x, y) | 
| + // JSAdd(x:string, y) => StringAdd(x, ToString(y)) | 
| + // JSAdd(x, y:string) => StringAdd(ToString(x), y) | 
| + r.ConvertInputsToString(); | 
| + return r.ChangeToPureOperator(simplified()->StringAdd()); | 
| + } | 
| return NoChange(); | 
| } |