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 class X86ManagedRuntimeCallingConvention : public ManagedRuntimeCallingConvention { 26 public: 27 explicit X86ManagedRuntimeCallingConvention(bool is_static, bool is_synchronized, 28 const char* shorty) 29 : ManagedRuntimeCallingConvention(is_static, is_synchronized, shorty) {} 30 virtual ~X86ManagedRuntimeCallingConvention() {} 31 // Calling convention 32 virtual ManagedRegister ReturnRegister(); 33 virtual ManagedRegister InterproceduralScratchRegister(); 34 // Managed runtime calling convention 35 virtual ManagedRegister MethodRegister(); 36 virtual bool IsCurrentParamInRegister(); 37 virtual bool IsCurrentParamOnStack(); 38 virtual ManagedRegister CurrentParamRegister(); 39 virtual FrameOffset CurrentParamStackOffset(); 40 virtual const std::vector<ManagedRegister>& EntrySpills(); 41 private: 42 std::vector<ManagedRegister> entry_spills_; 43 DISALLOW_COPY_AND_ASSIGN(X86ManagedRuntimeCallingConvention); 44 }; 45 46 class X86JniCallingConvention : public JniCallingConvention { 47 public: 48 explicit X86JniCallingConvention(bool is_static, bool is_synchronized, const char* shorty); 49 virtual ~X86JniCallingConvention() {} 50 // Calling convention 51 virtual ManagedRegister ReturnRegister(); 52 virtual ManagedRegister IntReturnRegister(); 53 virtual ManagedRegister InterproceduralScratchRegister(); 54 // JNI calling convention 55 virtual size_t FrameSize(); 56 virtual size_t OutArgSize(); 57 virtual const std::vector<ManagedRegister>& CalleeSaveRegisters() const { 58 return callee_save_regs_; 59 } 60 virtual ManagedRegister ReturnScratchRegister() const; 61 virtual uint32_t CoreSpillMask() const; 62 virtual uint32_t FpSpillMask() const { 63 return 0; 64 } 65 virtual bool IsCurrentParamInRegister(); 66 virtual bool IsCurrentParamOnStack(); 67 virtual ManagedRegister CurrentParamRegister(); 68 virtual FrameOffset CurrentParamStackOffset(); 69 70 protected: 71 virtual size_t NumberOfOutgoingStackArgs(); 72 73 private: 74 // TODO: these values aren't unique and can be shared amongst instances 75 std::vector<ManagedRegister> callee_save_regs_; 76 77 DISALLOW_COPY_AND_ASSIGN(X86JniCallingConvention); 78 }; 79 80 } // namespace x86 81 } // namespace art 82 83 #endif // ART_COMPILER_JNI_QUICK_X86_CALLING_CONVENTION_X86_H_ 84