Path: blob/master/src/hotspot/share/prims/jvmtiDeferredUpdates.cpp
41144 views
/*1* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.2* Copyright (c) 2020 SAP SE. All rights reserved.3* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.4*5* This code is free software; you can redistribute it and/or modify it6* under the terms of the GNU General Public License version 2 only, as7* published by the Free Software Foundation.8*9* This code is distributed in the hope that it will be useful, but WITHOUT10* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or11* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License12* version 2 for more details (a copy is included in the LICENSE file that13* accompanied this code).14*15* You should have received a copy of the GNU General Public License version16* 2 along with this work; if not, write to the Free Software Foundation,17* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.18*19* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA20* or visit www.oracle.com if you need additional information or have any21* questions.22*23*/2425#include "precompiled.hpp"26#include "prims/jvmtiDeferredUpdates.hpp"2728void JvmtiDeferredUpdates::create_for(JavaThread* thread) {29assert(thread->deferred_updates() == NULL, "already allocated");30thread->set_deferred_updates(new JvmtiDeferredUpdates());31}3233JvmtiDeferredUpdates::~JvmtiDeferredUpdates() {34while (_deferred_locals_updates.length() != 0) {35jvmtiDeferredLocalVariableSet* dlv = _deferred_locals_updates.pop();36// individual jvmtiDeferredLocalVariableSet are CHeapObj's37delete dlv;38}39}4041void JvmtiDeferredUpdates::inc_relock_count_after_wait(JavaThread* thread) {42if (thread->deferred_updates() == NULL) {43create_for(thread);44}45thread->deferred_updates()->inc_relock_count_after_wait();46}4748int JvmtiDeferredUpdates::get_and_reset_relock_count_after_wait(JavaThread* jt) {49JvmtiDeferredUpdates* updates = jt->deferred_updates();50int result = 0;51if (updates != NULL) {52result = updates->get_and_reset_relock_count_after_wait();53if (updates->count() == 0) {54delete updates;55jt->set_deferred_updates(NULL);56}57}58return result;59}6061void JvmtiDeferredUpdates::delete_updates_for_frame(JavaThread* jt, intptr_t* frame_id) {62JvmtiDeferredUpdates* updates = jt->deferred_updates();63if (updates != NULL) {64GrowableArray<jvmtiDeferredLocalVariableSet*>* list = updates->deferred_locals();65assert(list->length() > 0, "Updates holder not deleted");66int i = 0;67do {68// Because of inlining we could have multiple vframes for a single frame69// and several of the vframes could have deferred writes. Find them all.70jvmtiDeferredLocalVariableSet* dlv = list->at(i);71if (dlv->id() == frame_id) {72list->remove_at(i);73// individual jvmtiDeferredLocalVariableSet are CHeapObj's74delete dlv;75} else {76i++;77}78} while ( i < list->length() );79if (updates->count() == 0) {80jt->set_deferred_updates(NULL);81// Free deferred updates.82// Note, the 'list' of local variable updates is embedded in 'updates'.83delete updates;84}85}86}878889