Index: src/interpreter/bytecode-array-builder.cc |
diff --git a/src/interpreter/bytecode-array-builder.cc b/src/interpreter/bytecode-array-builder.cc |
index 989fb2d17749c9c54fbabdd4e24696ee3a09db4d..83cf036400e3a82377d1e1ab210837eff0763ed1 100644 |
--- a/src/interpreter/bytecode-array-builder.cc |
+++ b/src/interpreter/bytecode-array-builder.cc |
@@ -91,7 +91,7 @@ BytecodeArrayBuilder& BytecodeArrayBuilder::LoadLiteral( |
BytecodeArrayBuilder& BytecodeArrayBuilder::LoadLiteral(Handle<Object> object) { |
size_t entry = GetConstantPoolEntry(object); |
- if (entry <= 255) { |
+ if (FitsInByteOperand(entry)) { |
Output(Bytecode::kLdaConstant, static_cast<uint8_t>(entry)); |
} else { |
UNIMPLEMENTED(); |
@@ -144,6 +144,38 @@ BytecodeArrayBuilder& BytecodeArrayBuilder::StoreAccumulatorInRegister( |
} |
+BytecodeArrayBuilder& BytecodeArrayBuilder::LoadNamedProperty( |
+ Register object, int feedback_slot, LanguageMode language_mode) { |
+ if (is_strong(language_mode)) { |
+ UNIMPLEMENTED(); |
+ } |
+ |
+ if (FitsInByteOperand(feedback_slot)) { |
+ Output(Bytecode::kLoadIC, object.ToOperand(), |
+ static_cast<uint8_t>(feedback_slot)); |
+ } else { |
+ UNIMPLEMENTED(); |
+ } |
+ return *this; |
+} |
+ |
+ |
+BytecodeArrayBuilder& BytecodeArrayBuilder::LoadKeyedProperty( |
+ Register object, int feedback_slot, LanguageMode language_mode) { |
+ if (is_strong(language_mode)) { |
+ UNIMPLEMENTED(); |
+ } |
+ |
+ if (FitsInByteOperand(feedback_slot)) { |
+ Output(Bytecode::kKeyedLoadIC, object.ToOperand(), |
+ static_cast<uint8_t>(feedback_slot)); |
+ } else { |
+ UNIMPLEMENTED(); |
+ } |
+ return *this; |
+} |
+ |
+ |
BytecodeArrayBuilder& BytecodeArrayBuilder::Return() { |
Output(Bytecode::kReturn); |
return *this; |
@@ -194,9 +226,8 @@ bool BytecodeArrayBuilder::OperandIsValid(Bytecode bytecode, int operand_index, |
case OperandType::kNone: |
return false; |
case OperandType::kImm8: |
- return true; |
case OperandType::kIdx: |
- return operand_value < constants_.size(); |
+ return true; |
case OperandType::kReg: { |
int reg_index = Register::FromOperand(operand_value).index(); |
return (reg_index >= 0 && reg_index < temporary_register_next_) || |
@@ -267,6 +298,18 @@ Bytecode BytecodeArrayBuilder::BytecodeForBinaryOperation(Token::Value op) { |
} |
+// static |
+bool BytecodeArrayBuilder::FitsInByteOperand(int value) { |
+ return 0 <= value && value <= 255; |
+} |
+ |
+ |
+// static |
+bool BytecodeArrayBuilder::FitsInByteOperand(size_t value) { |
+ return value <= 255; |
+} |
+ |
+ |
TemporaryRegisterScope::TemporaryRegisterScope(BytecodeArrayBuilder* builder) |
: builder_(builder), count_(0), last_register_index_(-1) {} |