blob: 264ec6a99710e4a84c88e868c6d7de309858253a [file] [log] [blame]
Andreas Gampe36a296f2017-06-13 14:11:11 -07001/*
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
21namespace art {
22
23mirror::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 Chartier808c7a52017-12-15 11:19:33 -080030 CHECK(m->GetCodeItem() != nullptr) << ArtMethod::PrettyMethod(m);
David Sehr0225f8e2018-01-31 08:52:24 +000031 CodeItemDataAccessor accessor(m->DexInstructionData());
Mathieu Chartier808c7a52017-12-15 11:19:33 -080032 uint16_t reg = accessor.RegistersSize() - accessor.InsSize();
Andreas Gampe36a296f2017-06-13 14:11:11 -070033 return GetVRegReference(reg);
34 }
35}
36
37mirror::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