OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/compiler/access-builder.h" | 5 #include "src/compiler/access-builder.h" |
6 #include "src/compiler/graph-inl.h" | 6 #include "src/compiler/graph-inl.h" |
7 #include "src/compiler/js-typed-lowering.h" | 7 #include "src/compiler/js-typed-lowering.h" |
8 #include "src/compiler/node-aux-data-inl.h" | 8 #include "src/compiler/node-aux-data-inl.h" |
9 #include "src/compiler/node-properties-inl.h" | 9 #include "src/compiler/node-properties-inl.h" |
10 #include "src/types.h" | 10 #include "src/types.h" |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 if (r.BothInputsAre(Type::Number())) { | 225 if (r.BothInputsAre(Type::Number())) { |
226 // JSAdd(x:number, y:number) => NumberAdd(x, y) | 226 // JSAdd(x:number, y:number) => NumberAdd(x, y) |
227 return r.ChangeToPureOperator(simplified()->NumberAdd()); | 227 return r.ChangeToPureOperator(simplified()->NumberAdd()); |
228 } | 228 } |
229 Type* maybe_string = Type::Union(Type::String(), Type::Receiver(), zone()); | 229 Type* maybe_string = Type::Union(Type::String(), Type::Receiver(), zone()); |
230 if (r.NeitherInputCanBe(maybe_string)) { | 230 if (r.NeitherInputCanBe(maybe_string)) { |
231 // JSAdd(x:-string, y:-string) => NumberAdd(ToNumber(x), ToNumber(y)) | 231 // JSAdd(x:-string, y:-string) => NumberAdd(ToNumber(x), ToNumber(y)) |
232 r.ConvertInputsToNumber(); | 232 r.ConvertInputsToNumber(); |
233 return r.ChangeToPureOperator(simplified()->NumberAdd()); | 233 return r.ChangeToPureOperator(simplified()->NumberAdd()); |
234 } | 234 } |
| 235 #if 0 |
| 236 // TODO(turbofan): Lowering of StringAdd is disabled for now because: |
| 237 // a) The inserted ToString operation screws up valueOf vs. toString order. |
| 238 // b) Deoptimization at ToString doesn't have corresponding bailout id. |
| 239 // c) Our current StringAddStub is actually non-pure and requires context. |
235 if (r.OneInputIs(Type::String())) { | 240 if (r.OneInputIs(Type::String())) { |
236 // JSAdd(x:string, y:string) => StringAdd(x, y) | 241 // JSAdd(x:string, y:string) => StringAdd(x, y) |
237 // JSAdd(x:string, y) => StringAdd(x, ToString(y)) | 242 // JSAdd(x:string, y) => StringAdd(x, ToString(y)) |
238 // JSAdd(x, y:string) => StringAdd(ToString(x), y) | 243 // JSAdd(x, y:string) => StringAdd(ToString(x), y) |
239 r.ConvertInputsToString(); | 244 r.ConvertInputsToString(); |
240 return r.ChangeToPureOperator(simplified()->StringAdd()); | 245 return r.ChangeToPureOperator(simplified()->StringAdd()); |
241 } | 246 } |
| 247 #endif |
242 return NoChange(); | 248 return NoChange(); |
243 } | 249 } |
244 | 250 |
245 | 251 |
246 Reduction JSTypedLowering::ReduceNumberBinop(Node* node, | 252 Reduction JSTypedLowering::ReduceNumberBinop(Node* node, |
247 const Operator* numberOp) { | 253 const Operator* numberOp) { |
248 JSBinopReduction r(this, node); | 254 JSBinopReduction r(this, node); |
249 if (r.OneInputIs(Type::Primitive())) { | 255 if (r.OneInputIs(Type::Primitive())) { |
250 // If at least one input is a primitive, then insert appropriate conversions | 256 // If at least one input is a primitive, then insert appropriate conversions |
251 // to number and reduce this operator to the given numeric one. | 257 // to number and reduce this operator to the given numeric one. |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 return ReduceJSStoreProperty(node); | 674 return ReduceJSStoreProperty(node); |
669 default: | 675 default: |
670 break; | 676 break; |
671 } | 677 } |
672 return NoChange(); | 678 return NoChange(); |
673 } | 679 } |
674 | 680 |
675 } // namespace compiler | 681 } // namespace compiler |
676 } // namespace internal | 682 } // namespace internal |
677 } // namespace v8 | 683 } // namespace v8 |
OLD | NEW |