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 #include "shadow_frame.h" 18 19 #include "art_method-inl.h" 20 21 namespace art { 22 GetThisObject() const23mirror::Object* ShadowFrame::GetThisObject() const { 24 ArtMethod* m = GetMethod(); 25 if (m->IsStatic()) { 26 return nullptr; 27 } else if (m->IsNative()) { 28 return GetVRegReference(0); 29 } else { 30 CHECK(m->GetCodeItem() != nullptr) << ArtMethod::PrettyMethod(m); 31 CodeItemDataAccessor accessor(m->DexInstructionData()); 32 uint16_t reg = accessor.RegistersSize() - accessor.InsSize(); 33 return GetVRegReference(reg); 34 } 35 } 36 GetThisObject(uint16_t num_ins) const37mirror::Object* ShadowFrame::GetThisObject(uint16_t num_ins) const { 38 ArtMethod* m = GetMethod(); 39 if (m->IsStatic()) { 40 return nullptr; 41 } else { 42 return GetVRegReference(NumberOfVRegs() - num_ins); 43 } 44 } 45 46 } // namespace art 47