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