1 /* 2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef ART_RUNTIME_NTERP_HELPERS_INL_H_ 18 #define ART_RUNTIME_NTERP_HELPERS_INL_H_ 19 20 #include "nterp_helpers.h" 21 22 namespace art HIDDEN { 23 GetNterpFastPathFlags(std::string_view shorty,uint32_t access_flags,InstructionSet isa)24ALWAYS_INLINE inline uint32_t GetNterpFastPathFlags(std::string_view shorty, 25 uint32_t access_flags, 26 InstructionSet isa) { 27 bool all_parameters_are_reference = true; 28 bool all_parameters_are_reference_or_int = true; 29 for (size_t i = 1; i < shorty.length(); ++i) { 30 if (shorty[i] != 'L') { 31 all_parameters_are_reference = false; 32 if (shorty[i] == 'F' || shorty[i] == 'D' || shorty[i] == 'J') { 33 all_parameters_are_reference_or_int = false; 34 break; 35 } 36 } 37 } 38 39 // Check for nterp entry fast-path based on shorty. 40 uint32_t nterp_flags = 0u; 41 if ((access_flags & kAccNative) == 0u && all_parameters_are_reference) { 42 nterp_flags |= kAccNterpEntryPointFastPathFlag; 43 } 44 45 // Check for nterp invoke fast-path based on shorty. 46 const bool no_float_return = shorty[0] != 'F' && shorty[0] != 'D'; 47 if (isa != InstructionSet::kRiscv64 && all_parameters_are_reference_or_int && no_float_return) { 48 nterp_flags |= kAccNterpInvokeFastPathFlag; 49 } else if (isa == InstructionSet::kRiscv64 && all_parameters_are_reference && no_float_return) { 50 nterp_flags |= kAccNterpInvokeFastPathFlag; 51 } 52 return nterp_flags; 53 } 54 55 } // namespace art 56 57 #endif // ART_RUNTIME_NTERP_HELPERS_INL_H_ 58