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: 29 explicit X86_64ManagedRuntimeCallingConvention(bool is_static, bool is_synchronized, 30 const char* shorty) 31 : ManagedRuntimeCallingConvention(is_static, is_synchronized, shorty, kFramePointerSize) {} 32 ~X86_64ManagedRuntimeCallingConvention() 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 private: 44 ManagedRegisterEntrySpills entry_spills_; 45 DISALLOW_COPY_AND_ASSIGN(X86_64ManagedRuntimeCallingConvention); 46 }; 47 48 class X86_64JniCallingConvention FINAL : public JniCallingConvention { 49 public: 50 explicit X86_64JniCallingConvention(bool is_static, bool is_synchronized, const char* shorty); 51 ~X86_64JniCallingConvention() OVERRIDE {} 52 // Calling convention 53 ManagedRegister ReturnRegister() OVERRIDE; 54 ManagedRegister IntReturnRegister() OVERRIDE; 55 ManagedRegister InterproceduralScratchRegister() OVERRIDE; 56 // JNI calling convention 57 size_t FrameSize() OVERRIDE; 58 size_t OutArgSize() OVERRIDE; 59 const std::vector<ManagedRegister>& CalleeSaveRegisters() const OVERRIDE { 60 return callee_save_regs_; 61 } 62 ManagedRegister ReturnScratchRegister() const OVERRIDE; 63 uint32_t CoreSpillMask() const OVERRIDE; 64 uint32_t FpSpillMask() const OVERRIDE; 65 bool IsCurrentParamInRegister() OVERRIDE; 66 bool IsCurrentParamOnStack() OVERRIDE; 67 ManagedRegister CurrentParamRegister() OVERRIDE; 68 FrameOffset CurrentParamStackOffset() OVERRIDE; 69 70 // x86-64 needs to extend small return types. 71 bool RequiresSmallResultTypeExtension() const OVERRIDE { 72 return true; 73 } 74 75 protected: 76 size_t NumberOfOutgoingStackArgs() OVERRIDE; 77 78 private: 79 // TODO: these values aren't unique and can be shared amongst instances 80 std::vector<ManagedRegister> callee_save_regs_; 81 82 DISALLOW_COPY_AND_ASSIGN(X86_64JniCallingConvention); 83 }; 84 85 } // namespace x86_64 86 } // namespace art 87 88 #endif // ART_COMPILER_JNI_QUICK_X86_64_CALLING_CONVENTION_X86_64_H_ 89