summaryrefslogtreecommitdiff
path: root/compiler/optimizing/intrinsics_x86.cc
diff options
context:
space:
mode:
author Nicolas Geoffray <ngeoffray@google.com> 2024-07-08 11:19:04 +0100
committer Nicolas Geoffray <ngeoffray@google.com> 2024-07-08 11:19:45 +0100
commit801c4c9d8c55be2bd8ee9c3dcc6c20ab0cf4c5f7 (patch)
tree5018c7a90d8eb43c94bd3e0851e809b9f69962b0 /compiler/optimizing/intrinsics_x86.cc
parent342fef74762b2e827a638286d4b81a821b4c2b07 (diff)
Ensure x86 uses a byte register.
Not all registers can be used. Bug: 339571886 Test: 004-UnsafeTest Change-Id: I0ec51835cba56f1af0a5db8d818a3c5fea44dae6
Diffstat (limited to 'compiler/optimizing/intrinsics_x86.cc')
-rw-r--r--compiler/optimizing/intrinsics_x86.cc14
1 files changed, 12 insertions, 2 deletions
diff --git a/compiler/optimizing/intrinsics_x86.cc b/compiler/optimizing/intrinsics_x86.cc
index b752493a0f..50ac993ac8 100644
--- a/compiler/optimizing/intrinsics_x86.cc
+++ b/compiler/optimizing/intrinsics_x86.cc
@@ -1887,7 +1887,12 @@ static void CreateIntIntIntIntToVoidPlusTempsLocations(ArenaAllocator* allocator
locations->SetInAt(0, Location::NoLocation()); // Unused receiver.
locations->SetInAt(1, Location::RequiresRegister());
locations->SetInAt(2, Location::RequiresRegister());
- locations->SetInAt(3, Location::RequiresRegister());
+ if (type == DataType::Type::kInt8 || type == DataType::Type::kUint8) {
+ // Ensure the value is in a byte register
+ locations->SetInAt(3, Location::ByteRegisterOrConstant(EAX, invoke->InputAt(3)));
+ } else {
+ locations->SetInAt(3, Location::RequiresRegister());
+ }
if (type == DataType::Type::kReference) {
// Need temp registers for card-marking.
locations->AddTemp(Location::RequiresRegister()); // Possibly used for reference poisoning too.
@@ -2017,7 +2022,12 @@ static void GenUnsafePut(LocationSummary* locations,
__ movl(Address(base, offset, ScaleFactor::TIMES_1, 0), value_loc.AsRegister<Register>());
} else {
CHECK_EQ(type, DataType::Type::kInt8) << "Unimplemented GenUnsafePut data type";
- __ movb(Address(base, offset, ScaleFactor::TIMES_1, 0), value_loc.AsRegister<ByteRegister>());
+ if (value_loc.IsRegister()) {
+ __ movb(Address(base, offset, ScaleFactor::TIMES_1, 0), value_loc.AsRegister<ByteRegister>());
+ } else {
+ __ movb(Address(base, offset, ScaleFactor::TIMES_1, 0),
+ Immediate(CodeGenerator::GetInt8ValueOf(value_loc.GetConstant())));
+ }
}
if (is_volatile) {