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() const 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_fast_native, 57 bool is_critical_native, 58 const char* shorty); ~X86JniCallingConvention()59 ~X86JniCallingConvention() override {} 60 // Calling convention 61 ManagedRegister ReturnRegister() const override; 62 ManagedRegister IntReturnRegister() const override; 63 // JNI calling convention 64 size_t FrameSize() const override; 65 size_t OutFrameSize() const override; 66 ArrayRef<const ManagedRegister> CalleeSaveRegisters() const override; 67 ArrayRef<const ManagedRegister> CalleeSaveScratchRegisters() const override; 68 ArrayRef<const ManagedRegister> ArgumentScratchRegisters() const override; 69 uint32_t CoreSpillMask() const override; 70 uint32_t FpSpillMask() const override; 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 HasSmallReturnType(); 79 } 80 81 // Locking argument register, used to pass the synchronization object for calls 82 // to `JniLockObject()` and `JniUnlockObject()`. 83 ManagedRegister LockingArgumentRegister() const override; 84 85 // Hidden argument register, used to pass the method pointer for @CriticalNative call. 86 ManagedRegister HiddenArgumentRegister() const override; 87 88 // Whether to use tail call (used only for @CriticalNative). 89 bool UseTailCall() const override; 90 91 private: 92 DISALLOW_COPY_AND_ASSIGN(X86JniCallingConvention); 93 }; 94 95 } // namespace x86 96 } // namespace art 97 98 #endif // ART_COMPILER_JNI_QUICK_X86_CALLING_CONVENTION_X86_H_ 99