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