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

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

Issue 2100793003: [interpreter] Streamline bytecode array writing. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase. 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 | « src/interpreter/bytecodes.h ('k') | test/unittests/interpreter/bytecodes-unittest.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 <iomanip> 7 #include <iomanip>
8 8
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/frames.h" 10 #include "src/frames.h"
11 #include "src/interpreter/bytecode-traits.h" 11 #include "src/interpreter/bytecode-traits.h"
12 #include "src/interpreter/interpreter.h" 12 #include "src/interpreter/interpreter.h"
13 13
14 namespace v8 { 14 namespace v8 {
15 namespace internal { 15 namespace internal {
16 namespace interpreter { 16 namespace interpreter {
17 17
18 STATIC_CONST_MEMBER_DEFINITION const int Bytecodes::kMaxOperands;
18 19
19 // static 20 // static
20 const char* Bytecodes::ToString(Bytecode bytecode) { 21 const char* Bytecodes::ToString(Bytecode bytecode) {
21 switch (bytecode) { 22 switch (bytecode) {
22 #define CASE(Name, ...) \ 23 #define CASE(Name, ...) \
23 case Bytecode::k##Name: \ 24 case Bytecode::k##Name: \
24 return #Name; 25 return #Name;
25 BYTECODE_LIST(CASE) 26 BYTECODE_LIST(CASE)
26 #undef CASE 27 #undef CASE
27 } 28 }
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 #undef CASE 336 #undef CASE
336 } 337 }
337 UNREACHABLE(); 338 UNREACHABLE();
338 return nullptr; 339 return nullptr;
339 } 340 }
340 341
341 // static 342 // static
342 OperandSize Bytecodes::GetOperandSize(Bytecode bytecode, int i, 343 OperandSize Bytecodes::GetOperandSize(Bytecode bytecode, int i,
343 OperandScale operand_scale) { 344 OperandScale operand_scale) {
344 DCHECK_LT(i, NumberOfOperands(bytecode)); 345 DCHECK_LT(i, NumberOfOperands(bytecode));
345 return GetOperandSizes(bytecode, operand_scale)[i]; 346 OperandType operand_type = GetOperandType(bytecode, i);
347 return SizeOfOperand(operand_type, operand_scale);
346 } 348 }
347 349
348 // static 350 // static
349 const OperandSize* Bytecodes::GetOperandSizes(Bytecode bytecode,
350 OperandScale operand_scale) {
351 DCHECK(bytecode <= Bytecode::kLast);
352 switch (bytecode) {
353 #define CASE(Name, ...) \
354 case Bytecode::k##Name: \
355 return BytecodeTraits<__VA_ARGS__>::GetOperandSizes(operand_scale);
356 BYTECODE_LIST(CASE)
357 #undef CASE
358 }
359 UNREACHABLE();
360 return nullptr;
361 }
362
363 // static
364 int Bytecodes::GetRegisterOperandBitmap(Bytecode bytecode) {
365 DCHECK(bytecode <= Bytecode::kLast);
366 switch (bytecode) {
367 #define CASE(Name, ...) \
368 case Bytecode::k##Name: \
369 typedef BytecodeTraits<__VA_ARGS__> Name##Trait; \
370 return Name##Trait::kRegisterOperandBitmap;
371 BYTECODE_LIST(CASE)
372 #undef CASE
373 }
374 UNREACHABLE();
375 return false;
376 }
377
378 // static
379 int Bytecodes::GetOperandOffset(Bytecode bytecode, int i, 351 int Bytecodes::GetOperandOffset(Bytecode bytecode, int i,
380 OperandScale operand_scale) { 352 OperandScale operand_scale) {
381 DCHECK_LT(i, Bytecodes::NumberOfOperands(bytecode)); 353 DCHECK_LT(i, Bytecodes::NumberOfOperands(bytecode));
382 // TODO(oth): restore this to a statically determined constant. 354 // TODO(oth): restore this to a statically determined constant.
383 int offset = 1; 355 int offset = 1;
384 for (int operand_index = 0; operand_index < i; ++operand_index) { 356 for (int operand_index = 0; operand_index < i; ++operand_index) {
385 OperandSize operand_size = 357 OperandSize operand_size =
386 GetOperandSize(bytecode, operand_index, operand_scale); 358 GetOperandSize(bytecode, operand_index, operand_scale);
387 offset += static_cast<int>(operand_size); 359 offset += static_cast<int>(operand_size);
388 } 360 }
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 case OperandType::kMaybeReg: 568 case OperandType::kMaybeReg:
597 case OperandType::kReg: 569 case OperandType::kReg:
598 case OperandType::kRegOut: 570 case OperandType::kRegOut:
599 return 1; 571 return 1;
600 case OperandType::kRegPair: 572 case OperandType::kRegPair:
601 case OperandType::kRegOutPair: 573 case OperandType::kRegOutPair:
602 return 2; 574 return 2;
603 case OperandType::kRegOutTriple: 575 case OperandType::kRegOutTriple:
604 return 3; 576 return 3;
605 default: 577 default:
606 UNREACHABLE(); 578 return 0;
607 } 579 }
608 return 0; 580 return 0;
609 } 581 }
610 582
611 // static 583 // static
612 bool Bytecodes::IsUnsignedOperandType(OperandType operand_type) { 584 bool Bytecodes::IsUnsignedOperandType(OperandType operand_type) {
613 switch (operand_type) { 585 switch (operand_type) {
614 #define CASE(Name, _) \ 586 #define CASE(Name, _) \
615 case OperandType::k##Name: \ 587 case OperandType::k##Name: \
616 return OperandTraits<OperandType::k##Name>::TypeInfoTraits::kIsUnsigned; 588 return OperandTraits<OperandType::k##Name>::TypeInfoTraits::kIsUnsigned;
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
940 } else { 912 } else {
941 std::ostringstream s; 913 std::ostringstream s;
942 s << "r" << index(); 914 s << "r" << index();
943 return s.str(); 915 return s.str();
944 } 916 }
945 } 917 }
946 918
947 } // namespace interpreter 919 } // namespace interpreter
948 } // namespace internal 920 } // namespace internal
949 } // namespace v8 921 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/bytecodes.h ('k') | test/unittests/interpreter/bytecodes-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698