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

Side by Side Diff: test/unittests/interpreter/bytecode-array-builder-unittest.cc

Issue 1546683002: [Interpreter] Add support for jumps using constants with wide operands. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rationalize jumps in bytecode-graph-builder.cc. Created 5 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
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/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/interpreter/bytecode-array-builder.h" 7 #include "src/interpreter/bytecode-array-builder.h"
8 #include "src/interpreter/bytecode-array-iterator.h" 8 #include "src/interpreter/bytecode-array-iterator.h"
9 #include "test/unittests/test-utils.h" 9 #include "test/unittests/test-utils.h"
10 10
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 factory->NewStringFromStaticChars("function_b"), MaybeHandle<Code>(), 233 factory->NewStringFromStaticChars("function_b"), MaybeHandle<Code>(),
234 false); 234 false);
235 builder.CreateClosure(shared_info2, NOT_TENURED); 235 builder.CreateClosure(shared_info2, NOT_TENURED);
236 236
237 // Emit wide variant of literal creation operations. 237 // Emit wide variant of literal creation operations.
238 builder.CreateRegExpLiteral(factory->NewStringFromStaticChars("wide_literal"), 238 builder.CreateRegExpLiteral(factory->NewStringFromStaticChars("wide_literal"),
239 0, 0) 239 0, 0)
240 .CreateArrayLiteral(factory->NewFixedArray(2), 0, 0) 240 .CreateArrayLiteral(factory->NewFixedArray(2), 0, 0)
241 .CreateObjectLiteral(factory->NewFixedArray(2), 0, 0); 241 .CreateObjectLiteral(factory->NewFixedArray(2), 0, 0);
242 242
243 // Longer jumps requiring ConstantWide operand
244 builder.Jump(&start).JumpIfNull(&start).JumpIfUndefined(&start);
245 // Perform an operation that returns boolean value to
246 // generate JumpIfTrue/False
247 builder.CompareOperation(Token::Value::EQ, reg, Strength::WEAK)
248 .JumpIfTrue(&start)
249 .CompareOperation(Token::Value::EQ, reg, Strength::WEAK)
250 .JumpIfFalse(&start);
251 // Perform an operation that returns a non-boolean operation to
252 // generate JumpIfToBooleanTrue/False.
253 builder.BinaryOperation(Token::Value::ADD, reg, Strength::WEAK)
254 .JumpIfTrue(&start)
255 .BinaryOperation(Token::Value::ADD, reg, Strength::WEAK)
256 .JumpIfFalse(&start);
257
243 builder.Return(); 258 builder.Return();
244 259
245 // Generate BytecodeArray. 260 // Generate BytecodeArray.
246 Handle<BytecodeArray> the_array = builder.ToBytecodeArray(); 261 Handle<BytecodeArray> the_array = builder.ToBytecodeArray();
247 CHECK_EQ(the_array->frame_size(), 262 CHECK_EQ(the_array->frame_size(),
248 builder.fixed_register_count() * kPointerSize); 263 builder.fixed_register_count() * kPointerSize);
249 264
250 // Build scorecard of bytecodes encountered in the BytecodeArray. 265 // Build scorecard of bytecodes encountered in the BytecodeArray.
251 std::vector<int> scorecard(Bytecodes::ToByte(Bytecode::kLast) + 1); 266 std::vector<int> scorecard(Bytecodes::ToByte(Bytecode::kLast) + 1);
252 Bytecode final_bytecode = Bytecode::kLdaZero; 267 Bytecode final_bytecode = Bytecode::kLdaZero;
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 iterator.Advance(); 681 iterator.Advance();
667 CHECK_EQ(iterator.current_bytecode(), Bytecode::kJump); 682 CHECK_EQ(iterator.current_bytecode(), Bytecode::kJump);
668 CHECK_EQ(iterator.GetImmediateOperand(0), -2); 683 CHECK_EQ(iterator.GetImmediateOperand(0), -2);
669 iterator.Advance(); 684 iterator.Advance();
670 } 685 }
671 CHECK_EQ(iterator.current_bytecode(), Bytecode::kReturn); 686 CHECK_EQ(iterator.current_bytecode(), Bytecode::kReturn);
672 iterator.Advance(); 687 iterator.Advance();
673 CHECK(iterator.done()); 688 CHECK(iterator.done());
674 } 689 }
675 690
691
676 } // namespace interpreter 692 } // namespace interpreter
677 } // namespace internal 693 } // namespace internal
678 } // namespace v8 694 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698