11a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe/* 21a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe * Copyright (C) 2014 The Android Open Source Project 31a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe * 41a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe * Licensed under the Apache License, Version 2.0 (the "License"); 51a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe * you may not use this file except in compliance with the License. 61a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe * You may obtain a copy of the License at 71a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe * 81a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe * http://www.apache.org/licenses/LICENSE-2.0 91a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe * 101a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe * Unless required by applicable law or agreed to in writing, software 111a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe * distributed under the License is distributed on an "AS IS" BASIS, 121a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 131a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe * See the License for the specific language governing permissions and 141a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe * limitations under the License. 151a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe */ 161a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe 171a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe#ifndef ART_RUNTIME_ARCH_MIPS64_CONTEXT_MIPS64_H_ 181a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe#define ART_RUNTIME_ARCH_MIPS64_CONTEXT_MIPS64_H_ 191a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe 201a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe#include "arch/context.h" 211a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe#include "base/logging.h" 22794ad76e8d5b5b9132819d5b08a0570e27615644Andreas Gampe#include "base/macros.h" 231a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe#include "registers_mips64.h" 241a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe 251a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampenamespace art { 261a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampenamespace mips64 { 271a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe 281a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampeclass Mips64Context : public Context { 291a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe public: 301a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe Mips64Context() { 311a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe Reset(); 321a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe } 331a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe virtual ~Mips64Context() {} 341a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe 351a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe void Reset() OVERRIDE; 361a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe 37524e7ea8cd17bad17bd9f3e0ccbb19ad0d4d9c02Nicolas Geoffray void FillCalleeSaves(uint8_t* frame, const QuickMethodFrameInfo& fr) OVERRIDE; 381a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe 391a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe void SetSP(uintptr_t new_sp) OVERRIDE { 4096ba8dc82e7bd859106af837623fe8b2e9e772c3Sebastien Hertz SetGPR(SP, new_sp); 411a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe } 421a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe 431a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe void SetPC(uintptr_t new_pc) OVERRIDE { 44dbf056d38dddda10c5f409e3155c7b4211183f63Andreas Gampe SetGPR(T9, new_pc); 4596ba8dc82e7bd859106af837623fe8b2e9e772c3Sebastien Hertz } 4696ba8dc82e7bd859106af837623fe8b2e9e772c3Sebastien Hertz 4796ba8dc82e7bd859106af837623fe8b2e9e772c3Sebastien Hertz bool IsAccessibleGPR(uint32_t reg) OVERRIDE { 4896ba8dc82e7bd859106af837623fe8b2e9e772c3Sebastien Hertz DCHECK_LT(reg, static_cast<uint32_t>(kNumberOfGpuRegisters)); 4996ba8dc82e7bd859106af837623fe8b2e9e772c3Sebastien Hertz return gprs_[reg] != nullptr; 501a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe } 511a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe 521a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe uintptr_t* GetGPRAddress(uint32_t reg) OVERRIDE { 531a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe DCHECK_LT(reg, static_cast<uint32_t>(kNumberOfGpuRegisters)); 541a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe return gprs_[reg]; 551a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe } 561a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe 5796ba8dc82e7bd859106af837623fe8b2e9e772c3Sebastien Hertz uintptr_t GetGPR(uint32_t reg) OVERRIDE { 581a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe CHECK_LT(reg, static_cast<uint32_t>(kNumberOfGpuRegisters)); 5996ba8dc82e7bd859106af837623fe8b2e9e772c3Sebastien Hertz DCHECK(IsAccessibleGPR(reg)); 6096ba8dc82e7bd859106af837623fe8b2e9e772c3Sebastien Hertz return *gprs_[reg]; 611a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe } 621a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe 6396ba8dc82e7bd859106af837623fe8b2e9e772c3Sebastien Hertz void SetGPR(uint32_t reg, uintptr_t value) OVERRIDE; 6496ba8dc82e7bd859106af837623fe8b2e9e772c3Sebastien Hertz 6596ba8dc82e7bd859106af837623fe8b2e9e772c3Sebastien Hertz bool IsAccessibleFPR(uint32_t reg) OVERRIDE { 6696ba8dc82e7bd859106af837623fe8b2e9e772c3Sebastien Hertz CHECK_LT(reg, static_cast<uint32_t>(kNumberOfFpuRegisters)); 6796ba8dc82e7bd859106af837623fe8b2e9e772c3Sebastien Hertz return fprs_[reg] != nullptr; 6896ba8dc82e7bd859106af837623fe8b2e9e772c3Sebastien Hertz } 691a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe 7096ba8dc82e7bd859106af837623fe8b2e9e772c3Sebastien Hertz uintptr_t GetFPR(uint32_t reg) OVERRIDE { 711a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe CHECK_LT(reg, static_cast<uint32_t>(kNumberOfFpuRegisters)); 7296ba8dc82e7bd859106af837623fe8b2e9e772c3Sebastien Hertz DCHECK(IsAccessibleFPR(reg)); 7396ba8dc82e7bd859106af837623fe8b2e9e772c3Sebastien Hertz return *fprs_[reg]; 741a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe } 751a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe 7696ba8dc82e7bd859106af837623fe8b2e9e772c3Sebastien Hertz void SetFPR(uint32_t reg, uintptr_t value) OVERRIDE; 771a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe 781a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe void SmashCallerSaves() OVERRIDE; 79794ad76e8d5b5b9132819d5b08a0570e27615644Andreas Gampe NO_RETURN void DoLongJump() OVERRIDE; 801a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe 81639bdd13993644a267f177f8f5936496bda65e2bAndreas Gampe void SetArg0(uintptr_t new_arg0_value) OVERRIDE { 82639bdd13993644a267f177f8f5936496bda65e2bAndreas Gampe SetGPR(A0, new_arg0_value); 83639bdd13993644a267f177f8f5936496bda65e2bAndreas Gampe } 84639bdd13993644a267f177f8f5936496bda65e2bAndreas Gampe 851a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe private: 862cebb24bfc3247d3e9be138a3350106737455918Mathieu Chartier // Pointers to registers in the stack, initialized to null except for the special cases below. 871a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe uintptr_t* gprs_[kNumberOfGpuRegisters]; 881a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe uint64_t* fprs_[kNumberOfFpuRegisters]; 89dbf056d38dddda10c5f409e3155c7b4211183f63Andreas Gampe // Hold values for sp and t9 if they are not located within a stack frame. We use t9 for the 90639bdd13993644a267f177f8f5936496bda65e2bAndreas Gampe // PC (as ra is required to be valid for single-frame deopt and must not be clobbered). We 91639bdd13993644a267f177f8f5936496bda65e2bAndreas Gampe // also need the first argument for single-frame deopt. 92639bdd13993644a267f177f8f5936496bda65e2bAndreas Gampe uintptr_t sp_, t9_, arg0_; 931a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe}; 94639bdd13993644a267f177f8f5936496bda65e2bAndreas Gampe 951a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe} // namespace mips64 961a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe} // namespace art 971a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe 981a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe#endif // ART_RUNTIME_ARCH_MIPS64_CONTEXT_MIPS64_H_ 99