src/share/vm/interpreter/templateInterpreter.hpp

Fri, 31 Jul 2009 17:12:33 -0700

author
cfang
date
Fri, 31 Jul 2009 17:12:33 -0700
changeset 1335
9987d9d5eb0e
parent 1161
be93aad57795
child 1494
389049f3f393
permissions
-rw-r--r--

6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
Summary: developed a reexecute logic for the interpreter to reexecute the bytecode when deopt happens
Reviewed-by: kvn, never, jrose, twisti

duke@435 1 /*
jrose@1145 2 * Copyright 1997-2009 Sun Microsystems, Inc. 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 *
duke@435 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@435 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@435 21 * have any questions.
duke@435 22 *
duke@435 23 */
duke@435 24
twisti@1040 25 // This file contains the platform-independent parts
duke@435 26 // of the template interpreter and the template interpreter generator.
duke@435 27
duke@435 28 #ifndef CC_INTERP
duke@435 29
duke@435 30 //------------------------------------------------------------------------------------------------------------------------
duke@435 31 // A little wrapper class to group tosca-specific entry points into a unit.
duke@435 32 // (tosca = Top-Of-Stack CAche)
duke@435 33
duke@435 34 class EntryPoint VALUE_OBJ_CLASS_SPEC {
duke@435 35 private:
duke@435 36 address _entry[number_of_states];
duke@435 37
duke@435 38 public:
duke@435 39 // Construction
duke@435 40 EntryPoint();
duke@435 41 EntryPoint(address bentry, address centry, address sentry, address aentry, address ientry, address lentry, address fentry, address dentry, address ventry);
duke@435 42
duke@435 43 // Attributes
duke@435 44 address entry(TosState state) const; // return target address for a given tosca state
duke@435 45 void set_entry(TosState state, address entry); // set target address for a given tosca state
duke@435 46 void print();
duke@435 47
duke@435 48 // Comparison
duke@435 49 bool operator == (const EntryPoint& y); // for debugging only
duke@435 50 };
duke@435 51
duke@435 52
duke@435 53 //------------------------------------------------------------------------------------------------------------------------
duke@435 54 // A little wrapper class to group tosca-specific dispatch tables into a unit.
duke@435 55
duke@435 56 class DispatchTable VALUE_OBJ_CLASS_SPEC {
duke@435 57 public:
duke@435 58 enum { length = 1 << BitsPerByte }; // an entry point for each byte value (also for undefined bytecodes)
duke@435 59
duke@435 60 private:
duke@435 61 address _table[number_of_states][length]; // dispatch tables, indexed by tosca and bytecode
duke@435 62
duke@435 63 public:
duke@435 64 // Attributes
duke@435 65 EntryPoint entry(int i) const; // return entry point for a given bytecode i
duke@435 66 void set_entry(int i, EntryPoint& entry); // set entry point for a given bytecode i
duke@435 67 address* table_for(TosState state) { return _table[state]; }
duke@435 68 address* table_for() { return table_for((TosState)0); }
duke@435 69 int distance_from(address *table) { return table - table_for(); }
duke@435 70 int distance_from(TosState state) { return distance_from(table_for(state)); }
duke@435 71
duke@435 72 // Comparison
duke@435 73 bool operator == (DispatchTable& y); // for debugging only
duke@435 74 };
duke@435 75
duke@435 76 class TemplateInterpreter: public AbstractInterpreter {
duke@435 77 friend class VMStructs;
duke@435 78 friend class InterpreterMacroAssembler;
duke@435 79 friend class TemplateInterpreterGenerator;
jrose@1145 80 friend class InterpreterGenerator;
duke@435 81 friend class TemplateTable;
duke@435 82 // friend class Interpreter;
duke@435 83 public:
duke@435 84
duke@435 85 enum MoreConstants {
jrose@1161 86 number_of_return_entries = number_of_states, // number of return entry points
jrose@1161 87 number_of_deopt_entries = number_of_states, // number of deoptimization entry points
jrose@1161 88 number_of_return_addrs = number_of_states // number of return addresses
duke@435 89 };
duke@435 90
duke@435 91 protected:
duke@435 92
duke@435 93 static address _throw_ArrayIndexOutOfBoundsException_entry;
duke@435 94 static address _throw_ArrayStoreException_entry;
duke@435 95 static address _throw_ArithmeticException_entry;
duke@435 96 static address _throw_ClassCastException_entry;
jrose@1145 97 static address _throw_WrongMethodType_entry;
duke@435 98 static address _throw_NullPointerException_entry;
duke@435 99 static address _throw_exception_entry;
duke@435 100
duke@435 101 static address _throw_StackOverflowError_entry;
duke@435 102
duke@435 103 static address _remove_activation_entry; // continuation address if an exception is not handled by current frame
duke@435 104 #ifdef HOTSWAP
duke@435 105 static address _remove_activation_preserving_args_entry; // continuation address when current frame is being popped
duke@435 106 #endif // HOTSWAP
duke@435 107
duke@435 108 #ifndef PRODUCT
duke@435 109 static EntryPoint _trace_code;
duke@435 110 #endif // !PRODUCT
duke@435 111 static EntryPoint _return_entry[number_of_return_entries]; // entry points to return to from a call
duke@435 112 static EntryPoint _earlyret_entry; // entry point to return early from a call
jrose@1161 113 static EntryPoint _return_unbox_entry; // entry point to unbox a return value from a call
duke@435 114 static EntryPoint _deopt_entry[number_of_deopt_entries]; // entry points to return to from a deoptimization
duke@435 115 static EntryPoint _continuation_entry;
duke@435 116 static EntryPoint _safept_entry;
duke@435 117
duke@435 118 static address _return_3_addrs_by_index[number_of_return_addrs]; // for invokevirtual return entries
duke@435 119 static address _return_5_addrs_by_index[number_of_return_addrs]; // for invokeinterface return entries
jrose@1161 120 static address _return_5_unbox_addrs_by_index[number_of_return_addrs]; // for invokedynamic bootstrap methods
duke@435 121
duke@435 122 static DispatchTable _active_table; // the active dispatch table (used by the interpreter for dispatch)
duke@435 123 static DispatchTable _normal_table; // the normal dispatch table (used to set the active table in normal mode)
duke@435 124 static DispatchTable _safept_table; // the safepoint dispatch table (used to set the active table for safepoints)
duke@435 125 static address _wentry_point[DispatchTable::length]; // wide instructions only (vtos tosca always)
duke@435 126
duke@435 127
duke@435 128 public:
duke@435 129 // Initialization/debugging
duke@435 130 static void initialize();
duke@435 131 // this only returns whether a pc is within generated code for the interpreter.
duke@435 132 static bool contains(address pc) { return _code != NULL && _code->contains(pc); }
duke@435 133
duke@435 134 public:
duke@435 135
duke@435 136 static address remove_activation_early_entry(TosState state) { return _earlyret_entry.entry(state); }
duke@435 137 #ifdef HOTSWAP
duke@435 138 static address remove_activation_preserving_args_entry() { return _remove_activation_preserving_args_entry; }
duke@435 139 #endif // HOTSWAP
duke@435 140
duke@435 141 static address remove_activation_entry() { return _remove_activation_entry; }
duke@435 142 static address throw_exception_entry() { return _throw_exception_entry; }
duke@435 143 static address throw_ArithmeticException_entry() { return _throw_ArithmeticException_entry; }
jrose@1145 144 static address throw_WrongMethodType_entry() { return _throw_WrongMethodType_entry; }
duke@435 145 static address throw_NullPointerException_entry() { return _throw_NullPointerException_entry; }
duke@435 146 static address throw_StackOverflowError_entry() { return _throw_StackOverflowError_entry; }
duke@435 147
duke@435 148 // Code generation
duke@435 149 #ifndef PRODUCT
duke@435 150 static address trace_code (TosState state) { return _trace_code.entry(state); }
duke@435 151 #endif // !PRODUCT
duke@435 152 static address continuation (TosState state) { return _continuation_entry.entry(state); }
duke@435 153 static address* dispatch_table(TosState state) { return _active_table.table_for(state); }
duke@435 154 static address* dispatch_table() { return _active_table.table_for(); }
duke@435 155 static int distance_from_dispatch_table(TosState state){ return _active_table.distance_from(state); }
duke@435 156 static address* normal_table(TosState state) { return _normal_table.table_for(state); }
duke@435 157 static address* normal_table() { return _normal_table.table_for(); }
duke@435 158
duke@435 159 // Support for invokes
duke@435 160 static address* return_3_addrs_by_index_table() { return _return_3_addrs_by_index; }
duke@435 161 static address* return_5_addrs_by_index_table() { return _return_5_addrs_by_index; }
jrose@1161 162 static address* return_5_unbox_addrs_by_index_table() { return _return_5_unbox_addrs_by_index; }
duke@435 163 static int TosState_as_index(TosState state); // computes index into return_3_entry_by_index table
duke@435 164
duke@435 165 static address return_entry (TosState state, int length);
duke@435 166 static address deopt_entry (TosState state, int length);
jrose@1161 167 static address return_unbox_entry(TosState state, int length);
duke@435 168
duke@435 169 // Safepoint support
duke@435 170 static void notice_safepoints(); // stops the thread when reaching a safepoint
duke@435 171 static void ignore_safepoints(); // ignores safepoints
duke@435 172
duke@435 173 // Deoptimization support
cfang@1335 174 // Compute the entry address for continuation after
cfang@1335 175 static address deopt_continue_after_entry(methodOop method,
cfang@1335 176 address bcp,
cfang@1335 177 int callee_parameters,
cfang@1335 178 bool is_top_frame);
cfang@1335 179 // Deoptimization should reexecute this bytecode
cfang@1335 180 static bool bytecode_should_reexecute(Bytecodes::Code code);
cfang@1335 181 // Compute the address for reexecution
cfang@1335 182 static address deopt_reexecute_entry(methodOop method, address bcp);
duke@435 183
duke@435 184 #include "incls/_templateInterpreter_pd.hpp.incl"
duke@435 185
duke@435 186 };
duke@435 187
duke@435 188 #endif // !CC_INTERP

mercurial