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 "managed_stack-inl.h" 18 19 #include "android-base/stringprintf.h" 20 21 #include "art_method.h" 22 #include "mirror/object.h" 23 #include "stack_reference.h" 24 25 namespace art { 26 NumJniShadowFrameReferences() const27size_t ManagedStack::NumJniShadowFrameReferences() const { 28 size_t count = 0; 29 for (const ManagedStack* current_fragment = this; current_fragment != nullptr; 30 current_fragment = current_fragment->GetLink()) { 31 for (ShadowFrame* current_frame = current_fragment->top_shadow_frame_; 32 current_frame != nullptr; 33 current_frame = current_frame->GetLink()) { 34 if (current_frame->GetMethod()->IsNative()) { 35 // The JNI ShadowFrame only contains references. (For indirect reference.) 36 count += current_frame->NumberOfVRegs(); 37 } 38 } 39 } 40 return count; 41 } 42 ShadowFramesContain(StackReference<mirror::Object> * shadow_frame_entry) const43bool ManagedStack::ShadowFramesContain(StackReference<mirror::Object>* shadow_frame_entry) const { 44 for (const ManagedStack* current_fragment = this; current_fragment != nullptr; 45 current_fragment = current_fragment->GetLink()) { 46 for (ShadowFrame* current_frame = current_fragment->top_shadow_frame_; 47 current_frame != nullptr; 48 current_frame = current_frame->GetLink()) { 49 if (current_frame->Contains(shadow_frame_entry)) { 50 return true; 51 } 52 } 53 } 54 return false; 55 } 56 57 } // namespace art 58