1 /* 2 * Copyright (C) 2019 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_NTERP_HELPERS_H_ 18 #define ART_RUNTIME_NTERP_HELPERS_H_ 19 20 #include "quick/quick_method_frame_info.h" 21 22 namespace art { 23 24 class ArtMethod; 25 26 /** 27 * Returns the QuickMethodFrameInfo of the given frame corresponding to the 28 * given method. 29 */ 30 QuickMethodFrameInfo NterpFrameInfo(ArtMethod** frame) 31 REQUIRES_SHARED(Locks::mutator_lock_); 32 33 /** 34 * Returns the dex PC at which the given nterp frame is executing. 35 */ 36 uint32_t NterpGetDexPC(ArtMethod** frame) 37 REQUIRES_SHARED(Locks::mutator_lock_); 38 39 /** 40 * Returns the reference array to be used by the GC to visit references in an 41 * nterp frame. 42 */ 43 uintptr_t NterpGetReferenceArray(ArtMethod** frame) 44 REQUIRES_SHARED(Locks::mutator_lock_); 45 46 /** 47 * Returns the dex register array to be used by the GC to update references in 48 * an nterp frame. 49 */ 50 uintptr_t NterpGetRegistersArray(ArtMethod** frame) 51 REQUIRES_SHARED(Locks::mutator_lock_); 52 53 /** 54 * Returns the nterp landing pad for catching an exception. 55 */ 56 uintptr_t NterpGetCatchHandler(); 57 58 /** 59 * Returns the value of dex register number `vreg` in the given frame. 60 */ 61 uint32_t NterpGetVReg(ArtMethod** frame, uint16_t vreg) 62 REQUIRES_SHARED(Locks::mutator_lock_); 63 64 /** 65 * Returns the value of dex register number `vreg` in the given frame if it is a 66 * reference. Return 0 otehrwise. 67 */ 68 uint32_t NterpGetVRegReference(ArtMethod** frame, uint16_t vreg) 69 REQUIRES_SHARED(Locks::mutator_lock_); 70 71 /** 72 * Returns whether the given method can run with nterp. The instruction set can 73 * be passed for cross-compilation. 74 */ 75 bool CanMethodUseNterp(ArtMethod* method, InstructionSet isa = kRuntimeISA) 76 REQUIRES_SHARED(Locks::mutator_lock_); 77 78 } // namespace art 79 80 #endif // ART_RUNTIME_NTERP_HELPERS_H_ 81