Refactor Integer.valueOf() intrinsic implementation.
Prepare for Reference.getReferent() intrinsic implementation
by a refactoring to separate the retrieval of an intrinsic
method's declaring class to its own helper function, rather
than being a part of a larger one.
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing --jit
Test: aosp_blueline-userdebug boots.
Test: run-gtests.sh
Test: testrunner.py --target --optimizing --jit
Bug: 170286013
Change-Id: Ib6c0e55d0c6fcc932999428f21c51afe32ab7ef2
diff --git a/compiler/optimizing/intrinsics_arm64.cc b/compiler/optimizing/intrinsics_arm64.cc
index c38f5d6..a7d5b31 100644
--- a/compiler/optimizing/intrinsics_arm64.cc
+++ b/compiler/optimizing/intrinsics_arm64.cc
@@ -2825,6 +2825,12 @@
Register out = RegisterFrom(locations->Out(), DataType::Type::kReference);
UseScratchRegisterScope temps(masm);
Register temp = temps.AcquireW();
+ auto allocate_instance = [&]() {
+ DCHECK(out.X().Is(InvokeRuntimeCallingConvention().GetRegisterAt(0)));
+ codegen_->LoadIntrinsicDeclaringClass(out, invoke);
+ codegen_->InvokeRuntime(kQuickAllocObjectInitialized, invoke, invoke->GetDexPc());
+ CheckEntrypointTypes<kQuickAllocObjectWithChecks, void*, mirror::Class*>();
+ };
if (invoke->InputAt(0)->IsConstant()) {
int32_t value = invoke->InputAt(0)->AsIntConstant()->GetValue();
if (static_cast<uint32_t>(value - info.low) < info.length) {
@@ -2836,12 +2842,10 @@
// Allocate and initialize a new j.l.Integer.
// TODO: If we JIT, we could allocate the j.l.Integer now, and store it in the
// JIT object table.
- codegen_->AllocateInstanceForIntrinsic(invoke->AsInvokeStaticOrDirect(),
- info.integer_boot_image_offset);
+ allocate_instance();
__ Mov(temp.W(), value);
__ Str(temp.W(), HeapOperand(out.W(), info.value_offset));
- // `value` is a final field :-( Ideally, we'd merge this memory barrier with the allocation
- // one.
+ // `value` is a final field, emit the barrier after we have stored it.
codegen_->GenerateMemoryBarrier(MemBarrierKind::kStoreStore);
}
} else {
@@ -2861,11 +2865,9 @@
__ B(&done);
__ Bind(&allocate);
// Otherwise allocate and initialize a new j.l.Integer.
- codegen_->AllocateInstanceForIntrinsic(invoke->AsInvokeStaticOrDirect(),
- info.integer_boot_image_offset);
+ allocate_instance();
__ Str(in.W(), HeapOperand(out.W(), info.value_offset));
- // `value` is a final field :-( Ideally, we'd merge this memory barrier with the allocation
- // one.
+ // `value` is a final field, emit the barrier after we have stored it.
codegen_->GenerateMemoryBarrier(MemBarrierKind::kStoreStore);
__ Bind(&done);
}