Sat, 07 Nov 2020 10:30:02 +0800
Added tag mips-jdk8u275-b01 for changeset d3b4d62f391f
1 /*
2 * Copyright (c) 1997, 2015, 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 */
25 /*
26 * This file has been modified by Loongson Technology in 2015. These
27 * modifications are Copyright (c) 2015 Loongson Technology, and are made
28 * available on the same license terms set forth above.
29 */
31 #ifndef SHARE_VM_INTERPRETER_TEMPLATETABLE_HPP
32 #define SHARE_VM_INTERPRETER_TEMPLATETABLE_HPP
34 #include "interpreter/bytecodes.hpp"
35 #include "memory/allocation.hpp"
36 #include "runtime/frame.hpp"
37 #if defined INTERP_MASM_MD_HPP
38 # include INTERP_MASM_MD_HPP
39 #elif defined TARGET_ARCH_x86
40 # include "interp_masm_x86.hpp"
41 #elif defined TARGET_ARCH_MODEL_sparc
42 # include "interp_masm_sparc.hpp"
43 #elif defined TARGET_ARCH_MODEL_zero
44 # include "interp_masm_zero.hpp"
45 #elif defined TARGET_ARCH_MODEL_ppc_64
46 # include "interp_masm_ppc_64.hpp"
47 #elif defined TARGET_ARCH_MODEL_mips_64
48 # include "interp_masm_mips_64.hpp"
49 #endif
51 #ifndef CC_INTERP
52 // All the necessary definitions used for (bytecode) template generation. Instead of
53 // spreading the implementation functionality for each bytecode in the interpreter
54 // and the snippet generator, a template is assigned to each bytecode which can be
55 // used to generate the bytecode's implementation if needed.
58 // A Template describes the properties of a code template for a given bytecode
59 // and provides a generator to generate the code template.
61 class Template VALUE_OBJ_CLASS_SPEC {
62 private:
63 enum Flags {
64 uses_bcp_bit, // set if template needs the bcp pointing to bytecode
65 does_dispatch_bit, // set if template dispatches on its own
66 calls_vm_bit, // set if template calls the vm
67 wide_bit // set if template belongs to a wide instruction
68 };
70 typedef void (*generator)(int arg);
72 int _flags; // describes interpreter template properties (bcp unknown)
73 TosState _tos_in; // tos cache state before template execution
74 TosState _tos_out; // tos cache state after template execution
75 generator _gen; // template code generator
76 int _arg; // argument for template code generator
78 void initialize(int flags, TosState tos_in, TosState tos_out, generator gen, int arg);
80 friend class TemplateTable;
82 public:
83 Bytecodes::Code bytecode() const;
84 bool is_valid() const { return _gen != NULL; }
85 bool uses_bcp() const { return (_flags & (1 << uses_bcp_bit )) != 0; }
86 bool does_dispatch() const { return (_flags & (1 << does_dispatch_bit)) != 0; }
87 bool calls_vm() const { return (_flags & (1 << calls_vm_bit )) != 0; }
88 bool is_wide() const { return (_flags & (1 << wide_bit )) != 0; }
89 TosState tos_in() const { return _tos_in; }
90 TosState tos_out() const { return _tos_out; }
91 void generate(InterpreterMacroAssembler* masm);
92 };
95 // The TemplateTable defines all Templates and provides accessor functions
96 // to get the template for a given bytecode.
98 class TemplateTable: AllStatic {
99 public:
100 enum Operation { add, sub, mul, div, rem, _and, _or, _xor, shl, shr, ushr };
101 enum Condition { equal, not_equal, less, less_equal, greater, greater_equal };
102 enum CacheByte { f1_byte = 1, f2_byte = 2 }; // byte_no codes
104 private:
105 static bool _is_initialized; // true if TemplateTable has been initialized
106 static Template _template_table [Bytecodes::number_of_codes];
107 static Template _template_table_wide[Bytecodes::number_of_codes];
109 static Template* _desc; // the current template to be generated
110 static Bytecodes::Code bytecode() { return _desc->bytecode(); }
112 static BarrierSet* _bs; // Cache the barrier set.
113 public:
114 //%note templates_1
115 static InterpreterMacroAssembler* _masm; // the assembler used when generating templates
117 private:
119 // special registers
120 static inline Address at_bcp(int offset);
122 // helpers
123 static void unimplemented_bc();
124 static void patch_bytecode(Bytecodes::Code bc, Register bc_reg,
125 Register temp_reg, bool load_bc_into_bc_reg = true, int byte_no = -1);
127 // C calls
128 static void call_VM(Register oop_result, address entry_point);
129 static void call_VM(Register oop_result, address entry_point, Register arg_1);
130 static void call_VM(Register oop_result, address entry_point, Register arg_1, Register arg_2);
131 static void call_VM(Register oop_result, address entry_point, Register arg_1, Register arg_2, Register arg_3);
133 // these overloadings are not presently used on SPARC:
134 static void call_VM(Register oop_result, Register last_java_sp, address entry_point);
135 static void call_VM(Register oop_result, Register last_java_sp, address entry_point, Register arg_1);
136 static void call_VM(Register oop_result, Register last_java_sp, address entry_point, Register arg_1, Register arg_2);
137 static void call_VM(Register oop_result, Register last_java_sp, address entry_point, Register arg_1, Register arg_2, Register arg_3);
139 // bytecodes
140 static void nop();
142 static void aconst_null();
143 static void iconst(int value);
144 static void lconst(int value);
145 static void fconst(int value);
146 static void dconst(int value);
148 static void bipush();
149 static void sipush();
150 static void ldc(bool wide);
151 static void ldc2_w();
152 static void fast_aldc(bool wide);
154 static void locals_index(Register reg, int offset = 1);
155 static void iload();
156 static void fast_iload();
157 static void fast_iload2();
158 static void fast_icaload();
159 static void lload();
160 static void fload();
161 static void dload();
162 static void aload();
164 static void locals_index_wide(Register reg);
165 static void wide_iload();
166 static void wide_lload();
167 static void wide_fload();
168 static void wide_dload();
169 static void wide_aload();
171 static void iaload();
172 static void laload();
173 static void faload();
174 static void daload();
175 static void aaload();
176 static void baload();
177 static void caload();
178 static void saload();
180 static void iload(int n);
181 static void lload(int n);
182 static void fload(int n);
183 static void dload(int n);
184 static void aload(int n);
185 static void aload_0();
187 static void istore();
188 static void lstore();
189 static void fstore();
190 static void dstore();
191 static void astore();
193 static void wide_istore();
194 static void wide_lstore();
195 static void wide_fstore();
196 static void wide_dstore();
197 static void wide_astore();
199 static void iastore();
200 static void lastore();
201 static void fastore();
202 static void dastore();
203 static void aastore();
204 static void bastore();
205 static void castore();
206 static void sastore();
208 static void istore(int n);
209 static void lstore(int n);
210 static void fstore(int n);
211 static void dstore(int n);
212 static void astore(int n);
214 static void pop();
215 static void pop2();
216 static void dup();
217 static void dup_x1();
218 static void dup_x2();
219 static void dup2();
220 static void dup2_x1();
221 static void dup2_x2();
222 static void swap();
224 static void iop2(Operation op);
225 static void lop2(Operation op);
226 static void fop2(Operation op);
227 static void dop2(Operation op);
229 static void idiv();
230 static void irem();
232 static void lmul();
233 static void ldiv();
234 static void lrem();
235 static void lshl();
236 static void lshr();
237 static void lushr();
239 static void ineg();
240 static void lneg();
241 static void fneg();
242 static void dneg();
244 static void iinc();
245 static void wide_iinc();
246 static void convert();
247 static void lcmp();
249 static void float_cmp (bool is_float, int unordered_result);
250 static void float_cmp (int unordered_result);
251 static void double_cmp(int unordered_result);
253 static void count_calls(Register method, Register temp);
254 static void branch(bool is_jsr, bool is_wide);
255 static void if_0cmp (Condition cc);
256 static void if_icmp (Condition cc);
257 static void if_nullcmp(Condition cc);
258 static void if_acmp (Condition cc);
260 static void _goto();
261 static void jsr();
262 static void ret();
263 static void wide_ret();
265 static void goto_w();
266 static void jsr_w();
268 static void tableswitch();
269 static void lookupswitch();
270 static void fast_linearswitch();
271 static void fast_binaryswitch();
273 static void _return(TosState state);
275 static void resolve_cache_and_index(int byte_no, // one of 1,2,11
276 Register cache, // output for CP cache
277 Register index, // output for CP index
278 size_t index_size); // one of 1,2,4
279 static void load_invoke_cp_cache_entry(int byte_no,
280 Register method,
281 Register itable_index,
282 Register flags,
283 bool is_invokevirtual,
284 bool is_virtual_final,
285 bool is_invokedynamic);
286 static void load_field_cp_cache_entry(Register obj,
287 Register cache,
288 Register index,
289 Register offset,
290 Register flags,
291 bool is_static);
292 static void invokevirtual(int byte_no);
293 static void invokespecial(int byte_no);
294 static void invokestatic(int byte_no);
295 static void invokeinterface(int byte_no);
296 static void invokedynamic(int byte_no);
297 static void invokehandle(int byte_no);
298 static void fast_invokevfinal(int byte_no);
300 static void getfield_or_static(int byte_no, bool is_static);
301 static void putfield_or_static(int byte_no, bool is_static);
302 static void getfield(int byte_no);
303 static void putfield(int byte_no);
304 static void getstatic(int byte_no);
305 static void putstatic(int byte_no);
306 static void pop_and_check_object(Register obj);
308 static void _new();
309 static void newarray();
310 static void anewarray();
311 static void arraylength();
312 static void checkcast();
313 static void instanceof();
315 static void athrow();
317 static void monitorenter();
318 static void monitorexit();
320 static void wide();
321 static void multianewarray();
323 static void fast_xaccess(TosState state);
324 static void fast_accessfield(TosState state);
325 static void fast_storefield(TosState state);
327 static void _breakpoint();
329 static void shouldnotreachhere();
331 // jvmti support
332 static void jvmti_post_field_access(Register cache, Register index, bool is_static, bool has_tos);
333 static void jvmti_post_field_mod(Register cache, Register index, bool is_static);
334 static void jvmti_post_fast_field_mod();
336 // debugging of TemplateGenerator
337 static void transition(TosState tos_in, TosState tos_out);// checks if in/out states expected by template generator correspond to table entries
339 // initialization helpers
340 static void def(Bytecodes::Code code, int flags, TosState in, TosState out, void (*gen)( ), char filler );
341 static void def(Bytecodes::Code code, int flags, TosState in, TosState out, void (*gen)(int arg ), int arg );
342 static void def(Bytecodes::Code code, int flags, TosState in, TosState out, void (*gen)(bool arg ), bool arg );
343 static void def(Bytecodes::Code code, int flags, TosState in, TosState out, void (*gen)(TosState tos), TosState tos);
344 static void def(Bytecodes::Code code, int flags, TosState in, TosState out, void (*gen)(Operation op), Operation op);
345 static void def(Bytecodes::Code code, int flags, TosState in, TosState out, void (*gen)(Condition cc), Condition cc);
347 friend class Template;
349 // InterpreterMacroAssembler::is_a(), etc., need TemplateTable::call_VM().
350 friend class InterpreterMacroAssembler;
352 public:
353 // Initialization
354 static void initialize();
355 static void pd_initialize();
357 // Templates
358 static Template* template_for (Bytecodes::Code code) { Bytecodes::check (code); return &_template_table [code]; }
359 static Template* template_for_wide(Bytecodes::Code code) { Bytecodes::wide_check(code); return &_template_table_wide[code]; }
361 // Platform specifics
362 #if defined TEMPLATETABLE_MD_HPP
363 # include TEMPLATETABLE_MD_HPP
364 #elif defined TARGET_ARCH_MODEL_x86_32
365 # include "templateTable_x86_32.hpp"
366 #elif defined TARGET_ARCH_MODEL_x86_64
367 # include "templateTable_x86_64.hpp"
368 #elif defined TARGET_ARCH_MODEL_sparc
369 # include "templateTable_sparc.hpp"
370 #elif defined TARGET_ARCH_MODEL_zero
371 # include "templateTable_zero.hpp"
372 #elif defined TARGET_ARCH_MODEL_ppc_64
373 # include "templateTable_ppc_64.hpp"
374 #elif defined TARGET_ARCH_MODEL_mips_64
375 # include "templateTable_mips_64.hpp"
376 #endif
378 };
379 #endif /* !CC_INTERP */
381 #endif // SHARE_VM_INTERPRETER_TEMPLATETABLE_HPP