Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(478)

Side by Side Diff: test/unittests/compiler/js-operator-unittest.cc

Issue 928213003: Model exceptional edges from call nodes in TurboFan. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/js-operator.h" 5 #include "src/compiler/js-operator.h"
6 #include "src/compiler/opcodes.h" 6 #include "src/compiler/opcodes.h"
7 #include "src/compiler/operator.h" 7 #include "src/compiler/operator.h"
8 #include "src/compiler/operator-properties.h" 8 #include "src/compiler/operator-properties.h"
9 #include "test/unittests/test-utils.h" 9 #include "test/unittests/test-utils.h"
10 10
(...skipping 10 matching lines...) Expand all
21 struct SharedOperator { 21 struct SharedOperator {
22 const Operator* (JSOperatorBuilder::*constructor)(); 22 const Operator* (JSOperatorBuilder::*constructor)();
23 IrOpcode::Value opcode; 23 IrOpcode::Value opcode;
24 Operator::Properties properties; 24 Operator::Properties properties;
25 int value_input_count; 25 int value_input_count;
26 int frame_state_input_count; 26 int frame_state_input_count;
27 int effect_input_count; 27 int effect_input_count;
28 int control_input_count; 28 int control_input_count;
29 int value_output_count; 29 int value_output_count;
30 int effect_output_count; 30 int effect_output_count;
31 int control_output_count;
31 }; 32 };
32 33
33 34
34 std::ostream& operator<<(std::ostream& os, const SharedOperator& sop) { 35 std::ostream& operator<<(std::ostream& os, const SharedOperator& sop) {
35 return os << IrOpcode::Mnemonic(sop.opcode); 36 return os << IrOpcode::Mnemonic(sop.opcode);
36 } 37 }
37 38
38 39
39 const SharedOperator kSharedOperators[] = { 40 const SharedOperator kSharedOperators[] = {
40 #define SHARED(Name, properties, value_input_count, frame_state_input_count, \ 41 #define SHARED(Name, properties, value_input_count, frame_state_input_count, \
41 effect_input_count, control_input_count, value_output_count, \ 42 effect_input_count, control_input_count, value_output_count, \
42 effect_output_count) \ 43 effect_output_count, control_output_count) \
43 { \ 44 { \
44 &JSOperatorBuilder::Name, IrOpcode::kJS##Name, properties, \ 45 &JSOperatorBuilder::Name, IrOpcode::kJS##Name, properties, \
45 value_input_count, frame_state_input_count, effect_input_count, \ 46 value_input_count, frame_state_input_count, effect_input_count, \
46 control_input_count, value_output_count, effect_output_count \ 47 control_input_count, value_output_count, effect_output_count, \
48 control_output_count \
47 } 49 }
48 SHARED(Equal, Operator::kNoProperties, 2, 1, 1, 1, 1, 1), 50 SHARED(Equal, Operator::kNoProperties, 2, 1, 1, 1, 1, 1, 2),
49 SHARED(NotEqual, Operator::kNoProperties, 2, 1, 1, 1, 1, 1), 51 SHARED(NotEqual, Operator::kNoProperties, 2, 1, 1, 1, 1, 1, 2),
50 SHARED(StrictEqual, Operator::kPure, 2, 0, 0, 0, 1, 0), 52 SHARED(StrictEqual, Operator::kPure, 2, 0, 0, 0, 1, 0, 0),
51 SHARED(StrictNotEqual, Operator::kPure, 2, 0, 0, 0, 1, 0), 53 SHARED(StrictNotEqual, Operator::kPure, 2, 0, 0, 0, 1, 0, 0),
52 SHARED(LessThan, Operator::kNoProperties, 2, 1, 1, 1, 1, 1), 54 SHARED(LessThan, Operator::kNoProperties, 2, 1, 1, 1, 1, 1, 2),
53 SHARED(GreaterThan, Operator::kNoProperties, 2, 1, 1, 1, 1, 1), 55 SHARED(GreaterThan, Operator::kNoProperties, 2, 1, 1, 1, 1, 1, 2),
54 SHARED(LessThanOrEqual, Operator::kNoProperties, 2, 1, 1, 1, 1, 1), 56 SHARED(LessThanOrEqual, Operator::kNoProperties, 2, 1, 1, 1, 1, 1, 2),
55 SHARED(GreaterThanOrEqual, Operator::kNoProperties, 2, 1, 1, 1, 1, 1), 57 SHARED(GreaterThanOrEqual, Operator::kNoProperties, 2, 1, 1, 1, 1, 1, 2),
56 SHARED(BitwiseOr, Operator::kNoProperties, 2, 1, 1, 1, 1, 1), 58 SHARED(BitwiseOr, Operator::kNoProperties, 2, 1, 1, 1, 1, 1, 2),
57 SHARED(BitwiseXor, Operator::kNoProperties, 2, 1, 1, 1, 1, 1), 59 SHARED(BitwiseXor, Operator::kNoProperties, 2, 1, 1, 1, 1, 1, 2),
58 SHARED(BitwiseAnd, Operator::kNoProperties, 2, 1, 1, 1, 1, 1), 60 SHARED(BitwiseAnd, Operator::kNoProperties, 2, 1, 1, 1, 1, 1, 2),
59 SHARED(ShiftLeft, Operator::kNoProperties, 2, 1, 1, 1, 1, 1), 61 SHARED(ShiftLeft, Operator::kNoProperties, 2, 1, 1, 1, 1, 1, 2),
60 SHARED(ShiftRight, Operator::kNoProperties, 2, 1, 1, 1, 1, 1), 62 SHARED(ShiftRight, Operator::kNoProperties, 2, 1, 1, 1, 1, 1, 2),
61 SHARED(ShiftRightLogical, Operator::kNoProperties, 2, 1, 1, 1, 1, 1), 63 SHARED(ShiftRightLogical, Operator::kNoProperties, 2, 1, 1, 1, 1, 1, 2),
62 SHARED(Add, Operator::kNoProperties, 2, 1, 1, 1, 1, 1), 64 SHARED(Add, Operator::kNoProperties, 2, 1, 1, 1, 1, 1, 2),
63 SHARED(Subtract, Operator::kNoProperties, 2, 1, 1, 1, 1, 1), 65 SHARED(Subtract, Operator::kNoProperties, 2, 1, 1, 1, 1, 1, 2),
64 SHARED(Multiply, Operator::kNoProperties, 2, 1, 1, 1, 1, 1), 66 SHARED(Multiply, Operator::kNoProperties, 2, 1, 1, 1, 1, 1, 2),
65 SHARED(Divide, Operator::kNoProperties, 2, 1, 1, 1, 1, 1), 67 SHARED(Divide, Operator::kNoProperties, 2, 1, 1, 1, 1, 1, 2),
66 SHARED(Modulus, Operator::kNoProperties, 2, 1, 1, 1, 1, 1), 68 SHARED(Modulus, Operator::kNoProperties, 2, 1, 1, 1, 1, 1, 2),
67 SHARED(UnaryNot, Operator::kPure, 1, 0, 0, 0, 1, 0), 69 SHARED(UnaryNot, Operator::kPure, 1, 0, 0, 0, 1, 0, 0),
68 SHARED(ToBoolean, Operator::kPure, 1, 0, 0, 0, 1, 0), 70 SHARED(ToBoolean, Operator::kPure, 1, 0, 0, 0, 1, 0, 0),
69 SHARED(ToNumber, Operator::kNoProperties, 1, 1, 1, 1, 1, 1), 71 SHARED(ToNumber, Operator::kNoProperties, 1, 1, 1, 1, 1, 1, 2),
70 SHARED(ToString, Operator::kNoProperties, 1, 0, 1, 1, 1, 1), 72 SHARED(ToString, Operator::kNoProperties, 1, 0, 1, 1, 1, 1, 2),
71 SHARED(ToName, Operator::kNoProperties, 1, 1, 1, 1, 1, 1), 73 SHARED(ToName, Operator::kNoProperties, 1, 1, 1, 1, 1, 1, 2),
72 SHARED(ToObject, Operator::kNoProperties, 1, 1, 1, 1, 1, 1), 74 SHARED(ToObject, Operator::kNoProperties, 1, 1, 1, 1, 1, 1, 2),
73 SHARED(Yield, Operator::kNoProperties, 1, 0, 1, 1, 1, 1), 75 SHARED(Yield, Operator::kNoProperties, 1, 0, 1, 1, 1, 1, 2),
74 SHARED(Create, Operator::kEliminatable, 0, 0, 1, 1, 1, 1), 76 SHARED(Create, Operator::kEliminatable, 0, 0, 1, 1, 1, 1, 0),
75 SHARED(HasProperty, Operator::kNoProperties, 2, 1, 1, 1, 1, 1), 77 SHARED(HasProperty, Operator::kNoProperties, 2, 1, 1, 1, 1, 1, 2),
76 SHARED(TypeOf, Operator::kPure, 1, 0, 0, 0, 1, 0), 78 SHARED(TypeOf, Operator::kPure, 1, 0, 0, 0, 1, 0, 0),
77 SHARED(InstanceOf, Operator::kNoProperties, 2, 1, 1, 1, 1, 1), 79 SHARED(InstanceOf, Operator::kNoProperties, 2, 1, 1, 1, 1, 1, 2),
78 SHARED(Debugger, Operator::kNoProperties, 0, 0, 1, 1, 0, 1), 80 SHARED(Debugger, Operator::kNoProperties, 0, 0, 1, 1, 0, 1, 2),
79 SHARED(CreateFunctionContext, Operator::kNoProperties, 1, 0, 1, 1, 1, 1), 81 SHARED(CreateFunctionContext, Operator::kNoProperties, 1, 0, 1, 1, 1, 1, 2),
80 SHARED(CreateWithContext, Operator::kNoProperties, 2, 1, 1, 1, 1, 1), 82 SHARED(CreateWithContext, Operator::kNoProperties, 2, 1, 1, 1, 1, 1, 2),
81 SHARED(CreateBlockContext, Operator::kNoProperties, 2, 0, 1, 1, 1, 1), 83 SHARED(CreateBlockContext, Operator::kNoProperties, 2, 0, 1, 1, 1, 1, 2),
82 SHARED(CreateModuleContext, Operator::kNoProperties, 2, 0, 1, 1, 1, 1), 84 SHARED(CreateModuleContext, Operator::kNoProperties, 2, 0, 1, 1, 1, 1, 2),
83 SHARED(CreateScriptContext, Operator::kNoProperties, 2, 0, 1, 1, 1, 1) 85 SHARED(CreateScriptContext, Operator::kNoProperties, 2, 0, 1, 1, 1, 1, 2)
84 #undef SHARED 86 #undef SHARED
85 }; 87 };
86 88
87 } // namespace 89 } // namespace
88 90
89 91
90 class JSSharedOperatorTest 92 class JSSharedOperatorTest
91 : public TestWithZone, 93 : public TestWithZone,
92 public ::testing::WithParamInterface<SharedOperator> {}; 94 public ::testing::WithParamInterface<SharedOperator> {};
93 95
(...skipping 21 matching lines...) Expand all
115 OperatorProperties::GetFrameStateInputCount(op)); 117 OperatorProperties::GetFrameStateInputCount(op));
116 EXPECT_EQ(sop.effect_input_count, op->EffectInputCount()); 118 EXPECT_EQ(sop.effect_input_count, op->EffectInputCount());
117 EXPECT_EQ(sop.control_input_count, op->ControlInputCount()); 119 EXPECT_EQ(sop.control_input_count, op->ControlInputCount());
118 EXPECT_EQ(sop.value_input_count + context_input_count + 120 EXPECT_EQ(sop.value_input_count + context_input_count +
119 frame_state_input_count + sop.effect_input_count + 121 frame_state_input_count + sop.effect_input_count +
120 sop.control_input_count, 122 sop.control_input_count,
121 OperatorProperties::GetTotalInputCount(op)); 123 OperatorProperties::GetTotalInputCount(op));
122 124
123 EXPECT_EQ(sop.value_output_count, op->ValueOutputCount()); 125 EXPECT_EQ(sop.value_output_count, op->ValueOutputCount());
124 EXPECT_EQ(sop.effect_output_count, op->EffectOutputCount()); 126 EXPECT_EQ(sop.effect_output_count, op->EffectOutputCount());
125 EXPECT_EQ(0, op->ControlOutputCount()); 127 EXPECT_EQ(sop.control_output_count, op->ControlOutputCount());
126 } 128 }
127 129
128 130
129 TEST_P(JSSharedOperatorTest, OpcodeIsCorrect) { 131 TEST_P(JSSharedOperatorTest, OpcodeIsCorrect) {
130 JSOperatorBuilder javascript(zone()); 132 JSOperatorBuilder javascript(zone());
131 const SharedOperator& sop = GetParam(); 133 const SharedOperator& sop = GetParam();
132 const Operator* op = (javascript.*sop.constructor)(); 134 const Operator* op = (javascript.*sop.constructor)();
133 EXPECT_EQ(sop.opcode, op->opcode()); 135 EXPECT_EQ(sop.opcode, op->opcode());
134 } 136 }
135 137
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 EXPECT_EQ(1, OperatorProperties::GetContextInputCount(op)); 176 EXPECT_EQ(1, OperatorProperties::GetContextInputCount(op));
175 EXPECT_EQ(frame_state_input_count, 177 EXPECT_EQ(frame_state_input_count,
176 OperatorProperties::GetFrameStateInputCount(op)); 178 OperatorProperties::GetFrameStateInputCount(op));
177 EXPECT_EQ(1, op->EffectInputCount()); 179 EXPECT_EQ(1, op->EffectInputCount());
178 EXPECT_EQ(1, op->ControlInputCount()); 180 EXPECT_EQ(1, op->ControlInputCount());
179 EXPECT_EQ(6 + frame_state_input_count, 181 EXPECT_EQ(6 + frame_state_input_count,
180 OperatorProperties::GetTotalInputCount(op)); 182 OperatorProperties::GetTotalInputCount(op));
181 183
182 EXPECT_EQ(0, op->ValueOutputCount()); 184 EXPECT_EQ(0, op->ValueOutputCount());
183 EXPECT_EQ(1, op->EffectOutputCount()); 185 EXPECT_EQ(1, op->EffectOutputCount());
184 EXPECT_EQ(0, op->ControlOutputCount()); 186 EXPECT_EQ(2, op->ControlOutputCount());
185 } 187 }
186 188
187 189
188 TEST_P(JSStorePropertyOperatorTest, OpcodeIsCorrect) { 190 TEST_P(JSStorePropertyOperatorTest, OpcodeIsCorrect) {
189 JSOperatorBuilder javascript(zone()); 191 JSOperatorBuilder javascript(zone());
190 const LanguageMode mode = GetParam(); 192 const LanguageMode mode = GetParam();
191 const Operator* op = javascript.StoreProperty(mode); 193 const Operator* op = javascript.StoreProperty(mode);
192 EXPECT_EQ(IrOpcode::kJSStoreProperty, op->opcode()); 194 EXPECT_EQ(IrOpcode::kJSStoreProperty, op->opcode());
193 } 195 }
194 196
(...skipping 13 matching lines...) Expand all
208 EXPECT_EQ(Operator::kNoProperties, op->properties()); 210 EXPECT_EQ(Operator::kNoProperties, op->properties());
209 } 211 }
210 212
211 213
212 INSTANTIATE_TEST_CASE_P(JSOperatorTest, JSStorePropertyOperatorTest, 214 INSTANTIATE_TEST_CASE_P(JSOperatorTest, JSStorePropertyOperatorTest,
213 ::testing::Values(SLOPPY, STRICT)); 215 ::testing::Values(SLOPPY, STRICT));
214 216
215 } // namespace compiler 217 } // namespace compiler
216 } // namespace internal 218 } // namespace internal
217 } // namespace v8 219 } // namespace v8
OLDNEW
« no previous file with comments | « test/unittests/compiler/common-operator-unittest.cc ('k') | test/unittests/compiler/node-properties-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698