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

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: 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
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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadGlobal(int slot_index) { 216 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadGlobal(int slot_index) {
217 DCHECK(slot_index >= 0); 217 DCHECK(slot_index >= 0);
218 if (FitsInIdxOperand(slot_index)) { 218 if (FitsInIdxOperand(slot_index)) {
219 Output(Bytecode::kLdaGlobal, static_cast<uint8_t>(slot_index)); 219 Output(Bytecode::kLdaGlobal, static_cast<uint8_t>(slot_index));
220 } else { 220 } else {
221 UNIMPLEMENTED(); 221 UNIMPLEMENTED();
222 } 222 }
223 return *this; 223 return *this;
224 } 224 }
225 225
226
227 BytecodeArrayBuilder& BytecodeArrayBuilder::StoreGlobal(
228 int slot_index, LanguageMode language_mode) {
229 if (!is_sloppy(language_mode)) {
230 UNIMPLEMENTED();
231 }
232 DCHECK(slot_index >= 0);
233 if (FitsInIdxOperand(slot_index)) {
234 Output(Bytecode::kStaGlobal, static_cast<uint8_t>(slot_index));
235 } else {
236 UNIMPLEMENTED();
237 }
238 return *this;
239 }
240
241
242 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadContextSlot(Register context,
243 int slot_index) {
244 DCHECK(slot_index >= 0);
245 if (FitsInIdxOperand(slot_index)) {
246 Output(Bytecode::kLdaContextSlot, context.ToOperand(),
247 static_cast<uint8_t>(slot_index));
248 } else {
249 UNIMPLEMENTED();
250 }
251 return *this;
252 }
253
254
226 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadNamedProperty( 255 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadNamedProperty(
227 Register object, int feedback_slot, LanguageMode language_mode) { 256 Register object, int feedback_slot, LanguageMode language_mode) {
228 if (!is_sloppy(language_mode)) { 257 if (!is_sloppy(language_mode)) {
229 UNIMPLEMENTED(); 258 UNIMPLEMENTED();
230 } 259 }
231 260
232 if (FitsInIdxOperand(feedback_slot)) { 261 if (FitsInIdxOperand(feedback_slot)) {
233 Output(Bytecode::kLoadIC, object.ToOperand(), 262 Output(Bytecode::kLoadIC, object.ToOperand(),
234 static_cast<uint8_t>(feedback_slot)); 263 static_cast<uint8_t>(feedback_slot));
235 } else { 264 } else {
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 case OperandType::kNone: 557 case OperandType::kNone:
529 return false; 558 return false;
530 case OperandType::kWideIdx: 559 case OperandType::kWideIdx:
531 return static_cast<uint16_t>(operand_value) == operand_value; 560 return static_cast<uint16_t>(operand_value) == operand_value;
532 case OperandType::kCount: 561 case OperandType::kCount:
533 case OperandType::kImm8: 562 case OperandType::kImm8:
534 case OperandType::kIdx: 563 case OperandType::kIdx:
535 return static_cast<uint8_t>(operand_value) == operand_value; 564 return static_cast<uint8_t>(operand_value) == operand_value;
536 case OperandType::kReg: { 565 case OperandType::kReg: {
537 Register reg = Register::FromOperand(static_cast<uint8_t>(operand_value)); 566 Register reg = Register::FromOperand(static_cast<uint8_t>(operand_value));
538 if (reg.is_parameter()) { 567 if (reg.is_function_context()) {
568 return true;
569 } else if (reg.is_parameter()) {
539 int parameter_index = reg.ToParameterIndex(parameter_count_); 570 int parameter_index = reg.ToParameterIndex(parameter_count_);
540 return parameter_index >= 0 && parameter_index < parameter_count_; 571 return parameter_index >= 0 && parameter_index < parameter_count_;
541 } else { 572 } else {
542 return (reg.index() >= 0 && reg.index() < temporary_register_next_); 573 return (reg.index() >= 0 && reg.index() < temporary_register_next_);
543 } 574 }
544 } 575 }
545 } 576 }
546 UNREACHABLE(); 577 UNREACHABLE();
547 return false; 578 return false;
548 } 579 }
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 671
641 Register TemporaryRegisterScope::NewRegister() { 672 Register TemporaryRegisterScope::NewRegister() {
642 count_++; 673 count_++;
643 last_register_index_ = builder_->BorrowTemporaryRegister(); 674 last_register_index_ = builder_->BorrowTemporaryRegister();
644 return Register(last_register_index_); 675 return Register(last_register_index_);
645 } 676 }
646 677
647 } // namespace interpreter 678 } // namespace interpreter
648 } // namespace internal 679 } // namespace internal
649 } // namespace v8 680 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698