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

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

Issue 1325983002: [Intepreter] Extend and move Register class. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix test, bug spotted by bots. Created 5 years, 3 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-array-builder.cc ('k') | src/interpreter/bytecodes.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_BYTECODES_H_ 5 #ifndef V8_INTERPRETER_BYTECODES_H_
6 #define V8_INTERPRETER_BYTECODES_H_ 6 #define V8_INTERPRETER_BYTECODES_H_
7 7
8 #include <iosfwd> 8 #include <iosfwd>
9 9
10 // Clients of this interface shouldn't depend on lots of interpreter internals. 10 // Clients of this interface shouldn't depend on lots of interpreter internals.
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 BYTECODE_LIST(DECLARE_BYTECODE) 69 BYTECODE_LIST(DECLARE_BYTECODE)
70 #undef DECLARE_BYTECODE 70 #undef DECLARE_BYTECODE
71 #define COUNT_BYTECODE(x, ...) +1 71 #define COUNT_BYTECODE(x, ...) +1
72 // The COUNT_BYTECODE macro will turn this into kLast = -1 +1 +1... which will 72 // The COUNT_BYTECODE macro will turn this into kLast = -1 +1 +1... which will
73 // evaluate to the same value as the last real bytecode. 73 // evaluate to the same value as the last real bytecode.
74 kLast = -1 BYTECODE_LIST(COUNT_BYTECODE) 74 kLast = -1 BYTECODE_LIST(COUNT_BYTECODE)
75 #undef COUNT_BYTECODE 75 #undef COUNT_BYTECODE
76 }; 76 };
77 77
78 78
79 // An interpreter register which is located in the function's register file
80 // in its stack-frame. Register hold parameters, this, and expression values.
81 class Register {
82 public:
83 static const int kMaxRegisterIndex = 127;
84 static const int kMinRegisterIndex = -128;
85
86 explicit Register(int index) : index_(index) {
87 DCHECK_LE(index_, kMaxRegisterIndex);
88 DCHECK_GE(index_, kMinRegisterIndex);
89 }
90
91 int index() const { return index_; }
92 bool is_parameter() const { return index_ < 0; }
93
94 static Register FromParameterIndex(int index, int parameter_count);
95 int ToParameterIndex(int parameter_count) const;
96 static int MaxParameterIndex();
97
98 static Register FromOperand(uint8_t operand);
99 uint8_t ToOperand() const;
100
101 private:
102 void* operator new(size_t size);
103 void operator delete(void* p);
104
105 int index_;
106 };
107
108
79 class Bytecodes { 109 class Bytecodes {
80 public: 110 public:
81 // Returns string representation of |bytecode|. 111 // Returns string representation of |bytecode|.
82 static const char* ToString(Bytecode bytecode); 112 static const char* ToString(Bytecode bytecode);
83 113
84 // Returns string representation of |operand_type|. 114 // Returns string representation of |operand_type|.
85 static const char* OperandTypeToString(OperandType operand_type); 115 static const char* OperandTypeToString(OperandType operand_type);
86 116
87 // Returns byte value of bytecode. 117 // Returns byte value of bytecode.
88 static uint8_t ToByte(Bytecode bytecode); 118 static uint8_t ToByte(Bytecode bytecode);
(...skipping 10 matching lines...) Expand all
99 // Returns the size of the bytecode including its operands. 129 // Returns the size of the bytecode including its operands.
100 static int Size(Bytecode bytecode); 130 static int Size(Bytecode bytecode);
101 131
102 // The maximum number of operands across all bytecodes. 132 // The maximum number of operands across all bytecodes.
103 static int MaximumNumberOfOperands(); 133 static int MaximumNumberOfOperands();
104 134
105 // Maximum size of a bytecode and its operands. 135 // Maximum size of a bytecode and its operands.
106 static int MaximumSize(); 136 static int MaximumSize();
107 137
108 // Decode a single bytecode and operands to |os|. 138 // Decode a single bytecode and operands to |os|.
109 static std::ostream& Decode(std::ostream& os, const uint8_t* bytecode_start); 139 static std::ostream& Decode(std::ostream& os, const uint8_t* bytecode_start,
140 int number_of_parameters);
110 141
111 private: 142 private:
112 DISALLOW_IMPLICIT_CONSTRUCTORS(Bytecodes); 143 DISALLOW_IMPLICIT_CONSTRUCTORS(Bytecodes);
113 }; 144 };
114 145
115 std::ostream& operator<<(std::ostream& os, const Bytecode& bytecode); 146 std::ostream& operator<<(std::ostream& os, const Bytecode& bytecode);
116 std::ostream& operator<<(std::ostream& os, const OperandType& operand_type); 147 std::ostream& operator<<(std::ostream& os, const OperandType& operand_type);
117 148
118 } // namespace interpreter 149 } // namespace interpreter
119 } // namespace internal 150 } // namespace internal
120 } // namespace v8 151 } // namespace v8
121 152
122 #endif // V8_INTERPRETER_BYTECODES_H_ 153 #endif // V8_INTERPRETER_BYTECODES_H_
OLDNEW
« no previous file with comments | « src/interpreter/bytecode-array-builder.cc ('k') | src/interpreter/bytecodes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698