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

Side by Side Diff: test/unittests/interpreter/bytecode-peephole-optimizer-unittest.cc

Issue 2169813002: [interpreter] Add output register to ToName (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@addregouts
Patch Set: comments Created 4 years, 5 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
« no previous file with comments | « test/unittests/interpreter/bytecode-array-builder-unittest.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 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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 6
7 #include "src/factory.h" 7 #include "src/factory.h"
8 #include "src/interpreter/bytecode-label.h" 8 #include "src/interpreter/bytecode-label.h"
9 #include "src/interpreter/bytecode-peephole-optimizer.h" 9 #include "src/interpreter/bytecode-peephole-optimizer.h"
10 #include "src/interpreter/constant-array-builder.h" 10 #include "src/interpreter/constant-array-builder.h"
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 CHECK_EQ(last_written(), first); 234 CHECK_EQ(last_written(), first);
235 optimizer()->Write(&third); 235 optimizer()->Write(&third);
236 CHECK_EQ(write_count(), 1); 236 CHECK_EQ(write_count(), 1);
237 Flush(); 237 Flush();
238 CHECK_EQ(write_count(), 2); 238 CHECK_EQ(write_count(), 2);
239 CHECK_EQ(last_written(), third); 239 CHECK_EQ(last_written(), third);
240 } 240 }
241 241
242 TEST_F(BytecodePeepholeOptimizerTest, LdarToName) { 242 TEST_F(BytecodePeepholeOptimizerTest, LdarToName) {
243 BytecodeNode first(Bytecode::kLdar, Register(0).ToOperand()); 243 BytecodeNode first(Bytecode::kLdar, Register(0).ToOperand());
244 BytecodeNode second(Bytecode::kToName); 244 BytecodeNode second(Bytecode::kToName, Register(0).ToOperand());
245 optimizer()->Write(&first); 245 optimizer()->Write(&first);
246 CHECK_EQ(write_count(), 0); 246 CHECK_EQ(write_count(), 0);
247 optimizer()->Write(&second); 247 optimizer()->Write(&second);
248 CHECK_EQ(write_count(), 1); 248 CHECK_EQ(write_count(), 1);
249 CHECK_EQ(last_written(), first); 249 CHECK_EQ(last_written(), first);
250 Flush(); 250 Flush();
251 CHECK_EQ(write_count(), 2); 251 CHECK_EQ(write_count(), 2);
252 CHECK_EQ(last_written(), second); 252 CHECK_EQ(last_written(), second);
253 } 253 }
254 254
255 TEST_F(BytecodePeepholeOptimizerTest, ToNameToName) {
256 BytecodeNode first(Bytecode::kToName);
257 BytecodeNode second(Bytecode::kToName);
258 optimizer()->Write(&first);
259 optimizer()->Write(&second);
260 CHECK_EQ(write_count(), 0);
261 Flush();
262 CHECK_EQ(last_written(), first);
263 CHECK_EQ(write_count(), 1);
264 }
265
266 TEST_F(BytecodePeepholeOptimizerTest, TypeOfToName) { 255 TEST_F(BytecodePeepholeOptimizerTest, TypeOfToName) {
267 BytecodeNode first(Bytecode::kTypeOf); 256 BytecodeNode first(Bytecode::kTypeOf);
268 BytecodeNode second(Bytecode::kToName); 257 BytecodeNode second(Bytecode::kToName, Register(0).ToOperand());
269 optimizer()->Write(&first); 258 optimizer()->Write(&first);
259 CHECK_EQ(write_count(), 0);
270 optimizer()->Write(&second); 260 optimizer()->Write(&second);
271 CHECK_EQ(write_count(), 0);
272 Flush();
273 CHECK_EQ(write_count(), 1); 261 CHECK_EQ(write_count(), 1);
274 CHECK_EQ(last_written(), first); 262 CHECK_EQ(last_written(), first);
263 Flush();
264 CHECK_EQ(write_count(), 2);
265 CHECK_EQ(last_written(), second);
266 CHECK_EQ(last_written().bytecode(), Bytecode::kStar);
275 } 267 }
276 268
277 TEST_F(BytecodePeepholeOptimizerTest, LdaConstantStringToName) { 269 TEST_F(BytecodePeepholeOptimizerTest, LdaConstantStringToName) {
278 Handle<Object> word = 270 Handle<Object> word =
279 isolate()->factory()->NewStringFromStaticChars("optimizing"); 271 isolate()->factory()->NewStringFromStaticChars("optimizing");
280 size_t index = constant_array()->Insert(word); 272 size_t index = constant_array()->Insert(word);
281 BytecodeNode first(Bytecode::kLdaConstant, static_cast<uint32_t>(index)); 273 BytecodeNode first(Bytecode::kLdaConstant, static_cast<uint32_t>(index));
282 BytecodeNode second(Bytecode::kToName); 274 BytecodeNode second(Bytecode::kToName, Register(0).ToOperand());
283 optimizer()->Write(&first); 275 optimizer()->Write(&first);
276 CHECK_EQ(write_count(), 0);
284 optimizer()->Write(&second); 277 optimizer()->Write(&second);
285 CHECK_EQ(write_count(), 0);
286 Flush();
287 CHECK_EQ(write_count(), 1); 278 CHECK_EQ(write_count(), 1);
288 CHECK_EQ(last_written(), first); 279 CHECK_EQ(last_written(), first);
280 Flush();
281 CHECK_EQ(write_count(), 2);
282 CHECK_EQ(last_written(), second);
283 CHECK_EQ(last_written().bytecode(), Bytecode::kStar);
289 } 284 }
290 285
291 TEST_F(BytecodePeepholeOptimizerTest, LdaConstantNumberToName) { 286 TEST_F(BytecodePeepholeOptimizerTest, LdaConstantNumberToName) {
292 Handle<Object> word = isolate()->factory()->NewNumber(0.380); 287 Handle<Object> word = isolate()->factory()->NewNumber(0.380);
293 size_t index = constant_array()->Insert(word); 288 size_t index = constant_array()->Insert(word);
294 BytecodeNode first(Bytecode::kLdaConstant, static_cast<uint32_t>(index)); 289 BytecodeNode first(Bytecode::kLdaConstant, static_cast<uint32_t>(index));
295 BytecodeNode second(Bytecode::kToName); 290 BytecodeNode second(Bytecode::kToName, Register(0).ToOperand());
296 optimizer()->Write(&first); 291 optimizer()->Write(&first);
297 CHECK_EQ(write_count(), 0); 292 CHECK_EQ(write_count(), 0);
298 optimizer()->Write(&second); 293 optimizer()->Write(&second);
299 CHECK_EQ(write_count(), 1); 294 CHECK_EQ(write_count(), 1);
300 CHECK_EQ(last_written(), first); 295 CHECK_EQ(last_written(), first);
301 Flush(); 296 Flush();
302 CHECK_EQ(write_count(), 2); 297 CHECK_EQ(write_count(), 2);
303 CHECK_EQ(last_written(), second); 298 CHECK_EQ(last_written(), second);
304 } 299 }
305 300
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 CHECK_EQ(last_written().operand_count(), 2); 554 CHECK_EQ(last_written().operand_count(), 2);
560 CHECK_EQ(last_written().operand(0), 0); 555 CHECK_EQ(last_written().operand(0), 0);
561 CHECK_EQ(last_written().operand(1), reg_operand); 556 CHECK_EQ(last_written().operand(1), reg_operand);
562 Reset(); 557 Reset();
563 } 558 }
564 } 559 }
565 560
566 } // namespace interpreter 561 } // namespace interpreter
567 } // namespace internal 562 } // namespace internal
568 } // namespace v8 563 } // namespace v8
OLDNEW
« no previous file with comments | « test/unittests/interpreter/bytecode-array-builder-unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698