-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
riscv64: Implement
CriticalNativeAbiFixupRiscv64
.
And pass integral stack args sign-extended to 64 bits for direct @CriticalNative calls. Enable direct @CriticalNative call codegen unconditionally and also enable `HClinitCheck` codegen and extend the 178-app-image-native-method run-test to properly test these use cases. Test: # Edit `run-test` to disable checker, then testrunner.py --target --64 --ndebug --optimizing # Ignore 6 pre-existing failures (down from 7). Bug: 283082089 Change-Id: Ia514c62006c7079b04182cc39e413eb2deb089c1
- Loading branch information
Showing
14 changed files
with
484 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Copyright (C) 2023 The Android Open Source Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include "critical_native_abi_fixup_riscv64.h" | ||
|
||
#include "arch/riscv64/jni_frame_riscv64.h" | ||
#include "intrinsics.h" | ||
#include "nodes.h" | ||
|
||
namespace art HIDDEN { | ||
namespace riscv64 { | ||
|
||
// Fix up FP arguments passed in core registers for call to @CriticalNative by inserting fake calls | ||
// to Float.floatToRawIntBits() or Double.doubleToRawLongBits() to satisfy type consistency checks. | ||
static void FixUpArguments(HInvokeStaticOrDirect* invoke) { | ||
DCHECK_EQ(invoke->GetCodePtrLocation(), CodePtrLocation::kCallCriticalNative); | ||
size_t core_reg = 0u; | ||
size_t fp_reg = 0u; | ||
for (size_t i = 0, num_args = invoke->GetNumberOfArguments(); i != num_args; ++i) { | ||
if (core_reg == kMaxIntLikeArgumentRegisters) { | ||
break; // Remaining arguments are passed in FP regs or on the stack. | ||
} | ||
HInstruction* input = invoke->InputAt(i); | ||
DataType::Type input_type = input->GetType(); | ||
if (DataType::IsFloatingPointType(input_type)) { | ||
if (fp_reg < kMaxFloatOrDoubleArgumentRegisters) { | ||
++fp_reg; | ||
} else { | ||
DCHECK_LT(core_reg, kMaxIntLikeArgumentRegisters); | ||
InsertFpToIntegralIntrinsic(invoke, i); | ||
++core_reg; | ||
} | ||
} else { | ||
++core_reg; | ||
} | ||
} | ||
} | ||
|
||
bool CriticalNativeAbiFixupRiscv64::Run() { | ||
if (!graph_->HasDirectCriticalNativeCall()) { | ||
return false; | ||
} | ||
|
||
for (HBasicBlock* block : graph_->GetReversePostOrder()) { | ||
for (HInstructionIterator it(block->GetInstructions()); !it.Done(); it.Advance()) { | ||
HInstruction* instruction = it.Current(); | ||
if (instruction->IsInvokeStaticOrDirect() && | ||
instruction->AsInvokeStaticOrDirect()->GetCodePtrLocation() == | ||
CodePtrLocation::kCallCriticalNative) { | ||
FixUpArguments(instruction->AsInvokeStaticOrDirect()); | ||
} | ||
} | ||
} | ||
return true; | ||
} | ||
|
||
} // namespace riscv64 | ||
} // namespace art |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright (C) 2023 The Android Open Source Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#ifndef ART_COMPILER_OPTIMIZING_CRITICAL_NATIVE_ABI_FIXUP_RISCV64_H_ | ||
#define ART_COMPILER_OPTIMIZING_CRITICAL_NATIVE_ABI_FIXUP_RISCV64_H_ | ||
|
||
#include "base/macros.h" | ||
#include "nodes.h" | ||
#include "optimization.h" | ||
|
||
namespace art HIDDEN { | ||
namespace riscv64 { | ||
|
||
class CriticalNativeAbiFixupRiscv64 : public HOptimization { | ||
public: | ||
CriticalNativeAbiFixupRiscv64(HGraph* graph, OptimizingCompilerStats* stats) | ||
: HOptimization(graph, kCriticalNativeAbiFixupRiscv64PassName, stats) {} | ||
|
||
static constexpr const char* kCriticalNativeAbiFixupRiscv64PassName = | ||
"critical_native_abi_fixup_riscv64"; | ||
|
||
bool Run() override; | ||
}; | ||
|
||
} // namespace riscv64 | ||
} // namespace art | ||
|
||
#endif // ART_COMPILER_OPTIMIZING_CRITICAL_NATIVE_ABI_FIXUP_RISCV64_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.