Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/hotspot/share/prims/jvmtiDeferredUpdates.hpp
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
#ifndef SHARE_PRIMS_JVMTIDEFERREDUPDATES_HPP
27
#define SHARE_PRIMS_JVMTIDEFERREDUPDATES_HPP
28
29
#include "runtime/thread.inline.hpp"
30
#include "utilities/globalDefinitions.hpp"
31
#include "utilities/growableArray.hpp"
32
33
class jvmtiDeferredLocalVariable : public CHeapObj<mtCompiler> {
34
35
private:
36
37
BasicType _type;
38
jvalue _value;
39
int _index;
40
41
public:
42
43
jvmtiDeferredLocalVariable(int index, BasicType type, jvalue value);
44
45
BasicType type(void) { return _type; }
46
int index(void) { return _index; }
47
jvalue value(void) { return _value; }
48
49
// Only mutator is for value as only it can change
50
void set_value(jvalue value) { _value = value; }
51
52
// For gc
53
oop* oop_addr(void) { return (oop*) &_value.l; }
54
};
55
56
// In order to implement set_locals for compiled vframes we must
57
// store updated locals in a data structure that contains enough
58
// information to recognize equality with a vframe and to store
59
// any updated locals.
60
61
class StackValueCollection;
62
63
class jvmtiDeferredLocalVariableSet : public CHeapObj<mtCompiler> {
64
friend class compiledVFrame;
65
66
private:
67
68
Method* _method;
69
int _bci;
70
intptr_t* _id;
71
int _vframe_id;
72
GrowableArray<jvmtiDeferredLocalVariable*>* _locals;
73
bool _objects_are_deoptimized;
74
75
void update_value(StackValueCollection* locals, BasicType type, int index, jvalue value);
76
77
void set_value_at(int idx, BasicType typ, jvalue val);
78
79
public:
80
// JVM state
81
Method* method() const { return _method; }
82
int bci() const { return _bci; }
83
intptr_t* id() const { return _id; }
84
int vframe_id() const { return _vframe_id; }
85
bool objects_are_deoptimized() const { return _objects_are_deoptimized; }
86
87
void update_locals(StackValueCollection* locals);
88
void update_stack(StackValueCollection* locals);
89
void update_monitors(GrowableArray<MonitorInfo*>* monitors);
90
void set_objs_are_deoptimized() { _objects_are_deoptimized = true; }
91
92
// Does the vframe match this jvmtiDeferredLocalVariableSet
93
bool matches(const vframe* vf);
94
95
// Does the underlying physical frame match this jvmtiDeferredLocalVariableSet
96
bool matches(intptr_t* fr_id) { return id() == fr_id; }
97
98
// GC
99
void oops_do(OopClosure* f);
100
101
// constructor
102
jvmtiDeferredLocalVariableSet(Method* method, int bci, intptr_t* id, int vframe_id);
103
104
// destructor
105
~jvmtiDeferredLocalVariableSet();
106
};
107
108
// Holds updates for compiled frames by JVMTI agents that cannot be performed immediately.
109
110
class JvmtiDeferredUpdates : public CHeapObj<mtCompiler> {
111
112
// Relocking has to be deferred if the lock owning thread is currently waiting on the monitor.
113
int _relock_count_after_wait;
114
115
// Deferred updates of locals, expressions, and monitors
116
GrowableArray<jvmtiDeferredLocalVariableSet*> _deferred_locals_updates;
117
118
void inc_relock_count_after_wait() {
119
_relock_count_after_wait++;
120
}
121
122
int get_and_reset_relock_count_after_wait() {
123
int result = _relock_count_after_wait;
124
_relock_count_after_wait = 0;
125
return result;
126
}
127
128
GrowableArray<jvmtiDeferredLocalVariableSet*>* deferred_locals() { return &_deferred_locals_updates; }
129
130
JvmtiDeferredUpdates() :
131
_relock_count_after_wait(0),
132
_deferred_locals_updates((ResourceObj::set_allocation_type((address) &_deferred_locals_updates,
133
ResourceObj::C_HEAP), 1), mtCompiler) { }
134
135
public:
136
~JvmtiDeferredUpdates();
137
138
static void create_for(JavaThread* thread);
139
140
static GrowableArray<jvmtiDeferredLocalVariableSet*>* deferred_locals(JavaThread* jt) {
141
return jt->deferred_updates() == NULL ? NULL : jt->deferred_updates()->deferred_locals();
142
}
143
144
// Relocking has to be deferred if the lock owning thread is currently waiting on the monitor.
145
static int get_and_reset_relock_count_after_wait(JavaThread* jt);
146
static void inc_relock_count_after_wait(JavaThread* thread);
147
148
// Delete deferred updates for the compiled frame with id 'frame_id' on the
149
// given thread's stack. The thread's JvmtiDeferredUpdates instance will be
150
// deleted too if no updates remain.
151
static void delete_updates_for_frame(JavaThread* jt, intptr_t* frame_id);
152
153
// Number of deferred updates
154
int count() const {
155
return _deferred_locals_updates.length() + (_relock_count_after_wait > 0 ? 1 : 0);
156
}
157
};
158
159
#endif // SHARE_PRIMS_JVMTIDEFERREDUPDATES_HPP
160
161