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

Side by Side Diff: src/interpreter/bytecodes.cc

Issue 1555713002: [Interpreter] Bytecodes for exchanging registers. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase. 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
« no previous file with comments | « src/interpreter/bytecodes.h ('k') | src/interpreter/interpreter.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/interpreter/bytecodes.h" 5 #include "src/interpreter/bytecodes.h"
6 6
7 #include "src/frames.h" 7 #include "src/frames.h"
8 #include "src/interpreter/bytecode-traits.h" 8 #include "src/interpreter/bytecode-traits.h"
9 9
10 namespace v8 { 10 namespace v8 {
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 if (parameter_index == 0) { 266 if (parameter_index == 0) {
267 os << "<this>"; 267 os << "<this>";
268 } else { 268 } else {
269 os << "a" << parameter_index - 1; 269 os << "a" << parameter_index - 1;
270 } 270 }
271 } else { 271 } else {
272 os << "r" << reg.index(); 272 os << "r" << reg.index();
273 } 273 }
274 break; 274 break;
275 } 275 }
276 case interpreter::OperandType::kReg16: {
277 Register reg =
278 Register::FromWideOperand(ReadUnalignedUInt16(operand_start));
279 if (reg.is_parameter()) {
280 int parameter_index = reg.ToParameterIndex(parameter_count);
281 DCHECK_NE(parameter_index, 0);
282 os << "a" << parameter_index - 1;
283 } else {
284 os << "r" << reg.index();
285 }
286 break;
287 }
276 case interpreter::OperandType::kNone: 288 case interpreter::OperandType::kNone:
277 UNREACHABLE(); 289 UNREACHABLE();
278 break; 290 break;
279 } 291 }
280 if (i != number_of_operands - 1) { 292 if (i != number_of_operands - 1) {
281 os << ", "; 293 os << ", ";
282 } 294 }
283 } 295 }
284 return os; 296 return os;
285 } 297 }
(...skipping 29 matching lines...) Expand all
315 // for ease of access in the interpreter. 327 // for ease of access in the interpreter.
316 static const int kMaxParameterIndex = 128 + kLastParamRegisterIndex; 328 static const int kMaxParameterIndex = 128 + kLastParamRegisterIndex;
317 329
318 330
319 Register Register::FromParameterIndex(int index, int parameter_count) { 331 Register Register::FromParameterIndex(int index, int parameter_count) {
320 DCHECK_GE(index, 0); 332 DCHECK_GE(index, 0);
321 DCHECK_LT(index, parameter_count); 333 DCHECK_LT(index, parameter_count);
322 DCHECK_LE(parameter_count, kMaxParameterIndex + 1); 334 DCHECK_LE(parameter_count, kMaxParameterIndex + 1);
323 int register_index = kLastParamRegisterIndex - parameter_count + index + 1; 335 int register_index = kLastParamRegisterIndex - parameter_count + index + 1;
324 DCHECK_LT(register_index, 0); 336 DCHECK_LT(register_index, 0);
325 DCHECK_GE(register_index, Register::kMinRegisterIndex); 337 DCHECK_GE(register_index, kMinInt8);
326 return Register(register_index); 338 return Register(register_index);
327 } 339 }
328 340
329 341
330 int Register::ToParameterIndex(int parameter_count) const { 342 int Register::ToParameterIndex(int parameter_count) const {
331 DCHECK(is_parameter()); 343 DCHECK(is_parameter());
332 return index() - kLastParamRegisterIndex + parameter_count - 1; 344 return index() - kLastParamRegisterIndex + parameter_count - 1;
333 } 345 }
334 346
335 347
(...skipping 21 matching lines...) Expand all
357 369
358 370
359 bool Register::is_new_target() const { 371 bool Register::is_new_target() const {
360 return index() == kNewTargetRegisterIndex; 372 return index() == kNewTargetRegisterIndex;
361 } 373 }
362 374
363 375
364 int Register::MaxParameterIndex() { return kMaxParameterIndex; } 376 int Register::MaxParameterIndex() { return kMaxParameterIndex; }
365 377
366 378
367 uint8_t Register::ToOperand() const { return static_cast<uint8_t>(-index_); } 379 uint8_t Register::ToOperand() const {
380 DCHECK_GE(index_, kMinInt8);
381 DCHECK_LE(index_, kMaxInt8);
382 return static_cast<uint8_t>(-index_);
383 }
368 384
369 385
370 Register Register::FromOperand(uint8_t operand) { 386 Register Register::FromOperand(uint8_t operand) {
371 return Register(-static_cast<int8_t>(operand)); 387 return Register(-static_cast<int8_t>(operand));
372 } 388 }
373 389
374 390
391 uint16_t Register::ToWideOperand() const {
392 DCHECK_GE(index_, kMinInt16);
393 DCHECK_LE(index_, kMaxInt16);
394 return static_cast<uint16_t>(-index_);
395 }
396
397
398 Register Register::FromWideOperand(uint16_t operand) {
399 return Register(-static_cast<int16_t>(operand));
400 }
401
402
375 bool Register::AreContiguous(Register reg1, Register reg2, Register reg3, 403 bool Register::AreContiguous(Register reg1, Register reg2, Register reg3,
376 Register reg4, Register reg5) { 404 Register reg4, Register reg5) {
377 if (reg1.index() + 1 != reg2.index()) { 405 if (reg1.index() + 1 != reg2.index()) {
378 return false; 406 return false;
379 } 407 }
380 if (reg3.is_valid() && reg2.index() + 1 != reg3.index()) { 408 if (reg3.is_valid() && reg2.index() + 1 != reg3.index()) {
381 return false; 409 return false;
382 } 410 }
383 if (reg4.is_valid() && reg3.index() + 1 != reg4.index()) { 411 if (reg4.is_valid() && reg3.index() + 1 != reg4.index()) {
384 return false; 412 return false;
385 } 413 }
386 if (reg5.is_valid() && reg4.index() + 1 != reg5.index()) { 414 if (reg5.is_valid() && reg4.index() + 1 != reg5.index()) {
387 return false; 415 return false;
388 } 416 }
389 return true; 417 return true;
390 } 418 }
391 419
392 } // namespace interpreter 420 } // namespace interpreter
393 } // namespace internal 421 } // namespace internal
394 } // namespace v8 422 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/bytecodes.h ('k') | src/interpreter/interpreter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698