Chromium Code Reviews| 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/code-factory.h" | 5 #include "src/code-factory.h" |
| 6 #include "src/compiler/access-builder.h" | 6 #include "src/compiler/access-builder.h" |
| 7 #include "src/compiler/js-graph.h" | 7 #include "src/compiler/js-graph.h" |
| 8 #include "src/compiler/js-typed-lowering.h" | 8 #include "src/compiler/js-typed-lowering.h" |
| 9 #include "src/compiler/linkage.h" | 9 #include "src/compiler/linkage.h" |
| 10 #include "src/compiler/node-matchers.h" | 10 #include "src/compiler/node-matchers.h" |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 215 } | 215 } |
| 216 return lowering_->Changed(node_); | 216 return lowering_->Changed(node_); |
| 217 } | 217 } |
| 218 | 218 |
| 219 Reduction ChangeToPureOperator(const Operator* op, Type* type) { | 219 Reduction ChangeToPureOperator(const Operator* op, Type* type) { |
| 220 return ChangeToPureOperator(op, false, type); | 220 return ChangeToPureOperator(op, false, type); |
| 221 } | 221 } |
| 222 | 222 |
| 223 bool IsStrong() { return is_strong(OpParameter<LanguageMode>(node_)); } | 223 bool IsStrong() { return is_strong(OpParameter<LanguageMode>(node_)); } |
| 224 | 224 |
| 225 bool OneInputIs(Type* t) { return left_type()->Is(t) || right_type()->Is(t); } | 225 bool LeftInputIs(Type* t) { return left_type()->Is(t); } |
| 226 | 226 |
| 227 bool BothInputsAre(Type* t) { | 227 bool RightInputIs(Type* t) { return right_type()->Is(t); } |
| 228 return left_type()->Is(t) && right_type()->Is(t); | 228 |
| 229 } | 229 bool OneInputIs(Type* t) { return LeftInputIs(t) || RightInputIs(t); } |
| 230 | |
| 231 bool BothInputsAre(Type* t) { return LeftInputIs(t) && RightInputIs(t); } | |
| 230 | 232 |
| 231 bool OneInputCannotBe(Type* t) { | 233 bool OneInputCannotBe(Type* t) { |
| 232 return !left_type()->Maybe(t) || !right_type()->Maybe(t); | 234 return !left_type()->Maybe(t) || !right_type()->Maybe(t); |
| 233 } | 235 } |
| 234 | 236 |
| 235 bool NeitherInputCanBe(Type* t) { | 237 bool NeitherInputCanBe(Type* t) { |
| 236 return !left_type()->Maybe(t) && !right_type()->Maybe(t); | 238 return !left_type()->Maybe(t) && !right_type()->Maybe(t); |
| 237 } | 239 } |
| 238 | 240 |
| 239 Node* effect() { return NodeProperties::GetEffectInput(node_); } | 241 Node* effect() { return NodeProperties::GetEffectInput(node_); } |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 597 invert); | 599 invert); |
| 598 } | 600 } |
| 599 if (r.BothInputsAre(Type::Boolean())) { | 601 if (r.BothInputsAre(Type::Boolean())) { |
| 600 return r.ChangeToPureOperator(simplified()->ReferenceEqual(Type::Boolean()), | 602 return r.ChangeToPureOperator(simplified()->ReferenceEqual(Type::Boolean()), |
| 601 invert); | 603 invert); |
| 602 } | 604 } |
| 603 if (r.BothInputsAre(Type::Receiver())) { | 605 if (r.BothInputsAre(Type::Receiver())) { |
| 604 return r.ChangeToPureOperator( | 606 return r.ChangeToPureOperator( |
| 605 simplified()->ReferenceEqual(Type::Receiver()), invert); | 607 simplified()->ReferenceEqual(Type::Receiver()), invert); |
| 606 } | 608 } |
| 607 // TODO(turbofan): js-typed-lowering of Equal(undefined) | 609 if (r.OneInputIs(Type::NullOrUndefined())) { |
| 608 // TODO(turbofan): js-typed-lowering of Equal(null) | 610 Callable const callable = CodeFactory::CompareNilIC(isolate(), kNullValue); |
| 611 CallDescriptor const* const desc = Linkage::GetStubCallDescriptor( | |
| 612 isolate(), graph()->zone(), callable.descriptor(), 0, | |
| 613 CallDescriptor::kNeedsFrameState, node->op()->properties()); | |
| 614 node->RemoveInput(r.LeftInputIs(Type::NullOrUndefined()) ? 0 : 1); | |
| 615 node->InsertInput(graph()->zone(), 0, | |
| 616 jsgraph()->HeapConstant(callable.code())); | |
| 617 NodeProperties::ChangeOp(node, common()->Call(desc)); | |
| 618 if (invert) { | |
| 619 // Insert an boolean not to invert the value. | |
| 620 Node* value = graph()->NewNode(simplified()->BooleanNot(), node); | |
| 621 node->ReplaceUses(value); | |
| 622 // Note: ReplaceUses() smashes all uses, so smash it back here. | |
| 623 value->ReplaceInput(0, node); | |
|
Jarin
2015/10/27 11:00:00
This whole input/use massaging business is really
| |
| 624 return Replace(value); | |
| 625 } | |
| 626 return Changed(node); | |
| 627 } | |
| 609 return NoChange(); | 628 return NoChange(); |
| 610 } | 629 } |
| 611 | 630 |
| 612 | 631 |
| 613 Reduction JSTypedLowering::ReduceJSStrictEqual(Node* node, bool invert) { | 632 Reduction JSTypedLowering::ReduceJSStrictEqual(Node* node, bool invert) { |
| 614 JSBinopReduction r(this, node); | 633 JSBinopReduction r(this, node); |
| 615 if (r.left() == r.right()) { | 634 if (r.left() == r.right()) { |
| 616 // x === x is always true if x != NaN | 635 // x === x is always true if x != NaN |
| 617 if (!r.left_type()->Maybe(Type::NaN())) { | 636 if (!r.left_type()->Maybe(Type::NaN())) { |
| 618 Node* replacement = jsgraph()->BooleanConstant(!invert); | 637 Node* replacement = jsgraph()->BooleanConstant(!invert); |
| (...skipping 1302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1921 } | 1940 } |
| 1922 | 1941 |
| 1923 | 1942 |
| 1924 MachineOperatorBuilder* JSTypedLowering::machine() const { | 1943 MachineOperatorBuilder* JSTypedLowering::machine() const { |
| 1925 return jsgraph()->machine(); | 1944 return jsgraph()->machine(); |
| 1926 } | 1945 } |
| 1927 | 1946 |
| 1928 } // namespace compiler | 1947 } // namespace compiler |
| 1929 } // namespace internal | 1948 } // namespace internal |
| 1930 } // namespace v8 | 1949 } // namespace v8 |
| OLD | NEW |