• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "jni/quick/calling_convention.h"
21 
22 namespace art {
23 namespace x86_64 {
24 
25 constexpr size_t kFramePointerSize = 8;
26 
27 class X86_64ManagedRuntimeCallingConvention FINAL : public ManagedRuntimeCallingConvention {
28  public:
X86_64ManagedRuntimeCallingConvention(bool is_static,bool is_synchronized,const char * shorty)29   X86_64ManagedRuntimeCallingConvention(bool is_static, bool is_synchronized, const char* shorty)
30       : ManagedRuntimeCallingConvention(is_static, is_synchronized, shorty, kFramePointerSize) {}
~X86_64ManagedRuntimeCallingConvention()31   ~X86_64ManagedRuntimeCallingConvention() OVERRIDE {}
32   // Calling convention
33   ManagedRegister ReturnRegister() OVERRIDE;
34   ManagedRegister InterproceduralScratchRegister() OVERRIDE;
35   // Managed runtime calling convention
36   ManagedRegister MethodRegister() OVERRIDE;
37   bool IsCurrentParamInRegister() OVERRIDE;
38   bool IsCurrentParamOnStack() OVERRIDE;
39   ManagedRegister CurrentParamRegister() OVERRIDE;
40   FrameOffset CurrentParamStackOffset() OVERRIDE;
41   const ManagedRegisterEntrySpills& EntrySpills() OVERRIDE;
42  private:
43   ManagedRegisterEntrySpills entry_spills_;
44   DISALLOW_COPY_AND_ASSIGN(X86_64ManagedRuntimeCallingConvention);
45 };
46 
47 class X86_64JniCallingConvention FINAL : public JniCallingConvention {
48  public:
49   X86_64JniCallingConvention(bool is_static, bool is_synchronized, const char* shorty);
~X86_64JniCallingConvention()50   ~X86_64JniCallingConvention() OVERRIDE {}
51   // Calling convention
52   ManagedRegister ReturnRegister() OVERRIDE;
53   ManagedRegister IntReturnRegister() OVERRIDE;
54   ManagedRegister InterproceduralScratchRegister() OVERRIDE;
55   // JNI calling convention
56   size_t FrameSize() OVERRIDE;
57   size_t OutArgSize() OVERRIDE;
CalleeSaveRegisters()58   const std::vector<ManagedRegister>& CalleeSaveRegisters() const OVERRIDE {
59     return callee_save_regs_;
60   }
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 true;
72   }
73 
74  protected:
75   size_t NumberOfOutgoingStackArgs() OVERRIDE;
76 
77  private:
78   // TODO: these values aren't unique and can be shared amongst instances
79   std::vector<ManagedRegister> callee_save_regs_;
80 
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