1 | /* |
2 | * Copyright (c) 1997, 2019, Oracle and/or its affiliates. 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 it |
6 | * under the terms of the GNU General Public License version 2 only, as |
7 | * published by the Free Software Foundation. |
8 | * |
9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
12 | * version 2 for more details (a copy is included in the LICENSE file that |
13 | * accompanied this code). |
14 | * |
15 | * You should have received a copy of the GNU General Public License version |
16 | * 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 USA |
20 | * or visit www.oracle.com if you need additional information or have any |
21 | * questions. |
22 | * |
23 | */ |
24 | |
25 | #ifndef SHARE_RUNTIME_VFRAME_HP_HPP |
26 | #define SHARE_RUNTIME_VFRAME_HP_HPP |
27 | |
28 | #include "runtime/vframe.hpp" |
29 | |
30 | class compiledVFrame: public javaVFrame { |
31 | public: |
32 | // JVM state |
33 | Method* method() const; |
34 | int bci() const; |
35 | bool should_reexecute() const; |
36 | StackValueCollection* locals() const; |
37 | StackValueCollection* expressions() const; |
38 | GrowableArray<MonitorInfo*>* monitors() const; |
39 | int vframe_id() const { return _vframe_id; } |
40 | |
41 | void set_locals(StackValueCollection* values) const; |
42 | |
43 | // Virtuals defined in vframe |
44 | bool is_compiled_frame() const { return true; } |
45 | vframe* sender() const; |
46 | bool is_top() const; |
47 | |
48 | // Casting |
49 | static compiledVFrame* cast(vframe* vf) { |
50 | assert(vf == NULL || vf->is_compiled_frame(), "must be compiled frame" ); |
51 | return (compiledVFrame*) vf; |
52 | } |
53 | |
54 | void update_deferred_value(BasicType type, int index, jvalue value); |
55 | |
56 | public: |
57 | // Constructors |
58 | compiledVFrame(const frame* fr, const RegisterMap* reg_map, JavaThread* thread, CompiledMethod* nm); |
59 | |
60 | // Update a local in a compiled frame. Update happens when deopt occurs |
61 | void update_local(BasicType type, int index, jvalue value); |
62 | |
63 | // Update an expression stack value in a compiled frame. Update happens when deopt occurs |
64 | void update_stack(BasicType type, int index, jvalue value); |
65 | |
66 | // Update a lock value in a compiled frame. Update happens when deopt occurs |
67 | void update_monitor(int index, MonitorInfo* value); |
68 | |
69 | // Returns the active nmethod |
70 | CompiledMethod* code() const; |
71 | |
72 | // Returns the scopeDesc |
73 | ScopeDesc* scope() const { return _scope; } |
74 | |
75 | // Return the compiledVFrame for the desired scope |
76 | compiledVFrame* at_scope(int decode_offset, int vframe_id); |
77 | |
78 | // Returns SynchronizationEntryBCI or bci() (used for synchronization) |
79 | int raw_bci() const; |
80 | |
81 | protected: |
82 | ScopeDesc* _scope; |
83 | int _vframe_id; |
84 | |
85 | //StackValue resolve(ScopeValue* sv) const; |
86 | BasicLock* resolve_monitor_lock(Location location) const; |
87 | StackValue *create_stack_value(ScopeValue *sv) const; |
88 | |
89 | private: |
90 | compiledVFrame(const frame* fr, const RegisterMap* reg_map, JavaThread* thread, ScopeDesc* scope, int vframe_id); |
91 | |
92 | #ifndef PRODUCT |
93 | public: |
94 | void verify() const; |
95 | #endif |
96 | }; |
97 | |
98 | // In order to implement set_locals for compiled vframes we must |
99 | // store updated locals in a data structure that contains enough |
100 | // information to recognize equality with a vframe and to store |
101 | // any updated locals. |
102 | |
103 | class jvmtiDeferredLocalVariable; |
104 | class jvmtiDeferredLocalVariableSet : public CHeapObj<mtCompiler> { |
105 | friend class compiledVFrame; |
106 | |
107 | private: |
108 | |
109 | Method* _method; |
110 | int _bci; |
111 | intptr_t* _id; |
112 | int _vframe_id; |
113 | GrowableArray<jvmtiDeferredLocalVariable*>* _locals; |
114 | |
115 | void update_value(StackValueCollection* locals, BasicType type, int index, jvalue value); |
116 | |
117 | void set_value_at(int idx, BasicType typ, jvalue val); |
118 | |
119 | public: |
120 | // JVM state |
121 | Method* method() const { return _method; } |
122 | int bci() const { return _bci; } |
123 | intptr_t* id() const { return _id; } |
124 | int vframe_id() const { return _vframe_id; } |
125 | |
126 | void update_locals(StackValueCollection* locals); |
127 | void update_stack(StackValueCollection* locals); |
128 | void update_monitors(GrowableArray<MonitorInfo*>* monitors); |
129 | |
130 | // Does the vframe match this jvmtiDeferredLocalVariableSet |
131 | bool matches(const vframe* vf); |
132 | // GC |
133 | void oops_do(OopClosure* f); |
134 | |
135 | // constructor |
136 | jvmtiDeferredLocalVariableSet(Method* method, int bci, intptr_t* id, int vframe_id); |
137 | |
138 | // destructor |
139 | ~jvmtiDeferredLocalVariableSet(); |
140 | |
141 | |
142 | }; |
143 | |
144 | class jvmtiDeferredLocalVariable : public CHeapObj<mtCompiler> { |
145 | public: |
146 | |
147 | jvmtiDeferredLocalVariable(int index, BasicType type, jvalue value); |
148 | |
149 | BasicType type(void) { return _type; } |
150 | int index(void) { return _index; } |
151 | jvalue value(void) { return _value; } |
152 | // Only mutator is for value as only it can change |
153 | void set_value(jvalue value) { _value = value; } |
154 | // For gc |
155 | oop* oop_addr(void) { return (oop*) &_value.l; } |
156 | |
157 | private: |
158 | |
159 | BasicType _type; |
160 | jvalue _value; |
161 | int _index; |
162 | |
163 | }; |
164 | |
165 | #endif // SHARE_RUNTIME_VFRAME_HP_HPP |
166 | |