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 explicit X86ManagedRuntimeCallingConvention(bool is_static, bool is_synchronized, 30 const char* shorty) 31 : ManagedRuntimeCallingConvention(is_static, is_synchronized, shorty, kFramePointerSize) {} ~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 private: 44 ManagedRegisterEntrySpills entry_spills_; 45 DISALLOW_COPY_AND_ASSIGN(X86ManagedRuntimeCallingConvention); 46 }; 47 48 class X86JniCallingConvention FINAL : public JniCallingConvention { 49 public: 50 explicit X86JniCallingConvention(bool is_static, bool is_synchronized, const char* shorty); ~X86JniCallingConvention()51 ~X86JniCallingConvention() 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; CalleeSaveRegisters()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; FpSpillMask()64 uint32_t FpSpillMask() const OVERRIDE { 65 return 0; 66 } 67 bool IsCurrentParamInRegister() OVERRIDE; 68 bool IsCurrentParamOnStack() OVERRIDE; 69 ManagedRegister CurrentParamRegister() OVERRIDE; 70 FrameOffset CurrentParamStackOffset() OVERRIDE; 71 72 // x86 needs to extend small return types. RequiresSmallResultTypeExtension()73 bool RequiresSmallResultTypeExtension() const OVERRIDE { 74 return true; 75 } 76 77 protected: 78 size_t NumberOfOutgoingStackArgs() OVERRIDE; 79 80 private: 81 // TODO: these values aren't unique and can be shared amongst instances 82 std::vector<ManagedRegister> callee_save_regs_; 83 84 DISALLOW_COPY_AND_ASSIGN(X86JniCallingConvention); 85 }; 86 87 } // namespace x86 88 } // namespace art 89 90 #endif // ART_COMPILER_JNI_QUICK_X86_CALLING_CONVENTION_X86_H_ 91