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 class X86ManagedRuntimeCallingConvention final : public ManagedRuntimeCallingConvention { 27 public: X86ManagedRuntimeCallingConvention(bool is_static,bool is_synchronized,const char * shorty)28 X86ManagedRuntimeCallingConvention(bool is_static, bool is_synchronized, const char* shorty) 29 : ManagedRuntimeCallingConvention(is_static, 30 is_synchronized, 31 shorty, 32 PointerSize::k32), 33 gpr_arg_count_(1u) {} // Skip EAX for ArtMethod* ~X86ManagedRuntimeCallingConvention()34 ~X86ManagedRuntimeCallingConvention() override {} 35 // Calling convention 36 ManagedRegister ReturnRegister() override; 37 void ResetIterator(FrameOffset displacement) override; 38 // Managed runtime calling convention 39 ManagedRegister MethodRegister() override; 40 void Next() override; 41 bool IsCurrentParamInRegister() override; 42 bool IsCurrentParamOnStack() override; 43 ManagedRegister CurrentParamRegister() override; 44 FrameOffset CurrentParamStackOffset() override; 45 46 private: 47 int gpr_arg_count_; 48 DISALLOW_COPY_AND_ASSIGN(X86ManagedRuntimeCallingConvention); 49 }; 50 51 // Implements the x86 cdecl calling convention. 52 class X86JniCallingConvention final : public JniCallingConvention { 53 public: 54 X86JniCallingConvention(bool is_static, 55 bool is_synchronized, 56 bool is_critical_native, 57 const char* shorty); ~X86JniCallingConvention()58 ~X86JniCallingConvention() override {} 59 // Calling convention 60 ManagedRegister ReturnRegister() override; 61 ManagedRegister IntReturnRegister() override; 62 // JNI calling convention 63 size_t FrameSize() const override; 64 size_t OutFrameSize() const override; 65 ArrayRef<const ManagedRegister> CalleeSaveRegisters() const override; 66 ManagedRegister ReturnScratchRegister() const override; 67 uint32_t CoreSpillMask() const override; 68 uint32_t FpSpillMask() const override; 69 bool IsCurrentParamInRegister() override; 70 bool IsCurrentParamOnStack() override; 71 ManagedRegister CurrentParamRegister() override; 72 FrameOffset CurrentParamStackOffset() override; 73 74 // x86 needs to extend small return types. RequiresSmallResultTypeExtension()75 bool RequiresSmallResultTypeExtension() const override { 76 return HasSmallReturnType(); 77 } 78 79 // Hidden argument register, used to pass the method pointer for @CriticalNative call. 80 ManagedRegister HiddenArgumentRegister() const override; 81 82 // Whether to use tail call (used only for @CriticalNative). 83 bool UseTailCall() const override; 84 85 private: 86 DISALLOW_COPY_AND_ASSIGN(X86JniCallingConvention); 87 }; 88 89 } // namespace x86 90 } // namespace art 91 92 #endif // ART_COMPILER_JNI_QUICK_X86_CALLING_CONVENTION_X86_H_ 93