| 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/compilation-dependencies.h" | 5 #include "src/compilation-dependencies.h" |
| 6 #include "src/compiler/js-graph.h" | 6 #include "src/compiler/js-graph.h" |
| 7 #include "src/compiler/js-typed-lowering.h" | 7 #include "src/compiler/js-typed-lowering.h" |
| 8 #include "src/compiler/machine-operator.h" | 8 #include "src/compiler/machine-operator.h" |
| 9 #include "src/compiler/node-properties.h" | 9 #include "src/compiler/node-properties.h" |
| 10 #include "src/compiler/opcodes.h" | 10 #include "src/compiler/opcodes.h" |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 if (OperatorProperties::GetFrameStateInputCount(op) > 0) { | 156 if (OperatorProperties::GetFrameStateInputCount(op) > 0) { |
| 157 CHECK_EQ(1, OperatorProperties::GetFrameStateInputCount(op)); | 157 CHECK_EQ(1, OperatorProperties::GetFrameStateInputCount(op)); |
| 158 return graph.NewNode(op, input, context(), EmptyFrameState(context()), | 158 return graph.NewNode(op, input, context(), EmptyFrameState(context()), |
| 159 start(), control()); | 159 start(), control()); |
| 160 } else { | 160 } else { |
| 161 return graph.NewNode(op, input, context(), start(), control()); | 161 return graph.NewNode(op, input, context(), start(), control()); |
| 162 } | 162 } |
| 163 } | 163 } |
| 164 | 164 |
| 165 Node* UseForEffect(Node* node) { | 165 Node* UseForEffect(Node* node) { |
| 166 // TODO(titzer): use EffectPhi after fixing EffectCount | 166 Node* merge = graph.NewNode(common.Merge(1), start()); |
| 167 if (OperatorProperties::GetFrameStateInputCount(javascript.ToNumber()) > | 167 return graph.NewNode(common.EffectPhi(1), node, merge); |
| 168 0) { | |
| 169 CHECK_EQ(1, OperatorProperties::GetFrameStateInputCount( | |
| 170 javascript.ToNumber())); | |
| 171 return graph.NewNode(javascript.ToNumber(), node, context(), | |
| 172 EmptyFrameState(context()), node, control()); | |
| 173 } else { | |
| 174 return graph.NewNode(javascript.ToNumber(), node, context(), node, | |
| 175 control()); | |
| 176 } | |
| 177 } | 168 } |
| 178 | 169 |
| 179 void CheckEffectInput(Node* effect, Node* use) { | 170 void CheckEffectInput(Node* effect, Node* use) { |
| 180 CHECK_EQ(effect, NodeProperties::GetEffectInput(use)); | 171 CHECK_EQ(effect, NodeProperties::GetEffectInput(use)); |
| 181 } | 172 } |
| 182 | 173 |
| 183 void CheckInt32Constant(int32_t expected, Node* result) { | 174 void CheckInt32Constant(int32_t expected, Node* result) { |
| 184 CHECK_EQ(IrOpcode::kInt32Constant, result->opcode()); | 175 CHECK_EQ(IrOpcode::kInt32Constant, result->opcode()); |
| 185 CHECK_EQ(expected, OpParameter<int32_t>(result)); | 176 CHECK_EQ(expected, OpParameter<int32_t>(result)); |
| 186 } | 177 } |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 R.CheckHandle(R.isolate->factory()->null_string(), r); | 542 R.CheckHandle(R.isolate->factory()->null_string(), r); |
| 552 } | 543 } |
| 553 | 544 |
| 554 { // ToString(boolean) | 545 { // ToString(boolean) |
| 555 Node* r = R.ReduceUnop(op, Type::Boolean()); | 546 Node* r = R.ReduceUnop(op, Type::Boolean()); |
| 556 CHECK_EQ(IrOpcode::kSelect, r->opcode()); | 547 CHECK_EQ(IrOpcode::kSelect, r->opcode()); |
| 557 } | 548 } |
| 558 | 549 |
| 559 { // ToString(number) | 550 { // ToString(number) |
| 560 Node* r = R.ReduceUnop(op, Type::Number()); | 551 Node* r = R.ReduceUnop(op, Type::Number()); |
| 561 // TODO(titzer): could remove effects | |
| 562 CHECK_EQ(IrOpcode::kJSToString, r->opcode()); | 552 CHECK_EQ(IrOpcode::kJSToString, r->opcode()); |
| 563 } | 553 } |
| 564 | 554 |
| 565 { // ToString(string) | 555 { // ToString(string) |
| 566 Node* r = R.ReduceUnop(op, Type::String()); | 556 Node* r = R.ReduceUnop(op, Type::String()); |
| 567 CHECK_EQ(IrOpcode::kParameter, r->opcode()); // No-op | 557 CHECK_EQ(IrOpcode::kParameter, r->opcode()); // No-op |
| 568 } | 558 } |
| 569 | 559 |
| 570 { // ToString(object) | 560 { // ToString(object) |
| 571 Node* r = R.ReduceUnop(op, Type::Object()); | 561 Node* r = R.ReduceUnop(op, Type::Object()); |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 889 JSTypedLoweringTester R; | 879 JSTypedLoweringTester R; |
| 890 | 880 |
| 891 Type* types[] = {Type::Undefined(), Type::Null(), Type::Boolean(), | 881 Type* types[] = {Type::Undefined(), Type::Null(), Type::Boolean(), |
| 892 Type::Object(), Type::Receiver()}; | 882 Type::Object(), Type::Receiver()}; |
| 893 | 883 |
| 894 Node* p0 = R.Parameter(Type::Any()); | 884 Node* p0 = R.Parameter(Type::Any()); |
| 895 for (size_t i = 0; i < arraysize(types); i++) { | 885 for (size_t i = 0; i < arraysize(types); i++) { |
| 896 Node* p1 = R.Parameter(types[i]); | 886 Node* p1 = R.Parameter(types[i]); |
| 897 CheckEqualityReduction(&R, true, p0, p1, IrOpcode::kReferenceEqual); | 887 CheckEqualityReduction(&R, true, p0, p1, IrOpcode::kReferenceEqual); |
| 898 } | 888 } |
| 899 // TODO(titzer): Equal(RefEqualTypes) | |
| 900 } | 889 } |
| 901 | 890 |
| 891 TEST(StrictEqualityForUnique) { |
| 892 JSTypedLoweringTester R; |
| 893 |
| 894 Node* p0 = R.Parameter(Type::Unique()); |
| 895 Node* p1 = R.Parameter(Type::Unique()); |
| 896 CheckEqualityReduction(&R, true, p0, p1, IrOpcode::kReferenceEqual); |
| 897 CheckEqualityReduction(&R, true, p1, p0, IrOpcode::kReferenceEqual); |
| 898 } |
| 902 | 899 |
| 903 TEST(StringEquality) { | 900 TEST(StringEquality) { |
| 904 JSTypedLoweringTester R; | 901 JSTypedLoweringTester R; |
| 905 Node* p0 = R.Parameter(Type::String()); | 902 Node* p0 = R.Parameter(Type::String()); |
| 906 Node* p1 = R.Parameter(Type::String()); | 903 Node* p1 = R.Parameter(Type::String()); |
| 907 | 904 |
| 908 CheckEqualityReduction(&R, true, p0, p1, IrOpcode::kStringEqual); | 905 CheckEqualityReduction(&R, true, p0, p1, IrOpcode::kStringEqual); |
| 909 CheckEqualityReduction(&R, false, p0, p1, IrOpcode::kStringEqual); | 906 CheckEqualityReduction(&R, false, p0, p1, IrOpcode::kStringEqual); |
| 910 } | 907 } |
| 911 | 908 |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1276 CHECK_EQ(p1, r->InputAt(1)); | 1273 CHECK_EQ(p1, r->InputAt(1)); |
| 1277 } | 1274 } |
| 1278 } | 1275 } |
| 1279 } | 1276 } |
| 1280 } | 1277 } |
| 1281 } | 1278 } |
| 1282 | 1279 |
| 1283 } // namespace compiler | 1280 } // namespace compiler |
| 1284 } // namespace internal | 1281 } // namespace internal |
| 1285 } // namespace v8 | 1282 } // namespace v8 |
| OLD | NEW |