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

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

Issue 769193003: [turbofan] Cache the JSStoreProperty operator(s). (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « src/compiler/js-operator.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/operator-properties-inl.h" 6 #include "src/compiler/operator-properties-inl.h"
7 #include "test/unittests/test-utils.h" 7 #include "test/unittests/test-utils.h"
8 8
9 namespace v8 { 9 namespace v8 {
10 namespace internal { 10 namespace internal {
11 namespace compiler { 11 namespace compiler {
12 12
13 // ----------------------------------------------------------------------------- 13 // -----------------------------------------------------------------------------
14 // Shared operators. 14 // Shared operators.
15 15
16
16 namespace { 17 namespace {
17 18
18 struct SharedOperator { 19 struct SharedOperator {
19 const Operator* (JSOperatorBuilder::*constructor)(); 20 const Operator* (JSOperatorBuilder::*constructor)();
20 IrOpcode::Value opcode; 21 IrOpcode::Value opcode;
21 Operator::Properties properties; 22 Operator::Properties properties;
22 int value_input_count; 23 int value_input_count;
23 int frame_state_input_count; 24 int frame_state_input_count;
24 int effect_input_count; 25 int effect_input_count;
25 int control_input_count; 26 int control_input_count;
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 JSOperatorBuilder javascript(zone()); 136 JSOperatorBuilder javascript(zone());
136 const SharedOperator& sop = GetParam(); 137 const SharedOperator& sop = GetParam();
137 const Operator* op = (javascript.*sop.constructor)(); 138 const Operator* op = (javascript.*sop.constructor)();
138 EXPECT_EQ(sop.properties, op->properties()); 139 EXPECT_EQ(sop.properties, op->properties());
139 } 140 }
140 141
141 142
142 INSTANTIATE_TEST_CASE_P(JSOperatorTest, JSSharedOperatorTest, 143 INSTANTIATE_TEST_CASE_P(JSOperatorTest, JSSharedOperatorTest,
143 ::testing::ValuesIn(kSharedOperators)); 144 ::testing::ValuesIn(kSharedOperators));
144 145
146
147 // -----------------------------------------------------------------------------
148 // JSStoreProperty.
149
150
151 class JSStorePropertyOperatorTest
152 : public TestWithZone,
153 public ::testing::WithParamInterface<StrictMode> {};
154
155
156 TEST_P(JSStorePropertyOperatorTest, InstancesAreGloballyShared) {
157 const StrictMode mode = GetParam();
158 JSOperatorBuilder javascript1(zone());
159 JSOperatorBuilder javascript2(zone());
160 EXPECT_EQ(javascript1.StoreProperty(mode), javascript2.StoreProperty(mode));
161 }
162
163
164 TEST_P(JSStorePropertyOperatorTest, NumberOfInputsAndOutputs) {
165 JSOperatorBuilder javascript(zone());
166 const StrictMode mode = GetParam();
167 const Operator* op = javascript.StoreProperty(mode);
168
169 // TODO(jarin): Get rid of this hack.
170 const int frame_state_input_count = FLAG_turbo_deoptimization ? 1 : 0;
171 EXPECT_EQ(3, op->ValueInputCount());
172 EXPECT_EQ(1, OperatorProperties::GetContextInputCount(op));
173 EXPECT_EQ(frame_state_input_count,
174 OperatorProperties::GetFrameStateInputCount(op));
175 EXPECT_EQ(1, op->EffectInputCount());
176 EXPECT_EQ(1, op->ControlInputCount());
177 EXPECT_EQ(6 + frame_state_input_count,
178 OperatorProperties::GetTotalInputCount(op));
179
180 EXPECT_EQ(0, op->ValueOutputCount());
181 EXPECT_EQ(1, op->EffectOutputCount());
182 EXPECT_EQ(0, op->ControlOutputCount());
183 }
184
185
186 TEST_P(JSStorePropertyOperatorTest, OpcodeIsCorrect) {
187 JSOperatorBuilder javascript(zone());
188 const StrictMode mode = GetParam();
189 const Operator* op = javascript.StoreProperty(mode);
190 EXPECT_EQ(IrOpcode::kJSStoreProperty, op->opcode());
191 }
192
193
194 TEST_P(JSStorePropertyOperatorTest, OpParameter) {
195 JSOperatorBuilder javascript(zone());
196 const StrictMode mode = GetParam();
197 const Operator* op = javascript.StoreProperty(mode);
198 EXPECT_EQ(mode, OpParameter<StrictMode>(op));
199 }
200
201
202 TEST_P(JSStorePropertyOperatorTest, Properties) {
203 JSOperatorBuilder javascript(zone());
204 const StrictMode mode = GetParam();
205 const Operator* op = javascript.StoreProperty(mode);
206 EXPECT_EQ(Operator::kNoProperties, op->properties());
207 }
208
209
210 INSTANTIATE_TEST_CASE_P(JSOperatorTest, JSStorePropertyOperatorTest,
211 ::testing::Values(SLOPPY, STRICT));
212
145 } // namespace compiler 213 } // namespace compiler
146 } // namespace internal 214 } // namespace internal
147 } // namespace v8 215 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/js-operator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698