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

Side by Side Diff: src/interpreter/bytecode-register.h

Issue 2382273002: [Interpreter]: Add kRegList operand type for register list operands. (Closed)
Patch Set: Address comments Created 4 years, 2 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/bytecode-operands.h ('k') | src/interpreter/bytecode-register.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 #ifndef V8_INTERPRETER_BYTECODE_REGISTER_H_ 5 #ifndef V8_INTERPRETER_BYTECODE_REGISTER_H_
6 #define V8_INTERPRETER_BYTECODE_REGISTER_H_ 6 #define V8_INTERPRETER_BYTECODE_REGISTER_H_
7 7
8 #include "src/interpreter/bytecodes.h" 8 #include "src/interpreter/bytecodes.h"
9 9
10 #include "src/frames.h" 10 #include "src/frames.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 int32_t ToOperand() const { return kRegisterFileStartOffset - index_; } 59 int32_t ToOperand() const { return kRegisterFileStartOffset - index_; }
60 static Register FromOperand(int32_t operand) { 60 static Register FromOperand(int32_t operand) {
61 return Register(kRegisterFileStartOffset - operand); 61 return Register(kRegisterFileStartOffset - operand);
62 } 62 }
63 63
64 static bool AreContiguous(Register reg1, Register reg2, 64 static bool AreContiguous(Register reg1, Register reg2,
65 Register reg3 = Register(), 65 Register reg3 = Register(),
66 Register reg4 = Register(), 66 Register reg4 = Register(),
67 Register reg5 = Register()); 67 Register reg5 = Register());
68 68
69 std::string ToString(int parameter_count); 69 std::string ToString(int parameter_count) const;
70 70
71 bool operator==(const Register& other) const { 71 bool operator==(const Register& other) const {
72 return index() == other.index(); 72 return index() == other.index();
73 } 73 }
74 bool operator!=(const Register& other) const { 74 bool operator!=(const Register& other) const {
75 return index() != other.index(); 75 return index() != other.index();
76 } 76 }
77 bool operator<(const Register& other) const { 77 bool operator<(const Register& other) const {
78 return index() < other.index(); 78 return index() < other.index();
79 } 79 }
(...skipping 11 matching lines...) Expand all
91 static const int kInvalidIndex = kMaxInt; 91 static const int kInvalidIndex = kMaxInt;
92 static const int kRegisterFileStartOffset = 92 static const int kRegisterFileStartOffset =
93 InterpreterFrameConstants::kRegisterFileFromFp / kPointerSize; 93 InterpreterFrameConstants::kRegisterFileFromFp / kPointerSize;
94 94
95 void* operator new(size_t size) = delete; 95 void* operator new(size_t size) = delete;
96 void operator delete(void* p) = delete; 96 void operator delete(void* p) = delete;
97 97
98 int index_; 98 int index_;
99 }; 99 };
100 100
101 class RegisterList {
102 public:
103 RegisterList() : first_reg_index_(Register().index()), register_count_(0) {}
104 RegisterList(int first_reg_index, int register_count)
105 : first_reg_index_(first_reg_index), register_count_(register_count) {}
106
107 // Returns a new RegisterList which is a truncated version of this list, with
108 // |count| registers.
109 const RegisterList Truncate(int new_count) {
110 DCHECK_GE(new_count, 0);
111 DCHECK_LT(new_count, register_count_);
112 return RegisterList(first_reg_index_, new_count);
113 }
114
115 const Register operator[](size_t i) const {
116 DCHECK_LT(static_cast<int>(i), register_count_);
117 return Register(first_reg_index_ + static_cast<int>(i));
118 }
119
120 const Register first_register() const {
121 return (register_count() == 0) ? Register(0) : (*this)[0];
122 }
123
124 const Register last_register() const {
125 return (register_count() == 0) ? Register(0) : (*this)[register_count_ - 1];
126 }
127
128 int register_count() const { return register_count_; }
129
130 private:
131 int first_reg_index_;
132 int register_count_;
133 };
134
101 } // namespace interpreter 135 } // namespace interpreter
102 } // namespace internal 136 } // namespace internal
103 } // namespace v8 137 } // namespace v8
104 138
105 #endif // V8_INTERPRETER_BYTECODE_REGISTER_H_ 139 #endif // V8_INTERPRETER_BYTECODE_REGISTER_H_
OLDNEW
« no previous file with comments | « src/interpreter/bytecode-operands.h ('k') | src/interpreter/bytecode-register.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698