1 /*
2  * Copyright (C) 2011 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_ARM_CALLING_CONVENTION_ARM_H_
18 #define ART_COMPILER_JNI_QUICK_ARM_CALLING_CONVENTION_ARM_H_
19 
20 #include "base/enums.h"
21 #include "jni/quick/calling_convention.h"
22 
23 namespace art {
24 namespace arm {
25 
26 class ArmManagedRuntimeCallingConvention final : public ManagedRuntimeCallingConvention {
27  public:
ArmManagedRuntimeCallingConvention(bool is_static,bool is_synchronized,const char * shorty)28   ArmManagedRuntimeCallingConvention(bool is_static, bool is_synchronized, const char* shorty)
29       : ManagedRuntimeCallingConvention(is_static,
30                                         is_synchronized,
31                                         shorty,
32                                         PointerSize::k32),
33         gpr_index_(1u),  // Skip r0 for ArtMethod*
34         float_index_(0u),
35         double_index_(0u) {}
~ArmManagedRuntimeCallingConvention()36   ~ArmManagedRuntimeCallingConvention() override {}
37   // Calling convention
38   ManagedRegister ReturnRegister() override;
39   void ResetIterator(FrameOffset displacement) override;
40   // Managed runtime calling convention
41   ManagedRegister MethodRegister() override;
42   void Next() override;
43   bool IsCurrentParamInRegister() override;
44   bool IsCurrentParamOnStack() override;
45   ManagedRegister CurrentParamRegister() override;
46   FrameOffset CurrentParamStackOffset() override;
47 
48  private:
49   size_t gpr_index_;
50   size_t float_index_;
51   size_t double_index_;
52   DISALLOW_COPY_AND_ASSIGN(ArmManagedRuntimeCallingConvention);
53 };
54 
55 class ArmJniCallingConvention final : public JniCallingConvention {
56  public:
57   ArmJniCallingConvention(bool is_static,
58                           bool is_synchronized,
59                           bool is_critical_native,
60                           const char* shorty);
~ArmJniCallingConvention()61   ~ArmJniCallingConvention() override {}
62   // Calling convention
63   ManagedRegister ReturnRegister() override;
64   ManagedRegister IntReturnRegister() override;
65   // JNI calling convention
66   void Next() override;  // Override default behavior for AAPCS
67   size_t FrameSize() const override;
68   size_t OutFrameSize() const override;
69   ArrayRef<const ManagedRegister> CalleeSaveRegisters() const override;
70   ManagedRegister SavedLocalReferenceCookieRegister() const override;
71   ManagedRegister ReturnScratchRegister() const override;
72   uint32_t CoreSpillMask() const override;
73   uint32_t FpSpillMask() const override;
74   bool IsCurrentParamInRegister() override;
75   bool IsCurrentParamOnStack() override;
76   ManagedRegister CurrentParamRegister() override;
77   FrameOffset CurrentParamStackOffset() override;
78 
79   // AAPCS mandates return values are extended.
RequiresSmallResultTypeExtension()80   bool RequiresSmallResultTypeExtension() const override {
81     return false;
82   }
83 
84   // Hidden argument register, used to pass the method pointer for @CriticalNative call.
85   ManagedRegister HiddenArgumentRegister() const override;
86 
87   // Whether to use tail call (used only for @CriticalNative).
88   bool UseTailCall() const override;
89 
90  private:
91   // Padding to ensure longs and doubles are not split in AAPCS
92   size_t padding_;
93 
94   DISALLOW_COPY_AND_ASSIGN(ArmJniCallingConvention);
95 };
96 
97 }  // namespace arm
98 }  // namespace art
99 
100 #endif  // ART_COMPILER_JNI_QUICK_ARM_CALLING_CONVENTION_ARM_H_
101