1 /* 2 * Copyright (C) 2014 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_COMPILER_JNI_QUICK_ARM64_CALLING_CONVENTION_ARM64_H_ 18 #define ART_COMPILER_JNI_QUICK_ARM64_CALLING_CONVENTION_ARM64_H_ 19 20 #include "base/macros.h" 21 #include "base/pointer_size.h" 22 #include "jni/quick/calling_convention.h" 23 24 namespace art HIDDEN { 25 namespace arm64 { 26 27 class Arm64ManagedRuntimeCallingConvention final : public ManagedRuntimeCallingConvention { 28 public: Arm64ManagedRuntimeCallingConvention(bool is_static,bool is_synchronized,std::string_view shorty)29 Arm64ManagedRuntimeCallingConvention( 30 bool is_static, bool is_synchronized, std::string_view shorty) 31 : ManagedRuntimeCallingConvention(is_static, 32 is_synchronized, 33 shorty, 34 PointerSize::k64) {} ~Arm64ManagedRuntimeCallingConvention()35 ~Arm64ManagedRuntimeCallingConvention() override {} 36 // Calling convention 37 ManagedRegister ReturnRegister() const override; 38 // Managed runtime calling convention 39 ManagedRegister MethodRegister() override; 40 ManagedRegister ArgumentRegisterForMethodExitHook() override; 41 bool IsCurrentParamInRegister() override; 42 bool IsCurrentParamOnStack() override; 43 ManagedRegister CurrentParamRegister() override; 44 FrameOffset CurrentParamStackOffset() override; 45 46 private: 47 DISALLOW_COPY_AND_ASSIGN(Arm64ManagedRuntimeCallingConvention); 48 }; 49 50 class Arm64JniCallingConvention final : public JniCallingConvention { 51 public: 52 Arm64JniCallingConvention(bool is_static, 53 bool is_synchronized, 54 bool is_fast_native, 55 bool is_critical_native, 56 std::string_view shorty); ~Arm64JniCallingConvention()57 ~Arm64JniCallingConvention() override {} 58 // Calling convention 59 ManagedRegister ReturnRegister() const override; 60 ManagedRegister IntReturnRegister() const override; 61 // JNI calling convention 62 size_t FrameSize() const override; 63 size_t OutFrameSize() const override; 64 ArrayRef<const ManagedRegister> CalleeSaveRegisters() const override; 65 ArrayRef<const ManagedRegister> CalleeSaveScratchRegisters() const override; 66 ArrayRef<const ManagedRegister> ArgumentScratchRegisters() const override; 67 uint32_t CoreSpillMask() const override; 68 uint32_t FpSpillMask() const override; 69 bool IsCurrentParamInRegister() override; 70 bool IsCurrentParamOnStack() override; 71 ManagedRegister CurrentParamRegister() override; 72 FrameOffset CurrentParamStackOffset() override; 73 74 // aarch64 calling convention leaves upper bits undefined. RequiresSmallResultTypeExtension()75 bool RequiresSmallResultTypeExtension() const override { 76 return HasSmallReturnType(); 77 } 78 79 // Locking argument register, used to pass the synchronization object for calls 80 // to `JniLockObject()` and `JniUnlockObject()`. 81 ManagedRegister LockingArgumentRegister() const override; 82 83 // Hidden argument register, used to pass the method pointer for @CriticalNative call. 84 ManagedRegister HiddenArgumentRegister() const override; 85 86 // Whether to use tail call (used only for @CriticalNative). 87 bool UseTailCall() const override; 88 89 private: 90 DISALLOW_COPY_AND_ASSIGN(Arm64JniCallingConvention); 91 }; 92 93 } // namespace arm64 94 } // namespace art 95 96 #endif // ART_COMPILER_JNI_QUICK_ARM64_CALLING_CONVENTION_ARM64_H_ 97