| OLD | NEW |
| 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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 return *this; | 175 return *this; |
| 176 } | 176 } |
| 177 | 177 |
| 178 | 178 |
| 179 BytecodeArrayBuilder& BytecodeArrayBuilder::Return() { | 179 BytecodeArrayBuilder& BytecodeArrayBuilder::Return() { |
| 180 Output(Bytecode::kReturn); | 180 Output(Bytecode::kReturn); |
| 181 return *this; | 181 return *this; |
| 182 } | 182 } |
| 183 | 183 |
| 184 | 184 |
| 185 BytecodeArrayBuilder& BytecodeArrayBuilder::CallJS(Register first_arg, |
| 186 size_t arg_count) { |
| 187 if (FitsInByteOperand(arg_count)) { |
| 188 Output(Bytecode::kCallJS, first_arg.ToOperand(), |
| 189 static_cast<uint8_t>(arg_count)); |
| 190 } else { |
| 191 UNIMPLEMENTED(); |
| 192 } |
| 193 return *this; |
| 194 } |
| 195 |
| 196 |
| 185 size_t BytecodeArrayBuilder::GetConstantPoolEntry(Handle<Object> object) { | 197 size_t BytecodeArrayBuilder::GetConstantPoolEntry(Handle<Object> object) { |
| 186 // These constants shouldn't be added to the constant pool, the should use | 198 // These constants shouldn't be added to the constant pool, the should use |
| 187 // specialzed bytecodes instead. | 199 // specialzed bytecodes instead. |
| 188 DCHECK(!object.is_identical_to(isolate_->factory()->undefined_value())); | 200 DCHECK(!object.is_identical_to(isolate_->factory()->undefined_value())); |
| 189 DCHECK(!object.is_identical_to(isolate_->factory()->null_value())); | 201 DCHECK(!object.is_identical_to(isolate_->factory()->null_value())); |
| 190 DCHECK(!object.is_identical_to(isolate_->factory()->the_hole_value())); | 202 DCHECK(!object.is_identical_to(isolate_->factory()->the_hole_value())); |
| 191 DCHECK(!object.is_identical_to(isolate_->factory()->true_value())); | 203 DCHECK(!object.is_identical_to(isolate_->factory()->true_value())); |
| 192 DCHECK(!object.is_identical_to(isolate_->factory()->false_value())); | 204 DCHECK(!object.is_identical_to(isolate_->factory()->false_value())); |
| 193 | 205 |
| 194 size_t* entry = constants_map_.Find(object); | 206 size_t* entry = constants_map_.Find(object); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 218 temporary_register_next_ = reg_index; | 230 temporary_register_next_ = reg_index; |
| 219 } | 231 } |
| 220 | 232 |
| 221 | 233 |
| 222 bool BytecodeArrayBuilder::OperandIsValid(Bytecode bytecode, int operand_index, | 234 bool BytecodeArrayBuilder::OperandIsValid(Bytecode bytecode, int operand_index, |
| 223 uint8_t operand_value) const { | 235 uint8_t operand_value) const { |
| 224 OperandType operand_type = Bytecodes::GetOperandType(bytecode, operand_index); | 236 OperandType operand_type = Bytecodes::GetOperandType(bytecode, operand_index); |
| 225 switch (operand_type) { | 237 switch (operand_type) { |
| 226 case OperandType::kNone: | 238 case OperandType::kNone: |
| 227 return false; | 239 return false; |
| 240 case OperandType::kCount: |
| 228 case OperandType::kImm8: | 241 case OperandType::kImm8: |
| 229 case OperandType::kIdx: | 242 case OperandType::kIdx: |
| 230 return true; | 243 return true; |
| 231 case OperandType::kReg: { | 244 case OperandType::kReg: { |
| 232 Register reg = Register::FromOperand(operand_value); | 245 Register reg = Register::FromOperand(operand_value); |
| 233 if (reg.is_parameter()) { | 246 if (reg.is_parameter()) { |
| 234 int parameter_index = reg.ToParameterIndex(parameter_count_); | 247 int parameter_index = reg.ToParameterIndex(parameter_count_); |
| 235 return parameter_index >= 0 && parameter_index < parameter_count_; | 248 return parameter_index >= 0 && parameter_index < parameter_count_; |
| 236 } else { | 249 } else { |
| 237 return (reg.index() >= 0 && reg.index() < temporary_register_next_); | 250 return (reg.index() >= 0 && reg.index() < temporary_register_next_); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 | 339 |
| 327 Register TemporaryRegisterScope::NewRegister() { | 340 Register TemporaryRegisterScope::NewRegister() { |
| 328 count_++; | 341 count_++; |
| 329 last_register_index_ = builder_->BorrowTemporaryRegister(); | 342 last_register_index_ = builder_->BorrowTemporaryRegister(); |
| 330 return Register(last_register_index_); | 343 return Register(last_register_index_); |
| 331 } | 344 } |
| 332 | 345 |
| 333 } // namespace interpreter | 346 } // namespace interpreter |
| 334 } // namespace internal | 347 } // namespace internal |
| 335 } // namespace v8 | 348 } // namespace v8 |
| OLD | NEW |