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

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

Issue 1378523005: [Interpreter] Add support for global declarations and load/store of global variables (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@int_toplevel
Patch Set: Fix test Created 5 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-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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadGlobal(int slot_index) { 234 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadGlobal(int slot_index) {
235 DCHECK(slot_index >= 0); 235 DCHECK(slot_index >= 0);
236 if (FitsInIdx8Operand(slot_index)) { 236 if (FitsInIdx8Operand(slot_index)) {
237 Output(Bytecode::kLdaGlobal, static_cast<uint8_t>(slot_index)); 237 Output(Bytecode::kLdaGlobal, static_cast<uint8_t>(slot_index));
238 } else { 238 } else {
239 UNIMPLEMENTED(); 239 UNIMPLEMENTED();
240 } 240 }
241 return *this; 241 return *this;
242 } 242 }
243 243
244
245 BytecodeArrayBuilder& BytecodeArrayBuilder::StoreGlobal(
246 int slot_index, LanguageMode language_mode) {
247 if (!is_sloppy(language_mode)) {
248 UNIMPLEMENTED();
249 }
250 DCHECK(slot_index >= 0);
251 if (FitsInIdx8Operand(slot_index)) {
252 Output(Bytecode::kStaGlobal, static_cast<uint8_t>(slot_index));
253 } else {
254 UNIMPLEMENTED();
255 }
256 return *this;
257 }
258
259
260 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadContextSlot(Register context,
261 int slot_index) {
262 DCHECK(slot_index >= 0);
263 if (FitsInIdx8Operand(slot_index)) {
264 Output(Bytecode::kLdaContextSlot, context.ToOperand(),
265 static_cast<uint8_t>(slot_index));
266 } else {
267 UNIMPLEMENTED();
268 }
269 return *this;
270 }
271
272
244 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadNamedProperty( 273 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadNamedProperty(
245 Register object, int feedback_slot, LanguageMode language_mode) { 274 Register object, int feedback_slot, LanguageMode language_mode) {
246 Bytecode bytecode = BytecodeForLoadIC(language_mode); 275 Bytecode bytecode = BytecodeForLoadIC(language_mode);
247 if (FitsInIdx8Operand(feedback_slot)) { 276 if (FitsInIdx8Operand(feedback_slot)) {
248 Output(bytecode, object.ToOperand(), static_cast<uint8_t>(feedback_slot)); 277 Output(bytecode, object.ToOperand(), static_cast<uint8_t>(feedback_slot));
249 } else { 278 } else {
250 UNIMPLEMENTED(); 279 UNIMPLEMENTED();
251 } 280 }
252 return *this; 281 return *this;
253 } 282 }
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 case OperandType::kNone: 564 case OperandType::kNone:
536 return false; 565 return false;
537 case OperandType::kIdx16: 566 case OperandType::kIdx16:
538 return static_cast<uint16_t>(operand_value) == operand_value; 567 return static_cast<uint16_t>(operand_value) == operand_value;
539 case OperandType::kCount8: 568 case OperandType::kCount8:
540 case OperandType::kImm8: 569 case OperandType::kImm8:
541 case OperandType::kIdx8: 570 case OperandType::kIdx8:
542 return static_cast<uint8_t>(operand_value) == operand_value; 571 return static_cast<uint8_t>(operand_value) == operand_value;
543 case OperandType::kReg8: { 572 case OperandType::kReg8: {
544 Register reg = Register::FromOperand(static_cast<uint8_t>(operand_value)); 573 Register reg = Register::FromOperand(static_cast<uint8_t>(operand_value));
545 if (reg.is_parameter()) { 574 if (reg.is_function_context()) {
575 return true;
576 } else if (reg.is_parameter()) {
546 int parameter_index = reg.ToParameterIndex(parameter_count_); 577 int parameter_index = reg.ToParameterIndex(parameter_count_);
547 return parameter_index >= 0 && parameter_index < parameter_count_; 578 return parameter_index >= 0 && parameter_index < parameter_count_;
548 } else { 579 } else {
549 return (reg.index() >= 0 && reg.index() < temporary_register_next_); 580 return (reg.index() >= 0 && reg.index() < temporary_register_next_);
550 } 581 }
551 } 582 }
552 } 583 }
553 UNREACHABLE(); 584 UNREACHABLE();
554 return false; 585 return false;
555 } 586 }
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 744
714 Register TemporaryRegisterScope::NewRegister() { 745 Register TemporaryRegisterScope::NewRegister() {
715 count_++; 746 count_++;
716 last_register_index_ = builder_->BorrowTemporaryRegister(); 747 last_register_index_ = builder_->BorrowTemporaryRegister();
717 return Register(last_register_index_); 748 return Register(last_register_index_);
718 } 749 }
719 750
720 } // namespace interpreter 751 } // namespace interpreter
721 } // namespace internal 752 } // namespace internal
722 } // namespace v8 753 } // 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