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

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

Issue 1613163002: [interpreter] Wide register support. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Added tests, fixed off-by-one error in register indicies. Created 4 years, 11 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/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 "src/interpreter/bytecode-register-allocator.h" 9 #include "src/interpreter/bytecode-register-allocator.h"
10 #include "test/unittests/test-utils.h" 10 #include "test/unittests/test-utils.h"
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 157
158 // Emit cast operator invocations. 158 // Emit cast operator invocations.
159 builder.CastAccumulatorToNumber() 159 builder.CastAccumulatorToNumber()
160 .CastAccumulatorToJSObject() 160 .CastAccumulatorToJSObject()
161 .CastAccumulatorToName(); 161 .CastAccumulatorToName();
162 162
163 // Emit control flow. Return must be the last instruction. 163 // Emit control flow. Return must be the last instruction.
164 BytecodeLabel start; 164 BytecodeLabel start;
165 builder.Bind(&start); 165 builder.Bind(&start);
166 // Short jumps with Imm8 operands 166 // Short jumps with Imm8 operands
167 builder.Jump(&start) 167 builder.Jump(&start).JumpIfNull(&start).JumpIfUndefined(&start);
168 .JumpIfNull(&start)
169 .JumpIfUndefined(&start);
170 // Perform an operation that returns boolean value to 168 // Perform an operation that returns boolean value to
171 // generate JumpIfTrue/False 169 // generate JumpIfTrue/False
172 builder.CompareOperation(Token::Value::EQ, reg, Strength::WEAK) 170 builder.CompareOperation(Token::Value::EQ, reg, Strength::WEAK)
173 .JumpIfTrue(&start) 171 .JumpIfTrue(&start)
174 .CompareOperation(Token::Value::EQ, reg, Strength::WEAK) 172 .CompareOperation(Token::Value::EQ, reg, Strength::WEAK)
175 .JumpIfFalse(&start); 173 .JumpIfFalse(&start);
176 // Perform an operation that returns a non-boolean operation to 174 // Perform an operation that returns a non-boolean operation to
177 // generate JumpIfToBooleanTrue/False. 175 // generate JumpIfToBooleanTrue/False.
178 builder.BinaryOperation(Token::Value::ADD, reg, Strength::WEAK) 176 builder.BinaryOperation(Token::Value::ADD, reg, Strength::WEAK)
179 .JumpIfTrue(&start) 177 .JumpIfTrue(&start)
180 .BinaryOperation(Token::Value::ADD, reg, Strength::WEAK) 178 .BinaryOperation(Token::Value::ADD, reg, Strength::WEAK)
181 .JumpIfFalse(&start); 179 .JumpIfFalse(&start);
182 // Insert dummy ops to force longer jumps 180 // Insert dummy ops to force longer jumps
183 for (int i = 0; i < 128; i++) { 181 for (int i = 0; i < 128; i++) {
184 builder.LoadTrue(); 182 builder.LoadTrue();
185 } 183 }
186 // Longer jumps requiring Constant operand 184 // Longer jumps requiring Constant operand
187 builder.Jump(&start) 185 builder.Jump(&start).JumpIfNull(&start).JumpIfUndefined(&start);
188 .JumpIfNull(&start)
189 .JumpIfUndefined(&start);
190 // Perform an operation that returns boolean value to 186 // Perform an operation that returns boolean value to
191 // generate JumpIfTrue/False 187 // generate JumpIfTrue/False
192 builder.CompareOperation(Token::Value::EQ, reg, Strength::WEAK) 188 builder.CompareOperation(Token::Value::EQ, reg, Strength::WEAK)
193 .JumpIfTrue(&start) 189 .JumpIfTrue(&start)
194 .CompareOperation(Token::Value::EQ, reg, Strength::WEAK) 190 .CompareOperation(Token::Value::EQ, reg, Strength::WEAK)
195 .JumpIfFalse(&start); 191 .JumpIfFalse(&start);
196 // Perform an operation that returns a non-boolean operation to 192 // Perform an operation that returns a non-boolean operation to
197 // generate JumpIfToBooleanTrue/False. 193 // generate JumpIfToBooleanTrue/False.
198 builder.BinaryOperation(Token::Value::ADD, reg, Strength::WEAK) 194 builder.BinaryOperation(Token::Value::ADD, reg, Strength::WEAK)
199 .JumpIfTrue(&start) 195 .JumpIfTrue(&start)
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 builder.BinaryOperation(Token::Value::ADD, reg, Strength::WEAK) 272 builder.BinaryOperation(Token::Value::ADD, reg, Strength::WEAK)
277 .JumpIfTrue(&start) 273 .JumpIfTrue(&start)
278 .BinaryOperation(Token::Value::ADD, reg, Strength::WEAK) 274 .BinaryOperation(Token::Value::ADD, reg, Strength::WEAK)
279 .JumpIfFalse(&start); 275 .JumpIfFalse(&start);
280 276
281 builder.Return(); 277 builder.Return();
282 278
283 // Generate BytecodeArray. 279 // Generate BytecodeArray.
284 Handle<BytecodeArray> the_array = builder.ToBytecodeArray(); 280 Handle<BytecodeArray> the_array = builder.ToBytecodeArray();
285 CHECK_EQ(the_array->frame_size(), 281 CHECK_EQ(the_array->frame_size(),
286 builder.fixed_register_count() * kPointerSize); 282 (builder.fixed_and_temporary_register_count() +
283 builder.translation_register_count()) *
284 kPointerSize);
287 285
288 // Build scorecard of bytecodes encountered in the BytecodeArray. 286 // Build scorecard of bytecodes encountered in the BytecodeArray.
289 std::vector<int> scorecard(Bytecodes::ToByte(Bytecode::kLast) + 1); 287 std::vector<int> scorecard(Bytecodes::ToByte(Bytecode::kLast) + 1);
290 Bytecode final_bytecode = Bytecode::kLdaZero; 288 Bytecode final_bytecode = Bytecode::kLdaZero;
291 int i = 0; 289 int i = 0;
292 while (i < the_array->length()) { 290 while (i < the_array->length()) {
293 uint8_t code = the_array->get(i); 291 uint8_t code = the_array->get(i);
294 scorecard[code] += 1; 292 scorecard[code] += 1;
295 final_bytecode = Bytecodes::FromByte(code); 293 final_bytecode = Bytecodes::FromByte(code);
296 i += Bytecodes::Size(Bytecodes::FromByte(code)); 294 i += Bytecodes::Size(Bytecodes::FromByte(code));
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 iterator.Advance(); 676 iterator.Advance();
679 CHECK_EQ(iterator.current_bytecode(), Bytecode::kJump); 677 CHECK_EQ(iterator.current_bytecode(), Bytecode::kJump);
680 CHECK_EQ(iterator.GetImmediateOperand(0), -2); 678 CHECK_EQ(iterator.GetImmediateOperand(0), -2);
681 iterator.Advance(); 679 iterator.Advance();
682 } 680 }
683 CHECK_EQ(iterator.current_bytecode(), Bytecode::kReturn); 681 CHECK_EQ(iterator.current_bytecode(), Bytecode::kReturn);
684 iterator.Advance(); 682 iterator.Advance();
685 CHECK(iterator.done()); 683 CHECK(iterator.done());
686 } 684 }
687 685
688
689 } // namespace interpreter 686 } // namespace interpreter
690 } // namespace internal 687 } // namespace internal
691 } // namespace v8 688 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698