Andreas Gampe | 36a296f | 2017-06-13 14:11:11 -0700 | [diff] [blame] | 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 | |
| 23 | mirror::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 { |
Mathieu Chartier | 808c7a5 | 2017-12-15 11:19:33 -0800 | [diff] [blame] | 30 | CHECK(m->GetCodeItem() != nullptr) << ArtMethod::PrettyMethod(m); |
David Sehr | 0225f8e | 2018-01-31 08:52:24 +0000 | [diff] [blame^] | 31 | CodeItemDataAccessor accessor(m->DexInstructionData()); |
Mathieu Chartier | 808c7a5 | 2017-12-15 11:19:33 -0800 | [diff] [blame] | 32 | uint16_t reg = accessor.RegistersSize() - accessor.InsSize(); |
Andreas Gampe | 36a296f | 2017-06-13 14:11:11 -0700 | [diff] [blame] | 33 | return GetVRegReference(reg); |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | mirror::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 |