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/enums.h"
21 #include "jni/quick/calling_convention.h"
22 
23 namespace art {
24 namespace arm64 {
25 
26 class Arm64ManagedRuntimeCallingConvention final : public ManagedRuntimeCallingConvention {
27  public:
Arm64ManagedRuntimeCallingConvention(bool is_static,bool is_synchronized,const char * shorty)28   Arm64ManagedRuntimeCallingConvention(bool is_static, bool is_synchronized, const char* shorty)
29       : ManagedRuntimeCallingConvention(is_static,
30                                         is_synchronized,
31                                         shorty,
32                                         PointerSize::k64) {}
~Arm64ManagedRuntimeCallingConvention()33   ~Arm64ManagedRuntimeCallingConvention() override {}
34   // Calling convention
35   ManagedRegister ReturnRegister() override;
36   ManagedRegister InterproceduralScratchRegister() const override;
37   // Managed runtime calling convention
38   ManagedRegister MethodRegister() override;
39   bool IsCurrentParamInRegister() override;
40   bool IsCurrentParamOnStack() override;
41   ManagedRegister CurrentParamRegister() override;
42   FrameOffset CurrentParamStackOffset() override;
43   const ManagedRegisterEntrySpills& EntrySpills() override;
44 
45  private:
46   ManagedRegisterEntrySpills entry_spills_;
47 
48   DISALLOW_COPY_AND_ASSIGN(Arm64ManagedRuntimeCallingConvention);
49 };
50 
51 class Arm64JniCallingConvention final : public JniCallingConvention {
52  public:
53   Arm64JniCallingConvention(bool is_static,
54                             bool is_synchronized,
55                             bool is_critical_native,
56                             const char* shorty);
~Arm64JniCallingConvention()57   ~Arm64JniCallingConvention() override {}
58   // Calling convention
59   ManagedRegister ReturnRegister() override;
60   ManagedRegister IntReturnRegister() override;
61   ManagedRegister InterproceduralScratchRegister() const override;
62   // JNI calling convention
63   size_t FrameSize() const override;
64   size_t OutArgSize() const override;
65   ArrayRef<const ManagedRegister> CalleeSaveRegisters() const override;
66   ManagedRegister ReturnScratchRegister() 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   // Hidden argument register, used to pass the method pointer for @CriticalNative call.
80   ManagedRegister HiddenArgumentRegister() const override;
81 
82   // Whether to use tail call (used only for @CriticalNative).
83   bool UseTailCall() const override;
84 
85  private:
86   DISALLOW_COPY_AND_ASSIGN(Arm64JniCallingConvention);
87 };
88 
89 }  // namespace arm64
90 }  // namespace art
91 
92 #endif  // ART_COMPILER_JNI_QUICK_ARM64_CALLING_CONVENTION_ARM64_H_
93