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 "base/enums.h" 21 #include "jni/quick/calling_convention.h" 22 23 namespace art { 24 namespace x86 { 25 26 constexpr size_t kFramePointerSize = static_cast<size_t>(PointerSize::k32); 27 28 class X86ManagedRuntimeCallingConvention final : public ManagedRuntimeCallingConvention { 29 public: X86ManagedRuntimeCallingConvention(bool is_static,bool is_synchronized,const char * shorty)30 X86ManagedRuntimeCallingConvention(bool is_static, bool is_synchronized, const char* shorty) 31 : ManagedRuntimeCallingConvention(is_static, 32 is_synchronized, 33 shorty, 34 PointerSize::k32), 35 gpr_arg_count_(0) {} ~X86ManagedRuntimeCallingConvention()36 ~X86ManagedRuntimeCallingConvention() override {} 37 // Calling convention 38 ManagedRegister ReturnRegister() override; 39 ManagedRegister InterproceduralScratchRegister() override; 40 // Managed runtime calling convention 41 ManagedRegister MethodRegister() override; 42 bool IsCurrentParamInRegister() override; 43 bool IsCurrentParamOnStack() override; 44 ManagedRegister CurrentParamRegister() override; 45 FrameOffset CurrentParamStackOffset() override; 46 const ManagedRegisterEntrySpills& EntrySpills() override; 47 48 private: 49 int gpr_arg_count_; 50 ManagedRegister CurrentParamHighLongRegister(); 51 ManagedRegisterEntrySpills entry_spills_; 52 DISALLOW_COPY_AND_ASSIGN(X86ManagedRuntimeCallingConvention); 53 }; 54 55 // Implements the x86 cdecl calling convention. 56 class X86JniCallingConvention final : public JniCallingConvention { 57 public: 58 X86JniCallingConvention(bool is_static, 59 bool is_synchronized, 60 bool is_critical_native, 61 const char* shorty); ~X86JniCallingConvention()62 ~X86JniCallingConvention() override {} 63 // Calling convention 64 ManagedRegister ReturnRegister() override; 65 ManagedRegister IntReturnRegister() override; 66 ManagedRegister InterproceduralScratchRegister() override; 67 // JNI calling convention 68 size_t FrameSize() override; 69 size_t OutArgSize() override; 70 ArrayRef<const ManagedRegister> CalleeSaveRegisters() const override; 71 ManagedRegister ReturnScratchRegister() const override; 72 uint32_t CoreSpillMask() const override; 73 uint32_t FpSpillMask() const override; 74 bool IsCurrentParamInRegister() override; 75 bool IsCurrentParamOnStack() override; 76 ManagedRegister CurrentParamRegister() override; 77 FrameOffset CurrentParamStackOffset() override; 78 79 // x86 needs to extend small return types. RequiresSmallResultTypeExtension()80 bool RequiresSmallResultTypeExtension() const override { 81 return true; 82 } 83 84 protected: 85 size_t NumberOfOutgoingStackArgs() override; 86 87 private: 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