src/share/vm/interpreter/templateTable.hpp

Tue, 23 Nov 2010 13:22:55 -0800

author
stefank
date
Tue, 23 Nov 2010 13:22:55 -0800
changeset 2314
f95d63e2154a
parent 1957
136b78722a08
child 2508
b92c45f2bc75
permissions
-rw-r--r--

6989984: Use standard include model for Hospot
Summary: Replaced MakeDeps and the includeDB files with more standardized solutions.
Reviewed-by: coleenp, kvn, kamg

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

mercurial