1 /* 2 * Copyright (C) 2014 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_RUNTIME_ARCH_X86_QUICK_METHOD_FRAME_INFO_X86_H_ 18 #define ART_RUNTIME_ARCH_X86_QUICK_METHOD_FRAME_INFO_X86_H_ 19 20 #include "quick/quick_method_frame_info.h" 21 #include "registers_x86.h" 22 #include "runtime.h" // for Runtime::CalleeSaveType. 23 24 namespace art { 25 namespace x86 { 26 27 static constexpr uint32_t kX86CalleeSaveRefSpills = 28 (1 << art::x86::EBP) | (1 << art::x86::ESI) | (1 << art::x86::EDI); 29 static constexpr uint32_t kX86CalleeSaveArgSpills = 30 (1 << art::x86::ECX) | (1 << art::x86::EDX) | (1 << art::x86::EBX); 31 X86CalleeSaveCoreSpills(Runtime::CalleeSaveType type)32constexpr uint32_t X86CalleeSaveCoreSpills(Runtime::CalleeSaveType type) { 33 return kX86CalleeSaveRefSpills | (type == Runtime::kRefsAndArgs ? kX86CalleeSaveArgSpills : 0) | 34 (1 << art::x86::kNumberOfCpuRegisters); // fake return address callee save 35 } 36 X86CalleeSaveFrameSize(Runtime::CalleeSaveType type)37constexpr uint32_t X86CalleeSaveFrameSize(Runtime::CalleeSaveType type) { 38 return RoundUp((POPCOUNT(X86CalleeSaveCoreSpills(type)) /* gprs */ + 39 1 /* Method* */) * kX86PointerSize, kStackAlignment); 40 } 41 X86CalleeSaveMethodFrameInfo(Runtime::CalleeSaveType type)42constexpr QuickMethodFrameInfo X86CalleeSaveMethodFrameInfo(Runtime::CalleeSaveType type) { 43 return QuickMethodFrameInfo(X86CalleeSaveFrameSize(type), 44 X86CalleeSaveCoreSpills(type), 45 0u); 46 } 47 48 } // namespace x86 49 } // namespace art 50 51 #endif // ART_RUNTIME_ARCH_X86_QUICK_METHOD_FRAME_INFO_X86_H_ 52