src/share/vm/interpreter/templateTable.hpp

Tue, 08 Aug 2017 15:57:29 +0800

author
aoqi
date
Tue, 08 Aug 2017 15:57:29 +0800
changeset 6876
710a3c8b516e
parent 6512
fd1b9f02cc91
parent 1
2d8a650513c2
child 7994
04ff2f6cd0eb
permissions
-rw-r--r--

merge

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

mercurial