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   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  private:
45   ManagedRegisterEntrySpills entry_spills_;
46   DISALLOW_COPY_AND_ASSIGN(X86_64ManagedRuntimeCallingConvention);
47 };
48 
49 class X86_64JniCallingConvention final : public JniCallingConvention {
50  public:
51   X86_64JniCallingConvention(bool is_static,
52                              bool is_synchronized,
53                              bool is_critical_native,
54                              const char* shorty);
~X86_64JniCallingConvention()55   ~X86_64JniCallingConvention() override {}
56   // Calling convention
57   ManagedRegister ReturnRegister() override;
58   ManagedRegister IntReturnRegister() override;
59   ManagedRegister InterproceduralScratchRegister() const override;
60   // JNI calling convention
61   size_t FrameSize() const override;
62   size_t OutArgSize() const override;
63   ArrayRef<const ManagedRegister> CalleeSaveRegisters() const override;
64   ManagedRegister ReturnScratchRegister() const override;
65   uint32_t CoreSpillMask() const override;
66   uint32_t FpSpillMask() const override;
67   bool IsCurrentParamInRegister() override;
68   bool IsCurrentParamOnStack() override;
69   ManagedRegister CurrentParamRegister() override;
70   FrameOffset CurrentParamStackOffset() override;
71 
72   // x86-64 needs to extend small return types.
RequiresSmallResultTypeExtension()73   bool RequiresSmallResultTypeExtension() const override {
74     return HasSmallReturnType();
75   }
76 
77   // Hidden argument register, used to pass the method pointer for @CriticalNative call.
78   ManagedRegister HiddenArgumentRegister() const override;
79 
80   // Whether to use tail call (used only for @CriticalNative).
81   bool UseTailCall() const override;
82 
83  private:
84   DISALLOW_COPY_AND_ASSIGN(X86_64JniCallingConvention);
85 };
86 
87 }  // namespace x86_64
88 }  // namespace art
89 
90 #endif  // ART_COMPILER_JNI_QUICK_X86_64_CALLING_CONVENTION_X86_64_H_
91