diff options
Diffstat (limited to 'compiler/optimizing')
| -rw-r--r-- | compiler/optimizing/code_generator.h | 10 | ||||
| -rw-r--r-- | compiler/optimizing/code_generator_x86.cc | 8 | ||||
| -rw-r--r-- | compiler/optimizing/code_generator_x86_64.cc | 12 |
3 files changed, 20 insertions, 10 deletions
diff --git a/compiler/optimizing/code_generator.h b/compiler/optimizing/code_generator.h index 73202b4fd1..51a0bae799 100644 --- a/compiler/optimizing/code_generator.h +++ b/compiler/optimizing/code_generator.h @@ -446,6 +446,16 @@ class CodeGenerator : public DeletableArenaObject<kArenaAllocCodeGenerator> { return GetFrameSize() == (CallPushesPC() ? GetWordSize() : 0); } + static int8_t GetInt8ValueOf(HConstant* constant) { + DCHECK(constant->IsIntConstant()); + return constant->AsIntConstant()->GetValue(); + } + + static int16_t GetInt16ValueOf(HConstant* constant) { + DCHECK(constant->IsIntConstant()); + return constant->AsIntConstant()->GetValue(); + } + static int32_t GetInt32ValueOf(HConstant* constant) { if (constant->IsIntConstant()) { return constant->AsIntConstant()->GetValue(); diff --git a/compiler/optimizing/code_generator_x86.cc b/compiler/optimizing/code_generator_x86.cc index af0e6462a2..e5549feec6 100644 --- a/compiler/optimizing/code_generator_x86.cc +++ b/compiler/optimizing/code_generator_x86.cc @@ -4956,8 +4956,8 @@ void InstructionCodeGeneratorX86::HandleFieldSet(HInstruction* instruction, case Primitive::kPrimShort: case Primitive::kPrimChar: { if (value.IsConstant()) { - int16_t v = CodeGenerator::GetInt32ValueOf(value.GetConstant()); - __ movw(Address(base, offset), Immediate(v)); + __ movw(Address(base, offset), + Immediate(CodeGenerator::GetInt16ValueOf(value.GetConstant()))); } else { __ movw(Address(base, offset), value.AsRegister<Register>()); } @@ -5404,7 +5404,7 @@ void InstructionCodeGeneratorX86::VisitArraySet(HArraySet* instruction) { if (value.IsRegister()) { __ movb(address, value.AsRegister<ByteRegister>()); } else { - __ movb(address, Immediate(value.GetConstant()->AsIntConstant()->GetValue())); + __ movb(address, Immediate(CodeGenerator::GetInt8ValueOf(value.GetConstant()))); } codegen_->MaybeRecordImplicitNullCheck(instruction); break; @@ -5417,7 +5417,7 @@ void InstructionCodeGeneratorX86::VisitArraySet(HArraySet* instruction) { if (value.IsRegister()) { __ movw(address, value.AsRegister<Register>()); } else { - __ movw(address, Immediate(value.GetConstant()->AsIntConstant()->GetValue())); + __ movw(address, Immediate(CodeGenerator::GetInt16ValueOf(value.GetConstant()))); } codegen_->MaybeRecordImplicitNullCheck(instruction); break; diff --git a/compiler/optimizing/code_generator_x86_64.cc b/compiler/optimizing/code_generator_x86_64.cc index 86f6d51734..8283887a96 100644 --- a/compiler/optimizing/code_generator_x86_64.cc +++ b/compiler/optimizing/code_generator_x86_64.cc @@ -4425,8 +4425,8 @@ void InstructionCodeGeneratorX86_64::HandleFieldSet(HInstruction* instruction, case Primitive::kPrimBoolean: case Primitive::kPrimByte: { if (value.IsConstant()) { - int8_t v = CodeGenerator::GetInt32ValueOf(value.GetConstant()); - __ movb(Address(base, offset), Immediate(v)); + __ movb(Address(base, offset), + Immediate(CodeGenerator::GetInt8ValueOf(value.GetConstant()))); } else { __ movb(Address(base, offset), value.AsRegister<CpuRegister>()); } @@ -4436,8 +4436,8 @@ void InstructionCodeGeneratorX86_64::HandleFieldSet(HInstruction* instruction, case Primitive::kPrimShort: case Primitive::kPrimChar: { if (value.IsConstant()) { - int16_t v = CodeGenerator::GetInt32ValueOf(value.GetConstant()); - __ movw(Address(base, offset), Immediate(v)); + __ movw(Address(base, offset), + Immediate(CodeGenerator::GetInt16ValueOf(value.GetConstant()))); } else { __ movw(Address(base, offset), value.AsRegister<CpuRegister>()); } @@ -4861,7 +4861,7 @@ void InstructionCodeGeneratorX86_64::VisitArraySet(HArraySet* instruction) { if (value.IsRegister()) { __ movb(address, value.AsRegister<CpuRegister>()); } else { - __ movb(address, Immediate(value.GetConstant()->AsIntConstant()->GetValue())); + __ movb(address, Immediate(CodeGenerator::GetInt8ValueOf(value.GetConstant()))); } codegen_->MaybeRecordImplicitNullCheck(instruction); break; @@ -4875,7 +4875,7 @@ void InstructionCodeGeneratorX86_64::VisitArraySet(HArraySet* instruction) { __ movw(address, value.AsRegister<CpuRegister>()); } else { DCHECK(value.IsConstant()) << value; - __ movw(address, Immediate(value.GetConstant()->AsIntConstant()->GetValue())); + __ movw(address, Immediate(CodeGenerator::GetInt16ValueOf(value.GetConstant()))); } codegen_->MaybeRecordImplicitNullCheck(instruction); break; |