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_X86_64_CALLING_CONVENTION_X86_64_H_
18 #define ART_COMPILER_JNI_QUICK_X86_64_CALLING_CONVENTION_X86_64_H_
19 
20 #include "base/enums.h"
21 #include "jni/quick/calling_convention.h"
22 
23 namespace art {
24 namespace x86_64 {
25 
26 class X86_64ManagedRuntimeCallingConvention final : public ManagedRuntimeCallingConvention {
27  public:
X86_64ManagedRuntimeCallingConvention(bool is_static,bool is_synchronized,const char * shorty)28   X86_64ManagedRuntimeCallingConvention(bool is_static, bool is_synchronized, const char* shorty)
29       : ManagedRuntimeCallingConvention(is_static,
30                                         is_synchronized,
31                                         shorty,
32                                         PointerSize::k64) {}
~X86_64ManagedRuntimeCallingConvention()33   ~X86_64ManagedRuntimeCallingConvention() override {}
34   // Calling convention
35   ManagedRegister ReturnRegister() override;
36   // Managed runtime calling convention
37   ManagedRegister MethodRegister() override;
38   bool IsCurrentParamInRegister() override;
39   bool IsCurrentParamOnStack() override;
40   ManagedRegister CurrentParamRegister() override;
41   FrameOffset CurrentParamStackOffset() override;
42 
43  private:
44   DISALLOW_COPY_AND_ASSIGN(X86_64ManagedRuntimeCallingConvention);
45 };
46 
47 class X86_64JniCallingConvention final : public JniCallingConvention {
48  public:
49   X86_64JniCallingConvention(bool is_static,
50                              bool is_synchronized,
51                              bool is_critical_native,
52                              const char* shorty);
~X86_64JniCallingConvention()53   ~X86_64JniCallingConvention() override {}
54   // Calling convention
55   ManagedRegister ReturnRegister() override;
56   ManagedRegister IntReturnRegister() override;
57   // JNI calling convention
58   size_t FrameSize() const override;
59   size_t OutFrameSize() const override;
60   ArrayRef<const ManagedRegister> CalleeSaveRegisters() const override;
61   ManagedRegister ReturnScratchRegister() const override;
62   uint32_t CoreSpillMask() const override;
63   uint32_t FpSpillMask() const override;
64   bool IsCurrentParamInRegister() override;
65   bool IsCurrentParamOnStack() override;
66   ManagedRegister CurrentParamRegister() override;
67   FrameOffset CurrentParamStackOffset() override;
68 
69   // x86-64 needs to extend small return types.
RequiresSmallResultTypeExtension()70   bool RequiresSmallResultTypeExtension() const override {
71     return HasSmallReturnType();
72   }
73 
74   // Hidden argument register, used to pass the method pointer for @CriticalNative call.
75   ManagedRegister HiddenArgumentRegister() const override;
76 
77   // Whether to use tail call (used only for @CriticalNative).
78   bool UseTailCall() const override;
79 
80  private:
81   DISALLOW_COPY_AND_ASSIGN(X86_64JniCallingConvention);
82 };
83 
84 }  // namespace x86_64
85 }  // namespace art
86 
87 #endif  // ART_COMPILER_JNI_QUICK_X86_64_CALLING_CONVENTION_X86_64_H_
88