src/share/vm/interpreter/templateTable.hpp

Sat, 07 Nov 2020 10:30:02 +0800

author
aoqi
date
Sat, 07 Nov 2020 10:30:02 +0800
changeset 10026
8c95980d0b66
parent 7994
04ff2f6cd0eb
permissions
-rw-r--r--

Added tag mips-jdk8u275-b01 for changeset d3b4d62f391f

aoqi@0 1 /*
dlong@7598 2 * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation.
aoqi@0 8 *
aoqi@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 12 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 13 * accompanied this code).
aoqi@0 14 *
aoqi@0 15 * You should have received a copy of the GNU General Public License version
aoqi@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 18 *
aoqi@0 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 20 * or visit www.oracle.com if you need additional information or have any
aoqi@0 21 * questions.
aoqi@0 22 *
aoqi@0 23 */
aoqi@0 24
aoqi@1 25 /*
aoqi@1 26 * This file has been modified by Loongson Technology in 2015. These
aoqi@1 27 * modifications are Copyright (c) 2015 Loongson Technology, and are made
aoqi@1 28 * available on the same license terms set forth above.
aoqi@1 29 */
aoqi@1 30
aoqi@0 31 #ifndef SHARE_VM_INTERPRETER_TEMPLATETABLE_HPP
aoqi@0 32 #define SHARE_VM_INTERPRETER_TEMPLATETABLE_HPP
aoqi@0 33
aoqi@0 34 #include "interpreter/bytecodes.hpp"
aoqi@0 35 #include "memory/allocation.hpp"
aoqi@0 36 #include "runtime/frame.hpp"
dlong@7598 37 #if defined INTERP_MASM_MD_HPP
dlong@7598 38 # include INTERP_MASM_MD_HPP
dlong@7598 39 #elif defined TARGET_ARCH_x86
aoqi@0 40 # include "interp_masm_x86.hpp"
dlong@7598 41 #elif defined TARGET_ARCH_MODEL_sparc
goetz@6512 42 # include "interp_masm_sparc.hpp"
dlong@7598 43 #elif defined TARGET_ARCH_MODEL_zero
goetz@6512 44 # include "interp_masm_zero.hpp"
dlong@7598 45 #elif defined TARGET_ARCH_MODEL_ppc_64
goetz@6512 46 # include "interp_masm_ppc_64.hpp"
aoqi@7994 47 #elif defined TARGET_ARCH_MODEL_mips_64
aoqi@1 48 # include "interp_masm_mips_64.hpp"
aoqi@1 49 #endif
aoqi@0 50
aoqi@0 51 #ifndef CC_INTERP
aoqi@0 52 // All the necessary definitions used for (bytecode) template generation. Instead of
aoqi@0 53 // spreading the implementation functionality for each bytecode in the interpreter
aoqi@0 54 // and the snippet generator, a template is assigned to each bytecode which can be
aoqi@0 55 // used to generate the bytecode's implementation if needed.
aoqi@0 56
aoqi@0 57
aoqi@0 58 // A Template describes the properties of a code template for a given bytecode
aoqi@0 59 // and provides a generator to generate the code template.
aoqi@0 60
aoqi@0 61 class Template VALUE_OBJ_CLASS_SPEC {
aoqi@0 62 private:
aoqi@0 63 enum Flags {
aoqi@0 64 uses_bcp_bit, // set if template needs the bcp pointing to bytecode
aoqi@0 65 does_dispatch_bit, // set if template dispatches on its own
aoqi@0 66 calls_vm_bit, // set if template calls the vm
aoqi@0 67 wide_bit // set if template belongs to a wide instruction
aoqi@0 68 };
aoqi@0 69
aoqi@0 70 typedef void (*generator)(int arg);
aoqi@0 71
aoqi@0 72 int _flags; // describes interpreter template properties (bcp unknown)
aoqi@0 73 TosState _tos_in; // tos cache state before template execution
aoqi@0 74 TosState _tos_out; // tos cache state after template execution
aoqi@0 75 generator _gen; // template code generator
aoqi@0 76 int _arg; // argument for template code generator
aoqi@0 77
aoqi@0 78 void initialize(int flags, TosState tos_in, TosState tos_out, generator gen, int arg);
aoqi@0 79
aoqi@0 80 friend class TemplateTable;
aoqi@0 81
aoqi@0 82 public:
aoqi@0 83 Bytecodes::Code bytecode() const;
aoqi@0 84 bool is_valid() const { return _gen != NULL; }
aoqi@0 85 bool uses_bcp() const { return (_flags & (1 << uses_bcp_bit )) != 0; }
aoqi@0 86 bool does_dispatch() const { return (_flags & (1 << does_dispatch_bit)) != 0; }
aoqi@0 87 bool calls_vm() const { return (_flags & (1 << calls_vm_bit )) != 0; }
aoqi@0 88 bool is_wide() const { return (_flags & (1 << wide_bit )) != 0; }
aoqi@0 89 TosState tos_in() const { return _tos_in; }
aoqi@0 90 TosState tos_out() const { return _tos_out; }
aoqi@0 91 void generate(InterpreterMacroAssembler* masm);
aoqi@0 92 };
aoqi@0 93
aoqi@0 94
aoqi@0 95 // The TemplateTable defines all Templates and provides accessor functions
aoqi@0 96 // to get the template for a given bytecode.
aoqi@0 97
aoqi@0 98 class TemplateTable: AllStatic {
aoqi@0 99 public:
aoqi@0 100 enum Operation { add, sub, mul, div, rem, _and, _or, _xor, shl, shr, ushr };
aoqi@0 101 enum Condition { equal, not_equal, less, less_equal, greater, greater_equal };
aoqi@0 102 enum CacheByte { f1_byte = 1, f2_byte = 2 }; // byte_no codes
aoqi@0 103
aoqi@0 104 private:
aoqi@0 105 static bool _is_initialized; // true if TemplateTable has been initialized
aoqi@0 106 static Template _template_table [Bytecodes::number_of_codes];
aoqi@0 107 static Template _template_table_wide[Bytecodes::number_of_codes];
aoqi@0 108
aoqi@0 109 static Template* _desc; // the current template to be generated
aoqi@0 110 static Bytecodes::Code bytecode() { return _desc->bytecode(); }
aoqi@0 111
aoqi@0 112 static BarrierSet* _bs; // Cache the barrier set.
aoqi@0 113 public:
aoqi@0 114 //%note templates_1
aoqi@0 115 static InterpreterMacroAssembler* _masm; // the assembler used when generating templates
aoqi@0 116
aoqi@0 117 private:
aoqi@0 118
aoqi@0 119 // special registers
aoqi@0 120 static inline Address at_bcp(int offset);
aoqi@0 121
aoqi@0 122 // helpers
aoqi@0 123 static void unimplemented_bc();
aoqi@0 124 static void patch_bytecode(Bytecodes::Code bc, Register bc_reg,
aoqi@0 125 Register temp_reg, bool load_bc_into_bc_reg = true, int byte_no = -1);
aoqi@0 126
aoqi@0 127 // C calls
aoqi@0 128 static void call_VM(Register oop_result, address entry_point);
aoqi@0 129 static void call_VM(Register oop_result, address entry_point, Register arg_1);
aoqi@0 130 static void call_VM(Register oop_result, address entry_point, Register arg_1, Register arg_2);
aoqi@0 131 static void call_VM(Register oop_result, address entry_point, Register arg_1, Register arg_2, Register arg_3);
aoqi@0 132
aoqi@0 133 // these overloadings are not presently used on SPARC:
aoqi@0 134 static void call_VM(Register oop_result, Register last_java_sp, address entry_point);
aoqi@0 135 static void call_VM(Register oop_result, Register last_java_sp, address entry_point, Register arg_1);
aoqi@0 136 static void call_VM(Register oop_result, Register last_java_sp, address entry_point, Register arg_1, Register arg_2);
aoqi@0 137 static void call_VM(Register oop_result, Register last_java_sp, address entry_point, Register arg_1, Register arg_2, Register arg_3);
aoqi@0 138
aoqi@0 139 // bytecodes
aoqi@0 140 static void nop();
aoqi@0 141
aoqi@0 142 static void aconst_null();
aoqi@0 143 static void iconst(int value);
aoqi@0 144 static void lconst(int value);
aoqi@0 145 static void fconst(int value);
aoqi@0 146 static void dconst(int value);
aoqi@0 147
aoqi@0 148 static void bipush();
aoqi@0 149 static void sipush();
aoqi@0 150 static void ldc(bool wide);
aoqi@0 151 static void ldc2_w();
aoqi@0 152 static void fast_aldc(bool wide);
aoqi@0 153
aoqi@0 154 static void locals_index(Register reg, int offset = 1);
aoqi@0 155 static void iload();
aoqi@0 156 static void fast_iload();
aoqi@0 157 static void fast_iload2();
aoqi@0 158 static void fast_icaload();
aoqi@0 159 static void lload();
aoqi@0 160 static void fload();
aoqi@0 161 static void dload();
aoqi@0 162 static void aload();
aoqi@0 163
aoqi@0 164 static void locals_index_wide(Register reg);
aoqi@0 165 static void wide_iload();
aoqi@0 166 static void wide_lload();
aoqi@0 167 static void wide_fload();
aoqi@0 168 static void wide_dload();
aoqi@0 169 static void wide_aload();
aoqi@0 170
aoqi@0 171 static void iaload();
aoqi@0 172 static void laload();
aoqi@0 173 static void faload();
aoqi@0 174 static void daload();
aoqi@0 175 static void aaload();
aoqi@0 176 static void baload();
aoqi@0 177 static void caload();
aoqi@0 178 static void saload();
aoqi@0 179
aoqi@0 180 static void iload(int n);
aoqi@0 181 static void lload(int n);
aoqi@0 182 static void fload(int n);
aoqi@0 183 static void dload(int n);
aoqi@0 184 static void aload(int n);
aoqi@0 185 static void aload_0();
aoqi@0 186
aoqi@0 187 static void istore();
aoqi@0 188 static void lstore();
aoqi@0 189 static void fstore();
aoqi@0 190 static void dstore();
aoqi@0 191 static void astore();
aoqi@0 192
aoqi@0 193 static void wide_istore();
aoqi@0 194 static void wide_lstore();
aoqi@0 195 static void wide_fstore();
aoqi@0 196 static void wide_dstore();
aoqi@0 197 static void wide_astore();
aoqi@0 198
aoqi@0 199 static void iastore();
aoqi@0 200 static void lastore();
aoqi@0 201 static void fastore();
aoqi@0 202 static void dastore();
aoqi@0 203 static void aastore();
aoqi@0 204 static void bastore();
aoqi@0 205 static void castore();
aoqi@0 206 static void sastore();
aoqi@0 207
aoqi@0 208 static void istore(int n);
aoqi@0 209 static void lstore(int n);
aoqi@0 210 static void fstore(int n);
aoqi@0 211 static void dstore(int n);
aoqi@0 212 static void astore(int n);
aoqi@0 213
aoqi@0 214 static void pop();
aoqi@0 215 static void pop2();
aoqi@0 216 static void dup();
aoqi@0 217 static void dup_x1();
aoqi@0 218 static void dup_x2();
aoqi@0 219 static void dup2();
aoqi@0 220 static void dup2_x1();
aoqi@0 221 static void dup2_x2();
aoqi@0 222 static void swap();
aoqi@0 223
aoqi@0 224 static void iop2(Operation op);
aoqi@0 225 static void lop2(Operation op);
aoqi@0 226 static void fop2(Operation op);
aoqi@0 227 static void dop2(Operation op);
aoqi@0 228
aoqi@0 229 static void idiv();
aoqi@0 230 static void irem();
aoqi@0 231
aoqi@0 232 static void lmul();
aoqi@0 233 static void ldiv();
aoqi@0 234 static void lrem();
aoqi@0 235 static void lshl();
aoqi@0 236 static void lshr();
aoqi@0 237 static void lushr();
aoqi@0 238
aoqi@0 239 static void ineg();
aoqi@0 240 static void lneg();
aoqi@0 241 static void fneg();
aoqi@0 242 static void dneg();
aoqi@0 243
aoqi@0 244 static void iinc();
aoqi@0 245 static void wide_iinc();
aoqi@0 246 static void convert();
aoqi@0 247 static void lcmp();
aoqi@0 248
aoqi@0 249 static void float_cmp (bool is_float, int unordered_result);
aoqi@0 250 static void float_cmp (int unordered_result);
aoqi@0 251 static void double_cmp(int unordered_result);
aoqi@0 252
aoqi@0 253 static void count_calls(Register method, Register temp);
aoqi@0 254 static void branch(bool is_jsr, bool is_wide);
aoqi@0 255 static void if_0cmp (Condition cc);
aoqi@0 256 static void if_icmp (Condition cc);
aoqi@0 257 static void if_nullcmp(Condition cc);
aoqi@0 258 static void if_acmp (Condition cc);
aoqi@0 259
aoqi@0 260 static void _goto();
aoqi@0 261 static void jsr();
aoqi@0 262 static void ret();
aoqi@0 263 static void wide_ret();
aoqi@0 264
aoqi@0 265 static void goto_w();
aoqi@0 266 static void jsr_w();
aoqi@0 267
aoqi@0 268 static void tableswitch();
aoqi@0 269 static void lookupswitch();
aoqi@0 270 static void fast_linearswitch();
aoqi@0 271 static void fast_binaryswitch();
aoqi@0 272
aoqi@0 273 static void _return(TosState state);
aoqi@0 274
aoqi@0 275 static void resolve_cache_and_index(int byte_no, // one of 1,2,11
aoqi@0 276 Register cache, // output for CP cache
aoqi@0 277 Register index, // output for CP index
aoqi@0 278 size_t index_size); // one of 1,2,4
aoqi@0 279 static void load_invoke_cp_cache_entry(int byte_no,
aoqi@0 280 Register method,
aoqi@0 281 Register itable_index,
aoqi@0 282 Register flags,
aoqi@0 283 bool is_invokevirtual,
aoqi@0 284 bool is_virtual_final,
aoqi@0 285 bool is_invokedynamic);
aoqi@0 286 static void load_field_cp_cache_entry(Register obj,
aoqi@0 287 Register cache,
aoqi@0 288 Register index,
aoqi@0 289 Register offset,
aoqi@0 290 Register flags,
aoqi@0 291 bool is_static);
aoqi@0 292 static void invokevirtual(int byte_no);
aoqi@0 293 static void invokespecial(int byte_no);
aoqi@0 294 static void invokestatic(int byte_no);
aoqi@0 295 static void invokeinterface(int byte_no);
aoqi@0 296 static void invokedynamic(int byte_no);
aoqi@0 297 static void invokehandle(int byte_no);
aoqi@0 298 static void fast_invokevfinal(int byte_no);
aoqi@0 299
aoqi@0 300 static void getfield_or_static(int byte_no, bool is_static);
aoqi@0 301 static void putfield_or_static(int byte_no, bool is_static);
aoqi@0 302 static void getfield(int byte_no);
aoqi@0 303 static void putfield(int byte_no);
aoqi@0 304 static void getstatic(int byte_no);
aoqi@0 305 static void putstatic(int byte_no);
aoqi@0 306 static void pop_and_check_object(Register obj);
aoqi@0 307
aoqi@0 308 static void _new();
aoqi@0 309 static void newarray();
aoqi@0 310 static void anewarray();
aoqi@0 311 static void arraylength();
aoqi@0 312 static void checkcast();
aoqi@0 313 static void instanceof();
aoqi@0 314
aoqi@0 315 static void athrow();
aoqi@0 316
aoqi@0 317 static void monitorenter();
aoqi@0 318 static void monitorexit();
aoqi@0 319
aoqi@0 320 static void wide();
aoqi@0 321 static void multianewarray();
aoqi@0 322
aoqi@0 323 static void fast_xaccess(TosState state);
aoqi@0 324 static void fast_accessfield(TosState state);
aoqi@0 325 static void fast_storefield(TosState state);
aoqi@0 326
aoqi@0 327 static void _breakpoint();
aoqi@0 328
aoqi@0 329 static void shouldnotreachhere();
aoqi@0 330
aoqi@0 331 // jvmti support
aoqi@0 332 static void jvmti_post_field_access(Register cache, Register index, bool is_static, bool has_tos);
aoqi@0 333 static void jvmti_post_field_mod(Register cache, Register index, bool is_static);
aoqi@0 334 static void jvmti_post_fast_field_mod();
aoqi@0 335
aoqi@0 336 // debugging of TemplateGenerator
aoqi@0 337 static void transition(TosState tos_in, TosState tos_out);// checks if in/out states expected by template generator correspond to table entries
aoqi@0 338
aoqi@0 339 // initialization helpers
aoqi@0 340 static void def(Bytecodes::Code code, int flags, TosState in, TosState out, void (*gen)( ), char filler );
aoqi@0 341 static void def(Bytecodes::Code code, int flags, TosState in, TosState out, void (*gen)(int arg ), int arg );
aoqi@0 342 static void def(Bytecodes::Code code, int flags, TosState in, TosState out, void (*gen)(bool arg ), bool arg );
aoqi@0 343 static void def(Bytecodes::Code code, int flags, TosState in, TosState out, void (*gen)(TosState tos), TosState tos);
aoqi@0 344 static void def(Bytecodes::Code code, int flags, TosState in, TosState out, void (*gen)(Operation op), Operation op);
aoqi@0 345 static void def(Bytecodes::Code code, int flags, TosState in, TosState out, void (*gen)(Condition cc), Condition cc);
aoqi@0 346
aoqi@0 347 friend class Template;
aoqi@0 348
aoqi@0 349 // InterpreterMacroAssembler::is_a(), etc., need TemplateTable::call_VM().
aoqi@0 350 friend class InterpreterMacroAssembler;
aoqi@0 351
aoqi@0 352 public:
aoqi@0 353 // Initialization
aoqi@0 354 static void initialize();
aoqi@0 355 static void pd_initialize();
aoqi@0 356
aoqi@0 357 // Templates
aoqi@0 358 static Template* template_for (Bytecodes::Code code) { Bytecodes::check (code); return &_template_table [code]; }
aoqi@0 359 static Template* template_for_wide(Bytecodes::Code code) { Bytecodes::wide_check(code); return &_template_table_wide[code]; }
aoqi@0 360
aoqi@0 361 // Platform specifics
dlong@7598 362 #if defined TEMPLATETABLE_MD_HPP
dlong@7598 363 # include TEMPLATETABLE_MD_HPP
dlong@7598 364 #elif defined TARGET_ARCH_MODEL_x86_32
aoqi@0 365 # include "templateTable_x86_32.hpp"
dlong@7598 366 #elif defined TARGET_ARCH_MODEL_x86_64
aoqi@0 367 # include "templateTable_x86_64.hpp"
dlong@7598 368 #elif defined TARGET_ARCH_MODEL_sparc
goetz@6512 369 # include "templateTable_sparc.hpp"
dlong@7598 370 #elif defined TARGET_ARCH_MODEL_zero
goetz@6512 371 # include "templateTable_zero.hpp"
dlong@7598 372 #elif defined TARGET_ARCH_MODEL_ppc_64
goetz@6512 373 # include "templateTable_ppc_64.hpp"
aoqi@7994 374 #elif defined TARGET_ARCH_MODEL_mips_64
aoqi@1 375 # include "templateTable_mips_64.hpp"
aoqi@1 376 #endif
aoqi@0 377
aoqi@0 378 };
aoqi@0 379 #endif /* !CC_INTERP */
aoqi@0 380
aoqi@0 381 #endif // SHARE_VM_INTERPRETER_TEMPLATETABLE_HPP

mercurial