| 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/compiler/interpreter-assembler.h" | 5 #include "src/compiler/interpreter-assembler.h" |
| 6 | 6 |
| 7 #include <ostream> | 7 #include <ostream> |
| 8 | 8 |
| 9 #include "src/code-factory.h" | 9 #include "src/code-factory.h" |
| 10 #include "src/compiler/graph.h" | 10 #include "src/compiler/graph.h" |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 #elif V8_TARGET_BIG_ENDIAN | 202 #elif V8_TARGET_BIG_ENDIAN |
| 203 return raw_assembler_->WordOr(WordShl(first_byte, kBitsPerByte), | 203 return raw_assembler_->WordOr(WordShl(first_byte, kBitsPerByte), |
| 204 second_byte); | 204 second_byte); |
| 205 #else | 205 #else |
| 206 #error "Unknown Architecture" | 206 #error "Unknown Architecture" |
| 207 #endif | 207 #endif |
| 208 } | 208 } |
| 209 } | 209 } |
| 210 | 210 |
| 211 | 211 |
| 212 Node* InterpreterAssembler::BytecodeOperandShortSignExtended( |
| 213 int operand_index) { |
| 214 DCHECK_LT(operand_index, interpreter::Bytecodes::NumberOfOperands(bytecode_)); |
| 215 DCHECK_EQ(interpreter::OperandSize::kShort, |
| 216 interpreter::Bytecodes::GetOperandSize(bytecode_, operand_index)); |
| 217 int operand_offset = |
| 218 interpreter::Bytecodes::GetOperandOffset(bytecode_, operand_index); |
| 219 Node* load; |
| 220 if (TargetSupportsUnalignedAccess()) { |
| 221 load = raw_assembler_->Load( |
| 222 MachineType::Int16(), BytecodeArrayTaggedPointer(), |
| 223 IntPtrAdd(BytecodeOffset(), Int32Constant(operand_offset))); |
| 224 } else { |
| 225 #if V8_TARGET_LITTLE_ENDIAN |
| 226 Node* hi_byte_offset = Int32Constant(operand_offset + 1); |
| 227 Node* lo_byte_offset = Int32Constant(operand_offset); |
| 228 #elif V8_TARGET_BIG_ENDIAN |
| 229 Node* hi_byte_offset = Int32Constant(operand_offset); |
| 230 Node* lo_byte_offset = Int32Constant(operand_offset + 1); |
| 231 #else |
| 232 #error "Unknown Architecture" |
| 233 #endif |
| 234 Node* hi_byte = |
| 235 raw_assembler_->Load(MachineType::Int8(), BytecodeArrayTaggedPointer(), |
| 236 IntPtrAdd(BytecodeOffset(), hi_byte_offset)); |
| 237 Node* lo_byte = |
| 238 raw_assembler_->Load(MachineType::Uint8(), BytecodeArrayTaggedPointer(), |
| 239 IntPtrAdd(BytecodeOffset(), lo_byte_offset)); |
| 240 hi_byte = raw_assembler_->Word32Shl(hi_byte, Int32Constant(kBitsPerByte)); |
| 241 load = raw_assembler_->Word32Or(hi_byte, lo_byte); |
| 242 } |
| 243 |
| 244 // Ensure that we sign extend to full pointer size |
| 245 if (kPointerSize == 8) { |
| 246 load = raw_assembler_->ChangeInt32ToInt64(load); |
| 247 } |
| 248 return load; |
| 249 } |
| 250 |
| 251 |
| 212 Node* InterpreterAssembler::BytecodeOperandCount(int operand_index) { | 252 Node* InterpreterAssembler::BytecodeOperandCount(int operand_index) { |
| 213 switch (interpreter::Bytecodes::GetOperandSize(bytecode_, operand_index)) { | 253 switch (interpreter::Bytecodes::GetOperandSize(bytecode_, operand_index)) { |
| 214 case interpreter::OperandSize::kByte: | 254 case interpreter::OperandSize::kByte: |
| 215 DCHECK_EQ( | 255 DCHECK_EQ( |
| 216 interpreter::OperandType::kCount8, | 256 interpreter::OperandType::kCount8, |
| 217 interpreter::Bytecodes::GetOperandType(bytecode_, operand_index)); | 257 interpreter::Bytecodes::GetOperandType(bytecode_, operand_index)); |
| 218 return BytecodeOperand(operand_index); | 258 return BytecodeOperand(operand_index); |
| 219 case interpreter::OperandSize::kShort: | 259 case interpreter::OperandSize::kShort: |
| 220 DCHECK_EQ( | 260 DCHECK_EQ( |
| 221 interpreter::OperandType::kCount16, | 261 interpreter::OperandType::kCount16, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 248 interpreter::Bytecodes::GetOperandType(bytecode_, operand_index)); | 288 interpreter::Bytecodes::GetOperandType(bytecode_, operand_index)); |
| 249 return BytecodeOperandShort(operand_index); | 289 return BytecodeOperandShort(operand_index); |
| 250 default: | 290 default: |
| 251 UNREACHABLE(); | 291 UNREACHABLE(); |
| 252 return nullptr; | 292 return nullptr; |
| 253 } | 293 } |
| 254 } | 294 } |
| 255 | 295 |
| 256 | 296 |
| 257 Node* InterpreterAssembler::BytecodeOperandReg(int operand_index) { | 297 Node* InterpreterAssembler::BytecodeOperandReg(int operand_index) { |
| 258 #ifdef DEBUG | 298 switch (interpreter::Bytecodes::GetOperandType(bytecode_, operand_index)) { |
| 259 interpreter::OperandType operand_type = | 299 case interpreter::OperandType::kReg8: |
| 260 interpreter::Bytecodes::GetOperandType(bytecode_, operand_index); | 300 case interpreter::OperandType::kMaybeReg8: |
| 261 DCHECK(operand_type == interpreter::OperandType::kReg8 || | 301 DCHECK_EQ( |
| 262 operand_type == interpreter::OperandType::kMaybeReg8); | 302 interpreter::OperandSize::kByte, |
| 263 #endif | 303 interpreter::Bytecodes::GetOperandSize(bytecode_, operand_index)); |
| 264 return BytecodeOperandSignExtended(operand_index); | 304 return BytecodeOperandSignExtended(operand_index); |
| 305 case interpreter::OperandType::kReg16: |
| 306 DCHECK_EQ( |
| 307 interpreter::OperandSize::kShort, |
| 308 interpreter::Bytecodes::GetOperandSize(bytecode_, operand_index)); |
| 309 return BytecodeOperandShortSignExtended(operand_index); |
| 310 default: |
| 311 UNREACHABLE(); |
| 312 return nullptr; |
| 313 } |
| 265 } | 314 } |
| 266 | 315 |
| 267 | 316 |
| 268 Node* InterpreterAssembler::Int32Constant(int value) { | 317 Node* InterpreterAssembler::Int32Constant(int value) { |
| 269 return raw_assembler_->Int32Constant(value); | 318 return raw_assembler_->Int32Constant(value); |
| 270 } | 319 } |
| 271 | 320 |
| 272 | 321 |
| 273 Node* InterpreterAssembler::IntPtrConstant(intptr_t value) { | 322 Node* InterpreterAssembler::IntPtrConstant(intptr_t value) { |
| 274 return raw_assembler_->IntPtrConstant(value); | 323 return raw_assembler_->IntPtrConstant(value); |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 686 return raw_assembler_->call_descriptor(); | 735 return raw_assembler_->call_descriptor(); |
| 687 } | 736 } |
| 688 | 737 |
| 689 | 738 |
| 690 Zone* InterpreterAssembler::zone() { return raw_assembler_->zone(); } | 739 Zone* InterpreterAssembler::zone() { return raw_assembler_->zone(); } |
| 691 | 740 |
| 692 | 741 |
| 693 } // namespace compiler | 742 } // namespace compiler |
| 694 } // namespace internal | 743 } // namespace internal |
| 695 } // namespace v8 | 744 } // namespace v8 |
| OLD | NEW |