• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_X86_CALLING_CONVENTION_X86_H_
18 #define ART_COMPILER_JNI_QUICK_X86_CALLING_CONVENTION_X86_H_
19 
20 #include "jni/quick/calling_convention.h"
21 
22 namespace art {
23 namespace x86 {
24 
25 constexpr size_t kFramePointerSize = 4;
26 
27 class X86ManagedRuntimeCallingConvention FINAL : public ManagedRuntimeCallingConvention {
28  public:
X86ManagedRuntimeCallingConvention(bool is_static,bool is_synchronized,const char * shorty)29   X86ManagedRuntimeCallingConvention(bool is_static, bool is_synchronized, const char* shorty)
30       : ManagedRuntimeCallingConvention(is_static, is_synchronized, shorty, kFramePointerSize),
31         gpr_arg_count_(0) {}
~X86ManagedRuntimeCallingConvention()32   ~X86ManagedRuntimeCallingConvention() OVERRIDE {}
33   // Calling convention
34   ManagedRegister ReturnRegister() OVERRIDE;
35   ManagedRegister InterproceduralScratchRegister() 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   const ManagedRegisterEntrySpills& EntrySpills() OVERRIDE;
43 
44  private:
45   int gpr_arg_count_;
46   ManagedRegister CurrentParamHighLongRegister();
47   ManagedRegisterEntrySpills entry_spills_;
48   DISALLOW_COPY_AND_ASSIGN(X86ManagedRuntimeCallingConvention);
49 };
50 
51 class X86JniCallingConvention FINAL : public JniCallingConvention {
52  public:
53   X86JniCallingConvention(bool is_static, bool is_synchronized, const char* shorty);
~X86JniCallingConvention()54   ~X86JniCallingConvention() OVERRIDE {}
55   // Calling convention
56   ManagedRegister ReturnRegister() OVERRIDE;
57   ManagedRegister IntReturnRegister() OVERRIDE;
58   ManagedRegister InterproceduralScratchRegister() OVERRIDE;
59   // JNI calling convention
60   size_t FrameSize() OVERRIDE;
61   size_t OutArgSize() OVERRIDE;
CalleeSaveRegisters()62   const std::vector<ManagedRegister>& CalleeSaveRegisters() const OVERRIDE {
63     return callee_save_regs_;
64   }
65   ManagedRegister ReturnScratchRegister() const OVERRIDE;
66   uint32_t CoreSpillMask() const OVERRIDE;
FpSpillMask()67   uint32_t FpSpillMask() const OVERRIDE {
68     return 0;
69   }
70   bool IsCurrentParamInRegister() OVERRIDE;
71   bool IsCurrentParamOnStack() OVERRIDE;
72   ManagedRegister CurrentParamRegister() OVERRIDE;
73   FrameOffset CurrentParamStackOffset() OVERRIDE;
74 
75   // x86 needs to extend small return types.
RequiresSmallResultTypeExtension()76   bool RequiresSmallResultTypeExtension() const OVERRIDE {
77     return true;
78   }
79 
80  protected:
81   size_t NumberOfOutgoingStackArgs() OVERRIDE;
82 
83  private:
84   // TODO: these values aren't unique and can be shared amongst instances
85   std::vector<ManagedRegister> callee_save_regs_;
86 
87   DISALLOW_COPY_AND_ASSIGN(X86JniCallingConvention);
88 };
89 
90 }  // namespace x86
91 }  // namespace art
92 
93 #endif  // ART_COMPILER_JNI_QUICK_X86_CALLING_CONVENTION_X86_H_
94