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