duke@1
|
1 /*
|
coleenp@54304
|
2 * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
|
duke@1
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
duke@1
|
4 *
|
duke@1
|
5 * This code is free software; you can redistribute it and/or modify it
|
duke@1
|
6 * under the terms of the GNU General Public License version 2 only, as
|
duke@1
|
7 * published by the Free Software Foundation.
|
duke@1
|
8 *
|
duke@1
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT
|
duke@1
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
duke@1
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
duke@1
|
12 * version 2 for more details (a copy is included in the LICENSE file that
|
duke@1
|
13 * accompanied this code).
|
duke@1
|
14 *
|
duke@1
|
15 * You should have received a copy of the GNU General Public License version
|
duke@1
|
16 * 2 along with this work; if not, write to the Free Software Foundation,
|
duke@1
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
duke@1
|
18 *
|
trims@5547
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
trims@5547
|
20 * or visit www.oracle.com if you need additional information or have any
|
trims@5547
|
21 * questions.
|
duke@1
|
22 *
|
duke@1
|
23 */
|
duke@1
|
24
|
coleenp@54304
|
25 #ifndef SHARE_INTERPRETER_INTERPRETERRUNTIME_HPP
|
coleenp@54304
|
26 #define SHARE_INTERPRETER_INTERPRETERRUNTIME_HPP
|
stefank@7397
|
27
|
stefank@7397
|
28 #include "interpreter/bytecode.hpp"
|
stefank@7397
|
29 #include "interpreter/linkResolver.hpp"
|
stefank@7397
|
30 #include "memory/universe.hpp"
|
coleenp@13728
|
31 #include "oops/method.hpp"
|
coleenp@49945
|
32 #include "runtime/frame.hpp"
|
stefank@7397
|
33 #include "runtime/signature.hpp"
|
stefank@37456
|
34 #include "runtime/thread.hpp"
|
goetz@40010
|
35 #include "utilities/macros.hpp"
|
stefank@7397
|
36
|
duke@1
|
37 // The InterpreterRuntime is called by the interpreter for everything
|
duke@1
|
38 // that cannot/should not be dealt with in assembly and needs C support.
|
duke@1
|
39
|
duke@1
|
40 class InterpreterRuntime: AllStatic {
|
duke@1
|
41 friend class BytecodeClosure; // for method and bcp
|
duke@1
|
42 friend class PrintingClosure; // for method and bcp
|
duke@1
|
43
|
duke@1
|
44 private:
|
iklam@47951
|
45
|
iklam@46430
|
46 static void set_bcp_and_mdp(address bcp, JavaThread*thread);
|
goetz@22836
|
47 static void note_trap_inner(JavaThread* thread, int reason,
|
coleenp@46727
|
48 const methodHandle& trap_method, int trap_bci, TRAPS);
|
duke@1
|
49 static void note_trap(JavaThread *thread, int reason, TRAPS);
|
goetz@22836
|
50 #ifdef CC_INTERP
|
goetz@22836
|
51 // Profile traps in C++ interpreter.
|
goetz@22836
|
52 static void note_trap(JavaThread* thread, int reason, Method *method, int trap_bci);
|
goetz@22836
|
53 #endif // CC_INTERP
|
duke@1
|
54
|
goetz@22836
|
55 // Inner work method for Interpreter's frequency counter overflow.
|
ysr@3696
|
56 static nmethod* frequency_counter_overflow_inner(JavaThread* thread, address branch_bcp);
|
ysr@3696
|
57
|
duke@1
|
58 public:
|
duke@1
|
59 // Constants
|
duke@1
|
60 static void ldc (JavaThread* thread, bool wide);
|
jrose@5882
|
61 static void resolve_ldc (JavaThread* thread, Bytecodes::Code bytecode);
|
duke@1
|
62
|
duke@1
|
63 // Allocation
|
coleenp@13728
|
64 static void _new (JavaThread* thread, ConstantPool* pool, int index);
|
duke@1
|
65 static void newarray (JavaThread* thread, BasicType type, jint size);
|
coleenp@13728
|
66 static void anewarray (JavaThread* thread, ConstantPool* pool, int index, jint size);
|
duke@1
|
67 static void multianewarray(JavaThread* thread, jint* first_size_address);
|
duke@1
|
68 static void register_finalizer(JavaThread* thread, oopDesc* obj);
|
duke@1
|
69
|
duke@1
|
70 // Quicken instance-of and check-cast bytecodes
|
duke@1
|
71 static void quicken_io_cc(JavaThread* thread);
|
duke@1
|
72
|
duke@1
|
73 // Exceptions thrown by the interpreter
|
duke@1
|
74 static void throw_AbstractMethodError(JavaThread* thread);
|
goetz@49833
|
75 static void throw_AbstractMethodErrorWithMethod(JavaThread* thread, Method* oop);
|
goetz@49833
|
76 static void throw_AbstractMethodErrorVerbose(JavaThread* thread,
|
goetz@49833
|
77 Klass* recvKlass,
|
goetz@49833
|
78 Method* missingMethod);
|
goetz@49833
|
79
|
duke@1
|
80 static void throw_IncompatibleClassChangeError(JavaThread* thread);
|
goetz@49833
|
81 static void throw_IncompatibleClassChangeErrorVerbose(JavaThread* thread,
|
goetz@49833
|
82 Klass* resc,
|
goetz@49833
|
83 Klass* interfaceKlass);
|
duke@1
|
84 static void throw_StackOverflowError(JavaThread* thread);
|
fparain@35071
|
85 static void throw_delayed_StackOverflowError(JavaThread* thread);
|
goetz@50643
|
86 static void throw_ArrayIndexOutOfBoundsException(JavaThread* thread, arrayOopDesc* a, jint index);
|
duke@1
|
87 static void throw_ClassCastException(JavaThread* thread, oopDesc* obj);
|
duke@1
|
88 static void create_exception(JavaThread* thread, char* name, char* message);
|
duke@1
|
89 static void create_klass_exception(JavaThread* thread, char* name, oopDesc* obj);
|
duke@1
|
90 static address exception_handler_for_exception(JavaThread* thread, oopDesc* exception);
|
sspitsyn@19266
|
91 #if INCLUDE_JVMTI
|
sspitsyn@19266
|
92 static void member_name_arg_or_null(JavaThread* thread, address dmh, Method* m, address bcp);
|
sspitsyn@19266
|
93 #endif
|
duke@1
|
94 static void throw_pending_exception(JavaThread* thread);
|
duke@1
|
95
|
goetz@22836
|
96 #ifdef CC_INTERP
|
goetz@22836
|
97 // Profile traps in C++ interpreter.
|
goetz@22836
|
98 static void note_nullCheck_trap (JavaThread* thread, Method *method, int trap_bci);
|
goetz@22836
|
99 static void note_div0Check_trap (JavaThread* thread, Method *method, int trap_bci);
|
goetz@22836
|
100 static void note_rangeCheck_trap(JavaThread* thread, Method *method, int trap_bci);
|
goetz@22836
|
101 static void note_classCheck_trap(JavaThread* thread, Method *method, int trap_bci);
|
goetz@22836
|
102 static void note_arrayCheck_trap(JavaThread* thread, Method *method, int trap_bci);
|
coleenp@35214
|
103 // A dummy for macros that shall not profile traps.
|
goetz@22836
|
104 static void note_no_trap(JavaThread* thread, Method *method, int trap_bci) {}
|
goetz@22836
|
105 #endif // CC_INTERP
|
goetz@22836
|
106
|
coleenp@30132
|
107 static void resolve_from_cache(JavaThread* thread, Bytecodes::Code bytecode);
|
coleenp@30132
|
108 private:
|
duke@1
|
109 // Statics & fields
|
coleenp@30132
|
110 static void resolve_get_put(JavaThread* thread, Bytecodes::Code bytecode);
|
duke@1
|
111
|
coleenp@30132
|
112 // Calls
|
coleenp@30132
|
113 static void resolve_invoke(JavaThread* thread, Bytecodes::Code bytecode);
|
coleenp@30132
|
114 static void resolve_invokehandle (JavaThread* thread);
|
coleenp@30132
|
115 static void resolve_invokedynamic(JavaThread* thread);
|
coleenp@30132
|
116
|
coleenp@30132
|
117 public:
|
duke@1
|
118 // Synchronization
|
duke@1
|
119 static void monitorenter(JavaThread* thread, BasicObjectLock* elem);
|
duke@1
|
120 static void monitorexit (JavaThread* thread, BasicObjectLock* elem);
|
duke@1
|
121
|
duke@1
|
122 static void throw_illegal_monitor_state_exception(JavaThread* thread);
|
duke@1
|
123 static void new_illegal_monitor_state_exception(JavaThread* thread);
|
duke@1
|
124
|
duke@1
|
125 // Breakpoints
|
coleenp@13728
|
126 static void _breakpoint(JavaThread* thread, Method* method, address bcp);
|
coleenp@13728
|
127 static Bytecodes::Code get_original_bytecode_at(JavaThread* thread, Method* method, address bcp);
|
coleenp@13728
|
128 static void set_original_bytecode_at(JavaThread* thread, Method* method, address bcp, Bytecodes::Code new_code);
|
coleenp@49945
|
129 static bool is_breakpoint(JavaThread *thread);
|
duke@1
|
130
|
duke@1
|
131 // Safepoints
|
duke@1
|
132 static void at_safepoint(JavaThread* thread);
|
duke@1
|
133
|
duke@1
|
134 // Debugger support
|
duke@1
|
135 static void post_field_access(JavaThread *thread, oopDesc* obj,
|
duke@1
|
136 ConstantPoolCacheEntry *cp_entry);
|
duke@1
|
137 static void post_field_modification(JavaThread *thread, oopDesc* obj,
|
duke@1
|
138 ConstantPoolCacheEntry *cp_entry, jvalue *value);
|
duke@1
|
139 static void post_method_entry(JavaThread *thread);
|
duke@1
|
140 static void post_method_exit (JavaThread *thread);
|
duke@1
|
141 static int interpreter_contains(address pc);
|
duke@1
|
142
|
duke@1
|
143 // Native signature handlers
|
coleenp@13728
|
144 static void prepare_native_call(JavaThread* thread, Method* method);
|
duke@1
|
145 static address slow_signature_handler(JavaThread* thread,
|
coleenp@13728
|
146 Method* method,
|
duke@1
|
147 intptr_t* from, intptr_t* to);
|
duke@1
|
148
|
roland@10520
|
149 #if defined(IA32) || defined(AMD64) || defined(ARM)
|
roland@10520
|
150 // Popframe support (only needed on x86, AMD64 and ARM)
|
duke@1
|
151 static void popframe_move_outgoing_args(JavaThread* thread, void* src_address, void* dest_address);
|
duke@1
|
152 #endif
|
duke@1
|
153
|
coleenp@37152
|
154 // bytecode tracing is only used by the TraceBytecodes
|
coleenp@37152
|
155 static intptr_t trace_bytecode(JavaThread* thread, intptr_t preserve_this_value, intptr_t tos, intptr_t tos2) PRODUCT_RETURN0;
|
coleenp@37152
|
156
|
duke@1
|
157 // Platform dependent stuff
|
goetz@40010
|
158 #include CPU_HEADER(interpreterRT)
|
stefank@7397
|
159
|
bdelsart@31382
|
160 // optional normalization of fingerprints to reduce the number of adapters
|
bdelsart@31382
|
161 static uint64_t normalize_fast_native_fingerprint(uint64_t fingerprint);
|
duke@1
|
162
|
duke@1
|
163 // Interpreter's frequency counter overflow
|
duke@1
|
164 static nmethod* frequency_counter_overflow(JavaThread* thread, address branch_bcp);
|
duke@1
|
165
|
duke@1
|
166 // Interpreter profiling support
|
coleenp@13728
|
167 static jint bcp_to_di(Method* method, address cur_bcp);
|
iveresov@7889
|
168 static void profile_method(JavaThread* thread);
|
duke@1
|
169 static void update_mdp_for_ret(JavaThread* thread, int bci);
|
duke@1
|
170 #ifdef ASSERT
|
coleenp@13728
|
171 static void verify_mdp(Method* method, address bcp, address mdp);
|
duke@1
|
172 #endif // ASSERT
|
jiangli@17000
|
173 static MethodCounters* build_method_counters(JavaThread* thread, Method* m);
|
duke@1
|
174 };
|
duke@1
|
175
|
duke@1
|
176
|
duke@1
|
177 class SignatureHandlerLibrary: public AllStatic {
|
duke@1
|
178 public:
|
duke@1
|
179 enum { buffer_size = 1*K }; // the size of the temporary code buffer
|
duke@1
|
180 enum { blob_size = 32*K }; // the size of a handler code blob.
|
duke@1
|
181
|
duke@1
|
182 private:
|
duke@1
|
183 static BufferBlob* _handler_blob; // the current buffer blob containing the generated handlers
|
duke@1
|
184 static address _handler; // next available address within _handler_blob;
|
duke@1
|
185 static GrowableArray<uint64_t>* _fingerprints; // the fingerprint collection
|
duke@1
|
186 static GrowableArray<address>* _handlers; // the corresponding handlers
|
duke@1
|
187 static address _buffer; // the temporary code buffer
|
duke@1
|
188
|
duke@1
|
189 static address set_handler_blob();
|
duke@1
|
190 static void initialize();
|
duke@1
|
191 static address set_handler(CodeBuffer* buffer);
|
duke@1
|
192 static void pd_set_handler(address handler);
|
duke@1
|
193
|
duke@1
|
194 public:
|
coleenp@33593
|
195 static void add(const methodHandle& method);
|
bdelsart@31620
|
196 static void add(uint64_t fingerprint, address handler);
|
duke@1
|
197 };
|
stefank@7397
|
198
|
coleenp@54304
|
199 #endif // SHARE_INTERPRETER_INTERPRETERRUNTIME_HPP
|