12faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes/* 22faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * Copyright (C) 2011 The Android Open Source Project 32faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * 42faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * Licensed under the Apache License, Version 2.0 (the "License"); 52faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * you may not use this file except in compliance with the License. 62faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * You may obtain a copy of the License at 72faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * 82faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * http://www.apache.org/licenses/LICENSE-2.0 92faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * 102faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * Unless required by applicable law or agreed to in writing, software 112faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * distributed under the License is distributed on an "AS IS" BASIS, 122faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 132faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * See the License for the specific language governing permissions and 142faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * limitations under the License. 152faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes */ 162c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers 17fc0e3219edc9a5bf81b166e82fd5db2796eb6a0dBrian Carlstrom#ifndef ART_COMPILER_JNI_QUICK_X86_CALLING_CONVENTION_X86_H_ 18fc0e3219edc9a5bf81b166e82fd5db2796eb6a0dBrian Carlstrom#define ART_COMPILER_JNI_QUICK_X86_CALLING_CONVENTION_X86_H_ 192c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers 207940e44f4517de5e2634a7e07d58d0fb26160513Brian Carlstrom#include "jni/quick/calling_convention.h" 212c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers 222c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersnamespace art { 232c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersnamespace x86 { 242c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers 25790a6b7312979513710c366b411ba6791ddf78c2Ian Rogersconstexpr size_t kFramePointerSize = 4; 26790a6b7312979513710c366b411ba6791ddf78c2Ian Rogers 2725ff0048a70c79272884d5d0f8e9b9861a451afeAndreas Gampeclass X86ManagedRuntimeCallingConvention FINAL : public ManagedRuntimeCallingConvention { 282c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers public: 29169c9a7f46776b235d0a37d5e0ff27682deffe06Ian Rogers explicit X86ManagedRuntimeCallingConvention(bool is_static, bool is_synchronized, 30ca190666fb11820153f74274c495ba1f913d8a69Ian Rogers const char* shorty) 31966c3ae95d3c699ee9fbdbccc1acdaaf02325fafMark P Mendell : ManagedRuntimeCallingConvention(is_static, is_synchronized, shorty, kFramePointerSize), 32966c3ae95d3c699ee9fbdbccc1acdaaf02325fafMark P Mendell gpr_arg_count_(0) {} 3325ff0048a70c79272884d5d0f8e9b9861a451afeAndreas Gampe ~X86ManagedRuntimeCallingConvention() OVERRIDE {} 342c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers // Calling convention 3525ff0048a70c79272884d5d0f8e9b9861a451afeAndreas Gampe ManagedRegister ReturnRegister() OVERRIDE; 3625ff0048a70c79272884d5d0f8e9b9861a451afeAndreas Gampe ManagedRegister InterproceduralScratchRegister() OVERRIDE; 372c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers // Managed runtime calling convention 3825ff0048a70c79272884d5d0f8e9b9861a451afeAndreas Gampe ManagedRegister MethodRegister() OVERRIDE; 3925ff0048a70c79272884d5d0f8e9b9861a451afeAndreas Gampe bool IsCurrentParamInRegister() OVERRIDE; 4025ff0048a70c79272884d5d0f8e9b9861a451afeAndreas Gampe bool IsCurrentParamOnStack() OVERRIDE; 4125ff0048a70c79272884d5d0f8e9b9861a451afeAndreas Gampe ManagedRegister CurrentParamRegister() OVERRIDE; 4225ff0048a70c79272884d5d0f8e9b9861a451afeAndreas Gampe FrameOffset CurrentParamStackOffset() OVERRIDE; 43fca82208f7128fcda09b6a4743199308332558a2Dmitry Petrochenko const ManagedRegisterEntrySpills& EntrySpills() OVERRIDE; 44966c3ae95d3c699ee9fbdbccc1acdaaf02325fafMark P Mendell 452c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers private: 46966c3ae95d3c699ee9fbdbccc1acdaaf02325fafMark P Mendell int gpr_arg_count_; 47966c3ae95d3c699ee9fbdbccc1acdaaf02325fafMark P Mendell ManagedRegister CurrentParamHighLongRegister(); 48fca82208f7128fcda09b6a4743199308332558a2Dmitry Petrochenko ManagedRegisterEntrySpills entry_spills_; 492c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers DISALLOW_COPY_AND_ASSIGN(X86ManagedRuntimeCallingConvention); 502c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers}; 512c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers 5225ff0048a70c79272884d5d0f8e9b9861a451afeAndreas Gampeclass X86JniCallingConvention FINAL : public JniCallingConvention { 532c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers public: 54703f2cd1f4d1eb5ab5c9792ca2de9ffb39378203jeffhao explicit X86JniCallingConvention(bool is_static, bool is_synchronized, const char* shorty); 5525ff0048a70c79272884d5d0f8e9b9861a451afeAndreas Gampe ~X86JniCallingConvention() OVERRIDE {} 562c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers // Calling convention 5725ff0048a70c79272884d5d0f8e9b9861a451afeAndreas Gampe ManagedRegister ReturnRegister() OVERRIDE; 5825ff0048a70c79272884d5d0f8e9b9861a451afeAndreas Gampe ManagedRegister IntReturnRegister() OVERRIDE; 5925ff0048a70c79272884d5d0f8e9b9861a451afeAndreas Gampe ManagedRegister InterproceduralScratchRegister() OVERRIDE; 602c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers // JNI calling convention 6125ff0048a70c79272884d5d0f8e9b9861a451afeAndreas Gampe size_t FrameSize() OVERRIDE; 6225ff0048a70c79272884d5d0f8e9b9861a451afeAndreas Gampe size_t OutArgSize() OVERRIDE; 6325ff0048a70c79272884d5d0f8e9b9861a451afeAndreas Gampe const std::vector<ManagedRegister>& CalleeSaveRegisters() const OVERRIDE { 64bdb0391258abc54bf77c676e36847d28a783bfe5Ian Rogers return callee_save_regs_; 65bdb0391258abc54bf77c676e36847d28a783bfe5Ian Rogers } 6625ff0048a70c79272884d5d0f8e9b9861a451afeAndreas Gampe ManagedRegister ReturnScratchRegister() const OVERRIDE; 6725ff0048a70c79272884d5d0f8e9b9861a451afeAndreas Gampe uint32_t CoreSpillMask() const OVERRIDE; 6825ff0048a70c79272884d5d0f8e9b9861a451afeAndreas Gampe uint32_t FpSpillMask() const OVERRIDE { 69bdb0391258abc54bf77c676e36847d28a783bfe5Ian Rogers return 0; 70bdb0391258abc54bf77c676e36847d28a783bfe5Ian Rogers } 7125ff0048a70c79272884d5d0f8e9b9861a451afeAndreas Gampe bool IsCurrentParamInRegister() OVERRIDE; 7225ff0048a70c79272884d5d0f8e9b9861a451afeAndreas Gampe bool IsCurrentParamOnStack() OVERRIDE; 7325ff0048a70c79272884d5d0f8e9b9861a451afeAndreas Gampe ManagedRegister CurrentParamRegister() OVERRIDE; 7425ff0048a70c79272884d5d0f8e9b9861a451afeAndreas Gampe FrameOffset CurrentParamStackOffset() OVERRIDE; 752c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers 76d1104322e5156669767e8b2c3b843ffaff173381Andreas Gampe // x86 needs to extend small return types. 77d1104322e5156669767e8b2c3b843ffaff173381Andreas Gampe bool RequiresSmallResultTypeExtension() const OVERRIDE { 78d1104322e5156669767e8b2c3b843ffaff173381Andreas Gampe return true; 79d1104322e5156669767e8b2c3b843ffaff173381Andreas Gampe } 80d1104322e5156669767e8b2c3b843ffaff173381Andreas Gampe 812c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers protected: 8225ff0048a70c79272884d5d0f8e9b9861a451afeAndreas Gampe size_t NumberOfOutgoingStackArgs() OVERRIDE; 832c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers 842c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers private: 85703f2cd1f4d1eb5ab5c9792ca2de9ffb39378203jeffhao // TODO: these values aren't unique and can be shared amongst instances 86703f2cd1f4d1eb5ab5c9792ca2de9ffb39378203jeffhao std::vector<ManagedRegister> callee_save_regs_; 87bdb0391258abc54bf77c676e36847d28a783bfe5Ian Rogers 882c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers DISALLOW_COPY_AND_ASSIGN(X86JniCallingConvention); 892c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers}; 902c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers 912c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers} // namespace x86 922c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers} // namespace art 932c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers 94fc0e3219edc9a5bf81b166e82fd5db2796eb6a0dBrian Carlstrom#endif // ART_COMPILER_JNI_QUICK_X86_CALLING_CONVENTION_X86_H_ 95