author | rehn |
Thu, 31 Aug 2017 10:00:28 +0200 | |
changeset 47881 | 0ce0ac68ace7 |
parent 47216 | 71c04702a3d5 |
child 47916 | bdbef8638948 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
47881
0ce0ac68ace7
8189941: Implementation JEP 312: Thread-local handshake
rehn
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4429
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4429
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4429
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#ifndef SHARE_VM_INTERPRETER_TEMPLATEINTERPRETER_HPP |
26 |
#define SHARE_VM_INTERPRETER_TEMPLATEINTERPRETER_HPP |
|
27 |
||
28 |
#include "interpreter/abstractInterpreter.hpp" |
|
29 |
#include "interpreter/templateTable.hpp" |
|
30 |
||
2131 | 31 |
// This file contains the platform-independent parts |
1 | 32 |
// of the template interpreter and the template interpreter generator. |
33 |
||
34 |
#ifndef CC_INTERP |
|
35 |
||
25715
d5a8dbdc5150
8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents:
22234
diff
changeset
|
36 |
class InterpreterMacroAssembler; |
35214 | 37 |
class InterpreterCodelet; |
25715
d5a8dbdc5150
8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents:
22234
diff
changeset
|
38 |
|
1 | 39 |
//------------------------------------------------------------------------------------------------------------------------ |
40 |
// A little wrapper class to group tosca-specific entry points into a unit. |
|
41 |
// (tosca = Top-Of-Stack CAche) |
|
42 |
||
43 |
class EntryPoint VALUE_OBJ_CLASS_SPEC { |
|
44 |
private: |
|
45 |
address _entry[number_of_states]; |
|
46 |
||
47 |
public: |
|
48 |
// Construction |
|
49 |
EntryPoint(); |
|
37480 | 50 |
EntryPoint(address bentry, address zentry, address centry, address sentry, address aentry, address ientry, address lentry, address fentry, address dentry, address ventry); |
1 | 51 |
|
52 |
// Attributes |
|
53 |
address entry(TosState state) const; // return target address for a given tosca state |
|
54 |
void set_entry(TosState state, address entry); // set target address for a given tosca state |
|
55 |
void print(); |
|
56 |
||
57 |
// Comparison |
|
58 |
bool operator == (const EntryPoint& y); // for debugging only |
|
59 |
}; |
|
60 |
||
61 |
||
62 |
//------------------------------------------------------------------------------------------------------------------------ |
|
63 |
// A little wrapper class to group tosca-specific dispatch tables into a unit. |
|
64 |
||
65 |
class DispatchTable VALUE_OBJ_CLASS_SPEC { |
|
66 |
public: |
|
67 |
enum { length = 1 << BitsPerByte }; // an entry point for each byte value (also for undefined bytecodes) |
|
68 |
||
69 |
private: |
|
70 |
address _table[number_of_states][length]; // dispatch tables, indexed by tosca and bytecode |
|
71 |
||
72 |
public: |
|
73 |
// Attributes |
|
74 |
EntryPoint entry(int i) const; // return entry point for a given bytecode i |
|
75 |
void set_entry(int i, EntryPoint& entry); // set entry point for a given bytecode i |
|
76 |
address* table_for(TosState state) { return _table[state]; } |
|
77 |
address* table_for() { return table_for((TosState)0); } |
|
78 |
int distance_from(address *table) { return table - table_for(); } |
|
79 |
int distance_from(TosState state) { return distance_from(table_for(state)); } |
|
80 |
||
81 |
// Comparison |
|
82 |
bool operator == (DispatchTable& y); // for debugging only |
|
83 |
}; |
|
84 |
||
85 |
class TemplateInterpreter: public AbstractInterpreter { |
|
86 |
friend class VMStructs; |
|
87 |
friend class InterpreterMacroAssembler; |
|
88 |
friend class TemplateInterpreterGenerator; |
|
89 |
friend class TemplateTable; |
|
31620
53be635ad49c
8087333: Optionally Pre-Generate the HotSpot Template Interpreter
bdelsart
parents:
31389
diff
changeset
|
90 |
friend class CodeCacheExtensions; |
1 | 91 |
// friend class Interpreter; |
92 |
public: |
|
93 |
||
94 |
enum MoreConstants { |
|
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
95 |
number_of_return_entries = number_of_states, // number of return entry points |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
96 |
number_of_deopt_entries = number_of_states, // number of deoptimization entry points |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
97 |
number_of_return_addrs = number_of_states // number of return addresses |
1 | 98 |
}; |
99 |
||
100 |
protected: |
|
101 |
||
102 |
static address _throw_ArrayIndexOutOfBoundsException_entry; |
|
103 |
static address _throw_ArrayStoreException_entry; |
|
104 |
static address _throw_ArithmeticException_entry; |
|
105 |
static address _throw_ClassCastException_entry; |
|
106 |
static address _throw_NullPointerException_entry; |
|
107 |
static address _throw_exception_entry; |
|
108 |
||
109 |
static address _throw_StackOverflowError_entry; |
|
110 |
||
111 |
static address _remove_activation_entry; // continuation address if an exception is not handled by current frame |
|
112 |
#ifdef HOTSWAP |
|
113 |
static address _remove_activation_preserving_args_entry; // continuation address when current frame is being popped |
|
114 |
#endif // HOTSWAP |
|
115 |
||
116 |
#ifndef PRODUCT |
|
117 |
static EntryPoint _trace_code; |
|
118 |
#endif // !PRODUCT |
|
119 |
static EntryPoint _return_entry[number_of_return_entries]; // entry points to return to from a call |
|
120 |
static EntryPoint _earlyret_entry; // entry point to return early from a call |
|
121 |
static EntryPoint _deopt_entry[number_of_deopt_entries]; // entry points to return to from a deoptimization |
|
122 |
static EntryPoint _safept_entry; |
|
123 |
||
21198
dd647e8d1d72
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
13728
diff
changeset
|
124 |
static address _invoke_return_entry[number_of_return_addrs]; // for invokestatic, invokespecial, invokevirtual return entries |
dd647e8d1d72
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
13728
diff
changeset
|
125 |
static address _invokeinterface_return_entry[number_of_return_addrs]; // for invokeinterface return entries |
dd647e8d1d72
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
13728
diff
changeset
|
126 |
static address _invokedynamic_return_entry[number_of_return_addrs]; // for invokedynamic return entries |
1 | 127 |
|
128 |
static DispatchTable _active_table; // the active dispatch table (used by the interpreter for dispatch) |
|
129 |
static DispatchTable _normal_table; // the normal dispatch table (used to set the active table in normal mode) |
|
130 |
static DispatchTable _safept_table; // the safepoint dispatch table (used to set the active table for safepoints) |
|
131 |
static address _wentry_point[DispatchTable::length]; // wide instructions only (vtos tosca always) |
|
132 |
||
133 |
||
134 |
public: |
|
135 |
// Initialization/debugging |
|
136 |
static void initialize(); |
|
137 |
// this only returns whether a pc is within generated code for the interpreter. |
|
138 |
static bool contains(address pc) { return _code != NULL && _code->contains(pc); } |
|
35214 | 139 |
// Debugging/printing |
140 |
static InterpreterCodelet* codelet_containing(address pc); |
|
141 |
||
1 | 142 |
|
143 |
public: |
|
144 |
||
145 |
static address remove_activation_early_entry(TosState state) { return _earlyret_entry.entry(state); } |
|
146 |
#ifdef HOTSWAP |
|
147 |
static address remove_activation_preserving_args_entry() { return _remove_activation_preserving_args_entry; } |
|
148 |
#endif // HOTSWAP |
|
149 |
||
150 |
static address remove_activation_entry() { return _remove_activation_entry; } |
|
151 |
static address throw_exception_entry() { return _throw_exception_entry; } |
|
152 |
static address throw_ArithmeticException_entry() { return _throw_ArithmeticException_entry; } |
|
153 |
static address throw_NullPointerException_entry() { return _throw_NullPointerException_entry; } |
|
154 |
static address throw_StackOverflowError_entry() { return _throw_StackOverflowError_entry; } |
|
155 |
||
156 |
// Code generation |
|
157 |
#ifndef PRODUCT |
|
158 |
static address trace_code (TosState state) { return _trace_code.entry(state); } |
|
159 |
#endif // !PRODUCT |
|
160 |
static address* dispatch_table(TosState state) { return _active_table.table_for(state); } |
|
161 |
static address* dispatch_table() { return _active_table.table_for(); } |
|
162 |
static int distance_from_dispatch_table(TosState state){ return _active_table.distance_from(state); } |
|
163 |
static address* normal_table(TosState state) { return _normal_table.table_for(state); } |
|
164 |
static address* normal_table() { return _normal_table.table_for(); } |
|
47881
0ce0ac68ace7
8189941: Implementation JEP 312: Thread-local handshake
rehn
parents:
47216
diff
changeset
|
165 |
static address* safept_table(TosState state) { return _safept_table.table_for(state); } |
1 | 166 |
|
167 |
// Support for invokes |
|
21198
dd647e8d1d72
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
13728
diff
changeset
|
168 |
static address* invoke_return_entry_table() { return _invoke_return_entry; } |
dd647e8d1d72
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
13728
diff
changeset
|
169 |
static address* invokeinterface_return_entry_table() { return _invokeinterface_return_entry; } |
dd647e8d1d72
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
13728
diff
changeset
|
170 |
static address* invokedynamic_return_entry_table() { return _invokedynamic_return_entry; } |
dd647e8d1d72
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
13728
diff
changeset
|
171 |
static int TosState_as_index(TosState state); |
1 | 172 |
|
21198
dd647e8d1d72
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
13728
diff
changeset
|
173 |
static address* invoke_return_entry_table_for(Bytecodes::Code code); |
dd647e8d1d72
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
13728
diff
changeset
|
174 |
|
dd647e8d1d72
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
13728
diff
changeset
|
175 |
static address deopt_entry(TosState state, int length); |
dd647e8d1d72
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
13728
diff
changeset
|
176 |
static address return_entry(TosState state, int length, Bytecodes::Code code); |
1 | 177 |
|
178 |
// Safepoint support |
|
179 |
static void notice_safepoints(); // stops the thread when reaching a safepoint |
|
180 |
static void ignore_safepoints(); // ignores safepoints |
|
181 |
||
182 |
// Deoptimization support |
|
3600
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
2570
diff
changeset
|
183 |
// Compute the entry address for continuation after |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
184 |
static address deopt_continue_after_entry(Method* method, |
3600
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
2570
diff
changeset
|
185 |
address bcp, |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
2570
diff
changeset
|
186 |
int callee_parameters, |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
2570
diff
changeset
|
187 |
bool is_top_frame); |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
2570
diff
changeset
|
188 |
// Deoptimization should reexecute this bytecode |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
2570
diff
changeset
|
189 |
static bool bytecode_should_reexecute(Bytecodes::Code code); |
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
2570
diff
changeset
|
190 |
// Compute the address for reexecution |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
191 |
static address deopt_reexecute_entry(Method* method, address bcp); |
1 | 192 |
|
35214 | 193 |
// Size of interpreter code. Max size with JVMTI |
194 |
static int InterpreterCodeSize; |
|
1 | 195 |
}; |
196 |
||
197 |
#endif // !CC_INTERP |
|
7397 | 198 |
|
199 |
#endif // SHARE_VM_INTERPRETER_TEMPLATEINTERPRETER_HPP |