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/v8.h" | 5 #include "src/v8.h" |
| 6 #include "test/cctest/cctest.h" | 6 #include "test/cctest/cctest.h" |
| 7 | 7 |
| 8 #include "src/compiler/graph-inl.h" | 8 #include "src/compiler/graph-inl.h" |
| 9 #include "src/compiler/js-typed-lowering.h" | 9 #include "src/compiler/js-typed-lowering.h" |
| 10 #include "src/compiler/node-properties-inl.h" | 10 #include "src/compiler/node-properties-inl.h" |
| (...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 750 } | 750 } |
| 751 | 751 |
| 752 | 752 |
| 753 TEST(UnaryNot) { | 753 TEST(UnaryNot) { |
| 754 JSTypedLoweringTester R; | 754 JSTypedLoweringTester R; |
| 755 Operator* opnot = R.javascript.UnaryNot(); | 755 Operator* opnot = R.javascript.UnaryNot(); |
| 756 | 756 |
| 757 for (size_t i = 0; i < arraysize(kJSTypes); i++) { | 757 for (size_t i = 0; i < arraysize(kJSTypes); i++) { |
| 758 Node* r = R.ReduceUnop(opnot, kJSTypes[i]); | 758 Node* r = R.ReduceUnop(opnot, kJSTypes[i]); |
| 759 // TODO(titzer): test will break if/when js-typed-lowering constant folds. | 759 // TODO(titzer): test will break if/when js-typed-lowering constant folds. |
| 760 CHECK_EQ(IrOpcode::kBooleanNot, r->opcode()); | 760 CHECK(IrOpcode::kBooleanNot == r->opcode() || |
| 761 IrOpcode::kJSToBoolean == r->opcode()); | |
|
titzer
2014/08/29 15:49:38
Can you use a value use here?
Michael Starzinger
2014/09/01 10:25:40
Done.
| |
| 761 } | 762 } |
| 762 } | 763 } |
| 763 | 764 |
| 764 | 765 |
| 765 TEST(RemoveToNumberEffects) { | 766 TEST(RemoveToNumberEffects) { |
| 766 JSTypedLoweringTester R; | 767 JSTypedLoweringTester R; |
| 767 | 768 |
| 768 Node* effect_use = NULL; | 769 Node* effect_use = NULL; |
| 769 for (int i = 0; i < 10; i++) { | 770 for (int i = 0; i < 10; i++) { |
| 770 Node* p0 = R.Parameter(Type::Number()); | 771 Node* p0 = R.Parameter(Type::Number()); |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1177 JSTypedLoweringTester R; | 1178 JSTypedLoweringTester R; |
| 1178 Operator* opnot = R.javascript.UnaryNot(); | 1179 Operator* opnot = R.javascript.UnaryNot(); |
| 1179 | 1180 |
| 1180 for (size_t i = 0; i < arraysize(kJSTypes); i++) { | 1181 for (size_t i = 0; i < arraysize(kJSTypes); i++) { |
| 1181 Node* p0 = R.Parameter(kJSTypes[i], 0); | 1182 Node* p0 = R.Parameter(kJSTypes[i], 0); |
| 1182 Node* orig = R.Unop(opnot, p0); | 1183 Node* orig = R.Unop(opnot, p0); |
| 1183 Node* effect_use = R.UseForEffect(orig); | 1184 Node* effect_use = R.UseForEffect(orig); |
| 1184 Node* value_use = R.graph.NewNode(R.common.Return(), orig); | 1185 Node* value_use = R.graph.NewNode(R.common.Return(), orig); |
| 1185 Node* r = R.reduce(orig); | 1186 Node* r = R.reduce(orig); |
| 1186 // TODO(titzer): test will break if/when js-typed-lowering constant folds. | 1187 // TODO(titzer): test will break if/when js-typed-lowering constant folds. |
| 1187 CHECK_EQ(IrOpcode::kBooleanNot, r->opcode()); | 1188 CHECK(IrOpcode::kBooleanNot == r->opcode() || |
| 1189 IrOpcode::kJSToBoolean == r->opcode()); | |
|
titzer
2014/08/29 15:49:38
Can you push this condition down into the branch b
Michael Starzinger
2014/09/01 10:25:40
Done.
| |
| 1190 CHECK_EQ(IrOpcode::kBooleanNot, value_use->InputAt(0)->opcode()); | |
| 1188 | 1191 |
| 1189 CHECK_EQ(r, value_use->InputAt(0)); | 1192 if (r == orig && orig->opcode() == IrOpcode::kJSToBoolean) { |
| 1190 | |
| 1191 if (r->InputAt(0) == orig && orig->opcode() == IrOpcode::kJSToBoolean) { | |
| 1192 // The original node was turned into a ToBoolean, which has an effect. | 1193 // The original node was turned into a ToBoolean, which has an effect. |
| 1193 R.CheckEffectInput(R.start(), orig); | 1194 R.CheckEffectInput(R.start(), orig); |
| 1194 R.CheckEffectInput(orig, effect_use); | 1195 R.CheckEffectInput(orig, effect_use); |
| 1195 } else { | 1196 } else { |
| 1196 // effect should have been removed from this node. | 1197 // effect should have been removed from this node. |
| 1197 R.CheckEffectInput(R.start(), effect_use); | 1198 R.CheckEffectInput(R.start(), effect_use); |
| 1198 } | 1199 } |
| 1199 } | 1200 } |
| 1200 } | 1201 } |
| 1201 | 1202 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1331 CHECK_EQ(p1, r->InputAt(0)); | 1332 CHECK_EQ(p1, r->InputAt(0)); |
| 1332 CHECK_EQ(p0, r->InputAt(1)); | 1333 CHECK_EQ(p0, r->InputAt(1)); |
| 1333 } else { | 1334 } else { |
| 1334 CHECK_EQ(p0, r->InputAt(0)); | 1335 CHECK_EQ(p0, r->InputAt(0)); |
| 1335 CHECK_EQ(p1, r->InputAt(1)); | 1336 CHECK_EQ(p1, r->InputAt(1)); |
| 1336 } | 1337 } |
| 1337 } | 1338 } |
| 1338 } | 1339 } |
| 1339 } | 1340 } |
| 1340 } | 1341 } |
| OLD | NEW |