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 30 matching lines...) Expand all Loading... |
41 Graph graph; | 41 Graph graph; |
42 Typer typer; | 42 Typer typer; |
43 Node* context_node; | 43 Node* context_node; |
44 | 44 |
45 Node* Parameter(Type* t, int32_t index = 0) { | 45 Node* Parameter(Type* t, int32_t index = 0) { |
46 Node* n = graph.NewNode(common.Parameter(index), graph.start()); | 46 Node* n = graph.NewNode(common.Parameter(index), graph.start()); |
47 NodeProperties::SetBounds(n, Bounds(Type::None(), t)); | 47 NodeProperties::SetBounds(n, Bounds(Type::None(), t)); |
48 return n; | 48 return n; |
49 } | 49 } |
50 | 50 |
| 51 Node* UndefinedConstant() { |
| 52 Unique<Object> unique = |
| 53 Unique<Object>::CreateImmovable(isolate->factory()->undefined_value()); |
| 54 return graph.NewNode(common.HeapConstant(unique)); |
| 55 } |
| 56 |
| 57 Node* EmptyFrameState(Node* context) { |
| 58 Node* parameters = graph.NewNode(common.StateValues(0)); |
| 59 Node* locals = graph.NewNode(common.StateValues(0)); |
| 60 Node* stack = graph.NewNode(common.StateValues(0)); |
| 61 |
| 62 Node* state_node = |
| 63 graph.NewNode(common.FrameState(BailoutId(0), kIgnoreOutput), |
| 64 parameters, locals, stack, context, UndefinedConstant()); |
| 65 |
| 66 return state_node; |
| 67 } |
| 68 |
51 Node* reduce(Node* node) { | 69 Node* reduce(Node* node) { |
52 JSGraph jsgraph(&graph, &common, &javascript, &typer, &machine); | 70 JSGraph jsgraph(&graph, &common, &javascript, &typer, &machine); |
53 JSTypedLowering reducer(&jsgraph); | 71 JSTypedLowering reducer(&jsgraph); |
54 Reduction reduction = reducer.Reduce(node); | 72 Reduction reduction = reducer.Reduce(node); |
55 if (reduction.Changed()) return reduction.replacement(); | 73 if (reduction.Changed()) return reduction.replacement(); |
56 return node; | 74 return node; |
57 } | 75 } |
58 | 76 |
59 Node* start() { return graph.start(); } | 77 Node* start() { return graph.start(); } |
60 | 78 |
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
768 // The original node was turned into a ToBoolean. | 786 // The original node was turned into a ToBoolean. |
769 CHECK_EQ(IrOpcode::kJSToBoolean, r->opcode()); | 787 CHECK_EQ(IrOpcode::kJSToBoolean, r->opcode()); |
770 } else { | 788 } else { |
771 CHECK_EQ(IrOpcode::kBooleanNot, r->opcode()); | 789 CHECK_EQ(IrOpcode::kBooleanNot, r->opcode()); |
772 } | 790 } |
773 } | 791 } |
774 } | 792 } |
775 | 793 |
776 | 794 |
777 TEST(RemoveToNumberEffects) { | 795 TEST(RemoveToNumberEffects) { |
| 796 FLAG_turbo_deoptimization = true; |
| 797 |
778 JSTypedLoweringTester R; | 798 JSTypedLoweringTester R; |
779 | 799 |
780 Node* effect_use = NULL; | 800 Node* effect_use = NULL; |
781 for (int i = 0; i < 10; i++) { | 801 for (int i = 0; i < 10; i++) { |
782 Node* p0 = R.Parameter(Type::Number()); | 802 Node* p0 = R.Parameter(Type::Number()); |
783 Node* ton = R.Unop(R.javascript.ToNumber(), p0); | 803 Node* ton = R.Unop(R.javascript.ToNumber(), p0); |
| 804 Node* frame_state = R.EmptyFrameState(R.context()); |
784 effect_use = NULL; | 805 effect_use = NULL; |
785 | 806 |
786 switch (i) { | 807 switch (i) { |
787 case 0: | 808 case 0: |
788 effect_use = R.graph.NewNode(R.javascript.ToNumber(), p0, R.context(), | 809 effect_use = R.graph.NewNode(R.javascript.ToNumber(), p0, R.context(), |
789 ton, R.start()); | 810 ton, R.start()); |
790 break; | 811 break; |
791 case 1: | 812 case 1: |
792 effect_use = R.graph.NewNode(R.javascript.ToNumber(), ton, R.context(), | 813 effect_use = R.graph.NewNode(R.javascript.ToNumber(), ton, R.context(), |
793 ton, R.start()); | 814 ton, R.start()); |
794 break; | 815 break; |
795 case 2: | 816 case 2: |
796 effect_use = R.graph.NewNode(R.common.EffectPhi(1), ton, R.start()); | 817 effect_use = R.graph.NewNode(R.common.EffectPhi(1), ton, R.start()); |
797 case 3: | 818 case 3: |
798 effect_use = R.graph.NewNode(R.javascript.Add(), ton, ton, R.context(), | 819 effect_use = R.graph.NewNode(R.javascript.Add(), ton, ton, R.context(), |
799 ton, R.start()); | 820 frame_state, ton, R.start()); |
800 break; | 821 break; |
801 case 4: | 822 case 4: |
802 effect_use = R.graph.NewNode(R.javascript.Add(), p0, p0, R.context(), | 823 effect_use = R.graph.NewNode(R.javascript.Add(), p0, p0, R.context(), |
803 ton, R.start()); | 824 frame_state, ton, R.start()); |
804 break; | 825 break; |
805 case 5: | 826 case 5: |
806 effect_use = R.graph.NewNode(R.common.Return(), p0, ton, R.start()); | 827 effect_use = R.graph.NewNode(R.common.Return(), p0, ton, R.start()); |
807 break; | 828 break; |
808 case 6: | 829 case 6: |
809 effect_use = R.graph.NewNode(R.common.Return(), ton, ton, R.start()); | 830 effect_use = R.graph.NewNode(R.common.Return(), ton, ton, R.start()); |
810 } | 831 } |
811 | 832 |
812 R.CheckEffectInput(R.start(), ton); | 833 R.CheckEffectInput(R.start(), ton); |
813 if (effect_use != NULL) R.CheckEffectInput(ton, effect_use); | 834 if (effect_use != NULL) R.CheckEffectInput(ton, effect_use); |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1343 CHECK_EQ(p1, r->InputAt(0)); | 1364 CHECK_EQ(p1, r->InputAt(0)); |
1344 CHECK_EQ(p0, r->InputAt(1)); | 1365 CHECK_EQ(p0, r->InputAt(1)); |
1345 } else { | 1366 } else { |
1346 CHECK_EQ(p0, r->InputAt(0)); | 1367 CHECK_EQ(p0, r->InputAt(0)); |
1347 CHECK_EQ(p1, r->InputAt(1)); | 1368 CHECK_EQ(p1, r->InputAt(1)); |
1348 } | 1369 } |
1349 } | 1370 } |
1350 } | 1371 } |
1351 } | 1372 } |
1352 } | 1373 } |
OLD | NEW |