Chromium Code Reviews| Index: src/compiler/interpreter-assembler.cc |
| diff --git a/src/compiler/interpreter-assembler.cc b/src/compiler/interpreter-assembler.cc |
| index 1f5c0a26a5c8f16560cb124e384563c800972c92..e98e79f2b4fc3b1cf4072c8f1a27253e8b1a09d3 100644 |
| --- a/src/compiler/interpreter-assembler.cc |
| +++ b/src/compiler/interpreter-assembler.cc |
| @@ -126,17 +126,25 @@ Node* InterpreterAssembler::StoreRegister(Node* value, Node* reg_index) { |
| Node* InterpreterAssembler::BytecodeOperand(int operand_index) { |
| DCHECK_LT(operand_index, interpreter::Bytecodes::NumberOfOperands(bytecode_)); |
| + DCHECK(interpreter::OperandSize::kByte == |
|
oth
2015/10/01 15:12:15
DCHECK_EQ
rmcilroy
2015/10/01 16:25:07
Done.
|
| + interpreter::Bytecodes::GetOperandSize(bytecode_, operand_index)); |
| return raw_assembler_->Load( |
| kMachUint8, BytecodeArrayTaggedPointer(), |
| - IntPtrAdd(BytecodeOffset(), Int32Constant(1 + operand_index))); |
| + IntPtrAdd(BytecodeOffset(), |
| + Int32Constant(interpreter::Bytecodes::GetOperandOffset( |
| + bytecode_, operand_index)))); |
| } |
| Node* InterpreterAssembler::BytecodeOperandSignExtended(int operand_index) { |
| DCHECK_LT(operand_index, interpreter::Bytecodes::NumberOfOperands(bytecode_)); |
| + DCHECK(interpreter::OperandSize::kByte == |
| + interpreter::Bytecodes::GetOperandSize(bytecode_, operand_index)); |
| Node* load = raw_assembler_->Load( |
| kMachInt8, BytecodeArrayTaggedPointer(), |
| - IntPtrAdd(BytecodeOffset(), Int32Constant(1 + operand_index))); |
| + IntPtrAdd(BytecodeOffset(), |
| + Int32Constant(interpreter::Bytecodes::GetOperandOffset( |
| + bytecode_, operand_index)))); |
| // Ensure that we sign extend to full pointer size |
| if (kPointerSize == 8) { |
| load = raw_assembler_->ChangeInt32ToInt64(load); |
| @@ -145,8 +153,40 @@ Node* InterpreterAssembler::BytecodeOperandSignExtended(int operand_index) { |
| } |
| -Node* InterpreterAssembler::BytecodeOperandCount(int operand_index) { |
| - DCHECK_EQ(interpreter::OperandType::kCount, |
| +Node* InterpreterAssembler::BytecodeOperandShort(int operand_index) { |
| + DCHECK_LT(operand_index, interpreter::Bytecodes::NumberOfOperands(bytecode_)); |
| + DCHECK(interpreter::OperandSize::kShort == |
|
oth
2015/10/01 15:12:14
DCHECK_EQ
rmcilroy
2015/10/01 16:25:07
Done.
|
| + interpreter::Bytecodes::GetOperandSize(bytecode_, operand_index)); |
| + if (TargetSupportsUnalignedAccess()) { |
| + return raw_assembler_->Load( |
| + kMachUint16, BytecodeArrayTaggedPointer(), |
| + IntPtrAdd(BytecodeOffset(), |
| + Int32Constant(interpreter::Bytecodes::GetOperandOffset( |
| + bytecode_, operand_index)))); |
| + } else { |
| + int offset = |
| + interpreter::Bytecodes::GetOperandOffset(bytecode_, operand_index); |
| + Node* first_byte = raw_assembler_->Load( |
| + kMachUint8, BytecodeArrayTaggedPointer(), |
| + IntPtrAdd(BytecodeOffset(), Int32Constant(offset))); |
| + Node* second_byte = raw_assembler_->Load( |
| + kMachUint8, BytecodeArrayTaggedPointer(), |
| + IntPtrAdd(BytecodeOffset(), Int32Constant(offset + 1))); |
| +#if V8_TARGET_LITTLE_ENDIAN |
| + return raw_assembler_->WordOr(WordShl(second_byte, kBitsPerByte), |
| + first_byte); |
| +#elif V8_TARGET_BIG_ENDIAN |
| + return raw_assembler_->WordOr(WordShl(first_byte, kBitsPerByte), |
| + second_byte); |
| +#else |
| +#error "Unknown Architecture" |
| +#endif |
| + } |
| +} |
| + |
| + |
| +Node* InterpreterAssembler::BytecodeOperandCount8(int operand_index) { |
| + DCHECK_EQ(interpreter::OperandType::kCount8, |
| interpreter::Bytecodes::GetOperandType(bytecode_, operand_index)); |
| return BytecodeOperand(operand_index); |
| } |
| @@ -159,20 +199,27 @@ Node* InterpreterAssembler::BytecodeOperandImm8(int operand_index) { |
| } |
| -Node* InterpreterAssembler::BytecodeOperandIdx(int operand_index) { |
| - DCHECK_EQ(interpreter::OperandType::kIdx, |
| +Node* InterpreterAssembler::BytecodeOperandIdx8(int operand_index) { |
| + DCHECK_EQ(interpreter::OperandType::kIdx8, |
| interpreter::Bytecodes::GetOperandType(bytecode_, operand_index)); |
| return BytecodeOperand(operand_index); |
| } |
| -Node* InterpreterAssembler::BytecodeOperandReg(int operand_index) { |
| - DCHECK_EQ(interpreter::OperandType::kReg, |
| +Node* InterpreterAssembler::BytecodeOperandReg8(int operand_index) { |
| + DCHECK_EQ(interpreter::OperandType::kReg8, |
| interpreter::Bytecodes::GetOperandType(bytecode_, operand_index)); |
| return BytecodeOperandSignExtended(operand_index); |
| } |
| +Node* InterpreterAssembler::BytecodeOperandIdx16(int operand_index) { |
| + DCHECK_EQ(interpreter::OperandType::kIdx16, |
| + interpreter::Bytecodes::GetOperandType(bytecode_, operand_index)); |
| + return BytecodeOperandShort(operand_index); |
| +} |
| + |
| + |
| Node* InterpreterAssembler::Int32Constant(int value) { |
| return raw_assembler_->Int32Constant(value); |
| } |
| @@ -432,6 +479,20 @@ void InterpreterAssembler::End() { |
| } |
| +// static |
| +bool InterpreterAssembler::TargetSupportsUnalignedAccess() { |
| +#if V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 |
| + return false; |
| +#elif V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_PPC |
| + return CpuFeatures::IsSupported(UNALIGNED_ACCESSES); |
| +#elif V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_X87 |
| + return true; |
| +#else |
| +#error "Unknown Architecture" |
| +#endif |
| +} |
| + |
| + |
| // RawMachineAssembler delegate helpers: |
| Isolate* InterpreterAssembler::isolate() { return raw_assembler_->isolate(); } |