< prev index next >

src/hotspot/share/interpreter/abstractInterpreter.cpp

Print this page




  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  */
  24 
  25 #include "precompiled.hpp"
  26 #include "asm/macroAssembler.hpp"
  27 #include "asm/macroAssembler.inline.hpp"
  28 #include "compiler/disassembler.hpp"
  29 #include "interpreter/bytecodeHistogram.hpp"
  30 #include "interpreter/bytecodeInterpreter.hpp"

  31 #include "interpreter/interpreter.hpp"
  32 #include "interpreter/interpreterRuntime.hpp"
  33 #include "interpreter/interp_masm.hpp"
  34 #include "interpreter/templateTable.hpp"
  35 #include "memory/allocation.inline.hpp"
  36 #include "memory/metaspaceShared.hpp"
  37 #include "memory/resourceArea.hpp"
  38 #include "oops/arrayOop.hpp"


  39 #include "oops/methodData.hpp"
  40 #include "oops/method.hpp"
  41 #include "oops/oop.inline.hpp"
  42 #include "prims/forte.hpp"
  43 #include "prims/jvmtiExport.hpp"
  44 #include "prims/methodHandles.hpp"
  45 #include "runtime/handles.inline.hpp"
  46 #include "runtime/sharedRuntime.hpp"
  47 #include "runtime/stubRoutines.hpp"
  48 #include "runtime/timer.hpp"
  49 
  50 # define __ _masm->
  51 
  52 //------------------------------------------------------------------------------------------------------------------------
  53 // Implementation of platform independent aspects of Interpreter
  54 
  55 void AbstractInterpreter::initialize() {
  56   if (_code != NULL) return;
  57 
  58   // make sure 'imported' classes are initialized


 223     if (PrintInterpreter) {
 224       Disassembler::decode(buffer.insts_begin(), buffer.insts_end());
 225     }
 226   }
 227 }
 228 
 229 #endif
 230 
 231 void AbstractInterpreter::set_entry_for_kind(AbstractInterpreter::MethodKind kind, address entry) {
 232   assert(kind >= method_handle_invoke_FIRST &&
 233          kind <= method_handle_invoke_LAST, "late initialization only for MH entry points");
 234   assert(_entry_table[kind] == _entry_table[abstract], "previous value must be AME entry");
 235   _entry_table[kind] = entry;
 236 
 237   update_cds_entry_table(kind);
 238 }
 239 
 240 // Return true if the interpreter can prove that the given bytecode has
 241 // not yet been executed (in Java semantics, not in actual operation).
 242 bool AbstractInterpreter::is_not_reached(const methodHandle& method, int bci) {
 243   Bytecodes::Code code = method()->code_at(bci);

 244 
 245   if (!Bytecodes::must_rewrite(code)) {


























 246     // might have been reached
 247     return false;
 248   }
 249 
 250   // the bytecode might not be rewritten if the method is an accessor, etc.
 251   address ientry = method->interpreter_entry();
 252   if (ientry != entry_for_kind(AbstractInterpreter::zerolocals) &&
 253       ientry != entry_for_kind(AbstractInterpreter::zerolocals_synchronized))
 254     return false;  // interpreter does not run this method!
 255 
 256   // otherwise, we can be sure this bytecode has never been executed
 257   return true;
 258 }
 259 
 260 
 261 #ifndef PRODUCT
 262 void AbstractInterpreter::print_method_kind(MethodKind kind) {
 263   switch (kind) {
 264     case zerolocals             : tty->print("zerolocals"             ); break;
 265     case zerolocals_synchronized: tty->print("zerolocals_synchronized"); break;




  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  */
  24 
  25 #include "precompiled.hpp"
  26 #include "asm/macroAssembler.hpp"
  27 #include "asm/macroAssembler.inline.hpp"
  28 #include "compiler/disassembler.hpp"
  29 #include "interpreter/bytecodeHistogram.hpp"
  30 #include "interpreter/bytecodeInterpreter.hpp"
  31 #include "interpreter/bytecodeStream.hpp"
  32 #include "interpreter/interpreter.hpp"
  33 #include "interpreter/interpreterRuntime.hpp"
  34 #include "interpreter/interp_masm.hpp"
  35 #include "interpreter/templateTable.hpp"
  36 #include "memory/allocation.inline.hpp"
  37 #include "memory/metaspaceShared.hpp"
  38 #include "memory/resourceArea.hpp"
  39 #include "oops/arrayOop.hpp"
  40 #include "oops/constantPool.hpp"
  41 #include "oops/cpCache.inline.hpp"
  42 #include "oops/methodData.hpp"
  43 #include "oops/method.hpp"
  44 #include "oops/oop.inline.hpp"
  45 #include "prims/forte.hpp"
  46 #include "prims/jvmtiExport.hpp"
  47 #include "prims/methodHandles.hpp"
  48 #include "runtime/handles.inline.hpp"
  49 #include "runtime/sharedRuntime.hpp"
  50 #include "runtime/stubRoutines.hpp"
  51 #include "runtime/timer.hpp"
  52 
  53 # define __ _masm->
  54 
  55 //------------------------------------------------------------------------------------------------------------------------
  56 // Implementation of platform independent aspects of Interpreter
  57 
  58 void AbstractInterpreter::initialize() {
  59   if (_code != NULL) return;
  60 
  61   // make sure 'imported' classes are initialized


 226     if (PrintInterpreter) {
 227       Disassembler::decode(buffer.insts_begin(), buffer.insts_end());
 228     }
 229   }
 230 }
 231 
 232 #endif
 233 
 234 void AbstractInterpreter::set_entry_for_kind(AbstractInterpreter::MethodKind kind, address entry) {
 235   assert(kind >= method_handle_invoke_FIRST &&
 236          kind <= method_handle_invoke_LAST, "late initialization only for MH entry points");
 237   assert(_entry_table[kind] == _entry_table[abstract], "previous value must be AME entry");
 238   _entry_table[kind] = entry;
 239 
 240   update_cds_entry_table(kind);
 241 }
 242 
 243 // Return true if the interpreter can prove that the given bytecode has
 244 // not yet been executed (in Java semantics, not in actual operation).
 245 bool AbstractInterpreter::is_not_reached(const methodHandle& method, int bci) {
 246   BytecodeStream s(method, bci);
 247   Bytecodes::Code code = s.next();
 248 
 249   if (Bytecodes::is_invoke(code)) {
 250     assert(!Bytecodes::must_rewrite(code), "invokes aren't rewritten");
 251     ConstantPool* cpool = method()->constants();
 252 
 253     Bytecode invoke_bc(s.bytecode());
 254 
 255     switch (code) {
 256       case Bytecodes::_invokedynamic: {
 257         assert(invoke_bc.has_index_u4(code), "sanity");
 258         int method_index = invoke_bc.get_index_u4(code);
 259         return cpool->invokedynamic_cp_cache_entry_at(method_index)->is_f1_null();
 260       }
 261       case Bytecodes::_invokevirtual:   // fall-through
 262       case Bytecodes::_invokeinterface: // fall-through
 263       case Bytecodes::_invokespecial:   // fall-through
 264       case Bytecodes::_invokestatic: {
 265         if (cpool->has_preresolution()) {
 266           return false; // might have been reached
 267         }
 268         assert(!invoke_bc.has_index_u4(code), "sanity");
 269         int method_index = invoke_bc.get_index_u2_cpcache(code);
 270         Method* resolved_method = ConstantPool::method_at_if_loaded(cpool, method_index);
 271         return (resolved_method == NULL);
 272       }
 273       default: ShouldNotReachHere();
 274     }
 275   } else if (!Bytecodes::must_rewrite(code)) {
 276     // might have been reached
 277     return false;
 278   }
 279 
 280   // the bytecode might not be rewritten if the method is an accessor, etc.
 281   address ientry = method->interpreter_entry();
 282   if (ientry != entry_for_kind(AbstractInterpreter::zerolocals) &&
 283       ientry != entry_for_kind(AbstractInterpreter::zerolocals_synchronized))
 284     return false;  // interpreter does not run this method!
 285 
 286   // otherwise, we can be sure this bytecode has never been executed
 287   return true;
 288 }
 289 
 290 
 291 #ifndef PRODUCT
 292 void AbstractInterpreter::print_method_kind(MethodKind kind) {
 293   switch (kind) {
 294     case zerolocals             : tty->print("zerolocals"             ); break;
 295     case zerolocals_synchronized: tty->print("zerolocals_synchronized"); break;


< prev index next >