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

Side by Side Diff: src/interpreter/bytecode-array-builder.cc

Issue 1309843007: [Interpreter] Add support for property load operations. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Remove templated FitsInOperand since std::is_integral is not supported on Mac 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.h ('k') | src/interpreter/bytecode-generator.h » ('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/bytecode-array-builder.h" 5 #include "src/interpreter/bytecode-array-builder.h"
6 6
7 namespace v8 { 7 namespace v8 {
8 namespace internal { 8 namespace internal {
9 namespace interpreter { 9 namespace interpreter {
10 10
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 Output(Bytecode::kLdaSmi8, static_cast<uint8_t>(raw_smi)); 84 Output(Bytecode::kLdaSmi8, static_cast<uint8_t>(raw_smi));
85 } else { 85 } else {
86 LoadLiteral(Handle<Object>(smi, isolate_)); 86 LoadLiteral(Handle<Object>(smi, isolate_));
87 } 87 }
88 return *this; 88 return *this;
89 } 89 }
90 90
91 91
92 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadLiteral(Handle<Object> object) { 92 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadLiteral(Handle<Object> object) {
93 size_t entry = GetConstantPoolEntry(object); 93 size_t entry = GetConstantPoolEntry(object);
94 if (entry <= 255) { 94 if (FitsInByteOperand(entry)) {
95 Output(Bytecode::kLdaConstant, static_cast<uint8_t>(entry)); 95 Output(Bytecode::kLdaConstant, static_cast<uint8_t>(entry));
96 } else { 96 } else {
97 UNIMPLEMENTED(); 97 UNIMPLEMENTED();
98 } 98 }
99 return *this; 99 return *this;
100 } 100 }
101 101
102 102
103 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadUndefined() { 103 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadUndefined() {
104 Output(Bytecode::kLdaUndefined); 104 Output(Bytecode::kLdaUndefined);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 } 137 }
138 138
139 139
140 BytecodeArrayBuilder& BytecodeArrayBuilder::StoreAccumulatorInRegister( 140 BytecodeArrayBuilder& BytecodeArrayBuilder::StoreAccumulatorInRegister(
141 Register reg) { 141 Register reg) {
142 Output(Bytecode::kStar, reg.ToOperand()); 142 Output(Bytecode::kStar, reg.ToOperand());
143 return *this; 143 return *this;
144 } 144 }
145 145
146 146
147 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadNamedProperty(
148 Register object, int feedback_slot, LanguageMode language_mode) {
149 if (is_strong(language_mode)) {
150 UNIMPLEMENTED();
151 }
152
153 if (FitsInByteOperand(feedback_slot)) {
154 Output(Bytecode::kLoadIC, object.ToOperand(),
155 static_cast<uint8_t>(feedback_slot));
156 } else {
157 UNIMPLEMENTED();
158 }
159 return *this;
160 }
161
162
163 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadKeyedProperty(
164 Register object, int feedback_slot, LanguageMode language_mode) {
165 if (is_strong(language_mode)) {
166 UNIMPLEMENTED();
167 }
168
169 if (FitsInByteOperand(feedback_slot)) {
170 Output(Bytecode::kKeyedLoadIC, object.ToOperand(),
171 static_cast<uint8_t>(feedback_slot));
172 } else {
173 UNIMPLEMENTED();
174 }
175 return *this;
176 }
177
178
147 BytecodeArrayBuilder& BytecodeArrayBuilder::Return() { 179 BytecodeArrayBuilder& BytecodeArrayBuilder::Return() {
148 Output(Bytecode::kReturn); 180 Output(Bytecode::kReturn);
149 return *this; 181 return *this;
150 } 182 }
151 183
152 184
153 size_t BytecodeArrayBuilder::GetConstantPoolEntry(Handle<Object> object) { 185 size_t BytecodeArrayBuilder::GetConstantPoolEntry(Handle<Object> object) {
154 // These constants shouldn't be added to the constant pool, the should use 186 // These constants shouldn't be added to the constant pool, the should use
155 // specialzed bytecodes instead. 187 // specialzed bytecodes instead.
156 DCHECK(!object.is_identical_to(isolate_->factory()->undefined_value())); 188 DCHECK(!object.is_identical_to(isolate_->factory()->undefined_value()));
(...skipping 30 matching lines...) Expand all
187 } 219 }
188 220
189 221
190 bool BytecodeArrayBuilder::OperandIsValid(Bytecode bytecode, int operand_index, 222 bool BytecodeArrayBuilder::OperandIsValid(Bytecode bytecode, int operand_index,
191 uint8_t operand_value) const { 223 uint8_t operand_value) const {
192 OperandType operand_type = Bytecodes::GetOperandType(bytecode, operand_index); 224 OperandType operand_type = Bytecodes::GetOperandType(bytecode, operand_index);
193 switch (operand_type) { 225 switch (operand_type) {
194 case OperandType::kNone: 226 case OperandType::kNone:
195 return false; 227 return false;
196 case OperandType::kImm8: 228 case OperandType::kImm8:
229 case OperandType::kIdx:
197 return true; 230 return true;
198 case OperandType::kIdx:
199 return operand_value < constants_.size();
200 case OperandType::kReg: { 231 case OperandType::kReg: {
201 int reg_index = Register::FromOperand(operand_value).index(); 232 int reg_index = Register::FromOperand(operand_value).index();
202 return (reg_index >= 0 && reg_index < temporary_register_next_) || 233 return (reg_index >= 0 && reg_index < temporary_register_next_) ||
203 (reg_index <= kLastParamRegisterIndex && 234 (reg_index <= kLastParamRegisterIndex &&
204 reg_index > kLastParamRegisterIndex - parameter_count_); 235 reg_index > kLastParamRegisterIndex - parameter_count_);
205 } 236 }
206 } 237 }
207 UNREACHABLE(); 238 UNREACHABLE();
208 return false; 239 return false;
209 } 240 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 return Bytecode::kDiv; 291 return Bytecode::kDiv;
261 case Token::Value::MOD: 292 case Token::Value::MOD:
262 return Bytecode::kMod; 293 return Bytecode::kMod;
263 default: 294 default:
264 UNIMPLEMENTED(); 295 UNIMPLEMENTED();
265 return static_cast<Bytecode>(-1); 296 return static_cast<Bytecode>(-1);
266 } 297 }
267 } 298 }
268 299
269 300
301 // static
302 bool BytecodeArrayBuilder::FitsInByteOperand(int value) {
303 return 0 <= value && value <= 255;
304 }
305
306
307 // static
308 bool BytecodeArrayBuilder::FitsInByteOperand(size_t value) {
309 return value <= 255;
310 }
311
312
270 TemporaryRegisterScope::TemporaryRegisterScope(BytecodeArrayBuilder* builder) 313 TemporaryRegisterScope::TemporaryRegisterScope(BytecodeArrayBuilder* builder)
271 : builder_(builder), count_(0), last_register_index_(-1) {} 314 : builder_(builder), count_(0), last_register_index_(-1) {}
272 315
273 316
274 TemporaryRegisterScope::~TemporaryRegisterScope() { 317 TemporaryRegisterScope::~TemporaryRegisterScope() {
275 while (count_-- != 0) { 318 while (count_-- != 0) {
276 builder_->ReturnTemporaryRegister(last_register_index_--); 319 builder_->ReturnTemporaryRegister(last_register_index_--);
277 } 320 }
278 } 321 }
279 322
280 323
281 Register TemporaryRegisterScope::NewRegister() { 324 Register TemporaryRegisterScope::NewRegister() {
282 count_++; 325 count_++;
283 last_register_index_ = builder_->BorrowTemporaryRegister(); 326 last_register_index_ = builder_->BorrowTemporaryRegister();
284 return Register(last_register_index_); 327 return Register(last_register_index_);
285 } 328 }
286 329
287 } // namespace interpreter 330 } // namespace interpreter
288 } // namespace internal 331 } // namespace internal
289 } // namespace v8 332 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/bytecode-array-builder.h ('k') | src/interpreter/bytecode-generator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698