diff options
| author | 2014-10-30 17:04:55 +0000 | |
|---|---|---|
| committer | 2014-10-30 17:04:56 +0000 | |
| commit | db32ffec0867d4eea801d021361c8b95015e1d1c (patch) | |
| tree | 6e55afea5e0fd39eb4970b2ce3e689c4c0439857 /compiler/optimizing | |
| parent | d8e231c0f3f7349c89b2323af6313384353e4cc5 (diff) | |
| parent | 0a6c459f713ff61769a02204cd736167e062bf4c (diff) | |
Merge "Fix for long parameter passed both in stack and register."
Diffstat (limited to 'compiler/optimizing')
| -rw-r--r-- | compiler/optimizing/code_generator_arm.cc | 27 | ||||
| -rw-r--r-- | compiler/optimizing/code_generator_x86.cc | 29 | ||||
| -rw-r--r-- | compiler/optimizing/locations.h | 13 |
3 files changed, 41 insertions, 28 deletions
diff --git a/compiler/optimizing/code_generator_arm.cc b/compiler/optimizing/code_generator_arm.cc index a06860a5b6..0f14436539 100644 --- a/compiler/optimizing/code_generator_arm.cc +++ b/compiler/optimizing/code_generator_arm.cc @@ -446,7 +446,7 @@ Location InvokeDexCallingConventionVisitor::GetNextLocation(Primitive::Type type calling_convention.GetRegisterPairAt(index)); return Location::RegisterPairLocation(pair.AsRegisterPairLow(), pair.AsRegisterPairHigh()); } else if (index + 1 == calling_convention.GetNumberOfRegisters()) { - return Location::QuickParameter(stack_index); + return Location::QuickParameter(index, stack_index); } else { return Location::DoubleStackSlot(calling_convention.GetStackOffsetOf(stack_index)); } @@ -561,12 +561,13 @@ void CodeGeneratorARM::Move64(Location destination, Location source) { } else if (source.IsFpuRegister()) { UNIMPLEMENTED(FATAL); } else if (source.IsQuickParameter()) { - uint32_t argument_index = source.GetQuickParameterIndex(); + uint16_t register_index = source.GetQuickParameterRegisterIndex(); + uint16_t stack_index = source.GetQuickParameterStackIndex(); InvokeDexCallingConvention calling_convention; __ Mov(destination.AsRegisterPairLow<Register>(), - calling_convention.GetRegisterAt(argument_index)); + calling_convention.GetRegisterAt(register_index)); __ LoadFromOffset(kLoadWord, destination.AsRegisterPairHigh<Register>(), - SP, calling_convention.GetStackOffsetOf(argument_index + 1) + GetFrameSize()); + SP, calling_convention.GetStackOffsetOf(stack_index + 1) + GetFrameSize()); } else { DCHECK(source.IsDoubleStackSlot()); if (destination.AsRegisterPairLow<Register>() == R1) { @@ -588,20 +589,21 @@ void CodeGeneratorARM::Move64(Location destination, Location source) { } } else if (destination.IsQuickParameter()) { InvokeDexCallingConvention calling_convention; - uint32_t argument_index = destination.GetQuickParameterIndex(); + uint16_t register_index = destination.GetQuickParameterRegisterIndex(); + uint16_t stack_index = destination.GetQuickParameterStackIndex(); if (source.IsRegisterPair()) { - __ Mov(calling_convention.GetRegisterAt(argument_index), + __ Mov(calling_convention.GetRegisterAt(register_index), source.AsRegisterPairLow<Register>()); __ StoreToOffset(kStoreWord, source.AsRegisterPairHigh<Register>(), - SP, calling_convention.GetStackOffsetOf(argument_index + 1)); + SP, calling_convention.GetStackOffsetOf(stack_index + 1)); } else if (source.IsFpuRegister()) { UNIMPLEMENTED(FATAL); } else { DCHECK(source.IsDoubleStackSlot()); __ LoadFromOffset( - kLoadWord, calling_convention.GetRegisterAt(argument_index), SP, source.GetStackIndex()); + kLoadWord, calling_convention.GetRegisterAt(register_index), SP, source.GetStackIndex()); __ LoadFromOffset(kLoadWord, R0, SP, source.GetHighStackIndex(kArmWordSize)); - __ StoreToOffset(kStoreWord, R0, SP, calling_convention.GetStackOffsetOf(argument_index + 1)); + __ StoreToOffset(kStoreWord, R0, SP, calling_convention.GetStackOffsetOf(stack_index + 1)); } } else { DCHECK(destination.IsDoubleStackSlot()); @@ -616,11 +618,12 @@ void CodeGeneratorARM::Move64(Location destination, Location source) { } } else if (source.IsQuickParameter()) { InvokeDexCallingConvention calling_convention; - uint32_t argument_index = source.GetQuickParameterIndex(); - __ StoreToOffset(kStoreWord, calling_convention.GetRegisterAt(argument_index), + uint16_t register_index = source.GetQuickParameterRegisterIndex(); + uint16_t stack_index = source.GetQuickParameterStackIndex(); + __ StoreToOffset(kStoreWord, calling_convention.GetRegisterAt(register_index), SP, destination.GetStackIndex()); __ LoadFromOffset(kLoadWord, R0, - SP, calling_convention.GetStackOffsetOf(argument_index + 1) + GetFrameSize()); + SP, calling_convention.GetStackOffsetOf(stack_index + 1) + GetFrameSize()); __ StoreToOffset(kStoreWord, R0, SP, destination.GetHighStackIndex(kArmWordSize)); } else if (source.IsFpuRegisterPair()) { __ StoreDToOffset(FromLowSToD(source.AsFpuRegisterPairLow<SRegister>()), diff --git a/compiler/optimizing/code_generator_x86.cc b/compiler/optimizing/code_generator_x86.cc index 267edca2b0..2d6d14fbc4 100644 --- a/compiler/optimizing/code_generator_x86.cc +++ b/compiler/optimizing/code_generator_x86.cc @@ -393,7 +393,9 @@ Location InvokeDexCallingConventionVisitor::GetNextLocation(Primitive::Type type calling_convention.GetRegisterPairAt(index)); return Location::RegisterPairLocation(pair.AsRegisterPairLow(), pair.AsRegisterPairHigh()); } else if (index + 1 == calling_convention.GetNumberOfRegisters()) { - return Location::QuickParameter(index); + // On X86, the register index and stack index of a quick parameter is the same, since + // we are passing floating pointer values in core registers. + return Location::QuickParameter(index, index); } else { return Location::DoubleStackSlot(calling_convention.GetStackOffsetOf(index)); } @@ -453,12 +455,13 @@ void CodeGeneratorX86::Move64(Location destination, Location source) { } else if (source.IsFpuRegister()) { LOG(FATAL) << "Unimplemented"; } else if (source.IsQuickParameter()) { - uint32_t argument_index = source.GetQuickParameterIndex(); + uint16_t register_index = source.GetQuickParameterRegisterIndex(); + uint16_t stack_index = source.GetQuickParameterStackIndex(); InvokeDexCallingConvention calling_convention; __ movl(destination.AsRegisterPairLow<Register>(), - calling_convention.GetRegisterAt(argument_index)); + calling_convention.GetRegisterAt(register_index)); __ movl(destination.AsRegisterPairHigh<Register>(), Address(ESP, - calling_convention.GetStackOffsetOf(argument_index + 1) + GetFrameSize())); + calling_convention.GetStackOffsetOf(stack_index + 1) + GetFrameSize())); } else { DCHECK(source.IsDoubleStackSlot()); __ movl(destination.AsRegisterPairLow<Register>(), Address(ESP, source.GetStackIndex())); @@ -467,19 +470,20 @@ void CodeGeneratorX86::Move64(Location destination, Location source) { } } else if (destination.IsQuickParameter()) { InvokeDexCallingConvention calling_convention; - uint32_t argument_index = destination.GetQuickParameterIndex(); + uint16_t register_index = destination.GetQuickParameterRegisterIndex(); + uint16_t stack_index = destination.GetQuickParameterStackIndex(); if (source.IsRegister()) { - __ movl(calling_convention.GetRegisterAt(argument_index), source.AsRegisterPairLow<Register>()); - __ movl(Address(ESP, calling_convention.GetStackOffsetOf(argument_index + 1)), + __ movl(calling_convention.GetRegisterAt(register_index), source.AsRegisterPairLow<Register>()); + __ movl(Address(ESP, calling_convention.GetStackOffsetOf(stack_index + 1)), source.AsRegisterPairHigh<Register>()); } else if (source.IsFpuRegister()) { LOG(FATAL) << "Unimplemented"; } else { DCHECK(source.IsDoubleStackSlot()); - __ movl(calling_convention.GetRegisterAt(argument_index), + __ movl(calling_convention.GetRegisterAt(register_index), Address(ESP, source.GetStackIndex())); __ pushl(Address(ESP, source.GetHighStackIndex(kX86WordSize))); - __ popl(Address(ESP, calling_convention.GetStackOffsetOf(argument_index + 1))); + __ popl(Address(ESP, calling_convention.GetStackOffsetOf(stack_index + 1))); } } else if (destination.IsFpuRegister()) { if (source.IsDoubleStackSlot()) { @@ -495,10 +499,11 @@ void CodeGeneratorX86::Move64(Location destination, Location source) { source.AsRegisterPairHigh<Register>()); } else if (source.IsQuickParameter()) { InvokeDexCallingConvention calling_convention; - uint32_t argument_index = source.GetQuickParameterIndex(); + uint16_t register_index = source.GetQuickParameterRegisterIndex(); + uint16_t stack_index = source.GetQuickParameterStackIndex(); __ movl(Address(ESP, destination.GetStackIndex()), - calling_convention.GetRegisterAt(argument_index)); - DCHECK_EQ(calling_convention.GetStackOffsetOf(argument_index + 1) + GetFrameSize(), + calling_convention.GetRegisterAt(register_index)); + DCHECK_EQ(calling_convention.GetStackOffsetOf(stack_index + 1) + GetFrameSize(), static_cast<size_t>(destination.GetHighStackIndex(kX86WordSize))); } else if (source.IsFpuRegister()) { __ movsd(Address(ESP, destination.GetStackIndex()), source.As<XmmRegister>()); diff --git a/compiler/optimizing/locations.h b/compiler/optimizing/locations.h index 94aded6c87..d7295aa112 100644 --- a/compiler/optimizing/locations.h +++ b/compiler/optimizing/locations.h @@ -228,13 +228,18 @@ class Location : public ValueObject { return GetPayload() - kStackIndexBias + word_size; } - static Location QuickParameter(uint32_t parameter_index) { - return Location(kQuickParameter, parameter_index); + static Location QuickParameter(uint16_t register_index, uint16_t stack_index) { + return Location(kQuickParameter, register_index << 16 | stack_index); } - uint32_t GetQuickParameterIndex() const { + uint32_t GetQuickParameterRegisterIndex() const { DCHECK(IsQuickParameter()); - return GetPayload(); + return GetPayload() >> 16; + } + + uint32_t GetQuickParameterStackIndex() const { + DCHECK(IsQuickParameter()); + return GetPayload() & 0xFFFF; } bool IsQuickParameter() const { |