hotspot/src/share/vm/interpreter/bytecodes.cpp
changeset 7913 dd096a83bdbb
parent 7397 5b173b4ca846
child 8107 78e5bd944384
equal deleted inserted replaced
7901:ea3d83447861 7913:dd096a83bdbb
     1 /*
     1 /*
     2  * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    52 s_char          Bytecodes::_depth         [Bytecodes::number_of_codes];
    52 s_char          Bytecodes::_depth         [Bytecodes::number_of_codes];
    53 u_char          Bytecodes::_lengths       [Bytecodes::number_of_codes];
    53 u_char          Bytecodes::_lengths       [Bytecodes::number_of_codes];
    54 Bytecodes::Code Bytecodes::_java_code     [Bytecodes::number_of_codes];
    54 Bytecodes::Code Bytecodes::_java_code     [Bytecodes::number_of_codes];
    55 u_short         Bytecodes::_flags         [(1<<BitsPerByte)*2];
    55 u_short         Bytecodes::_flags         [(1<<BitsPerByte)*2];
    56 
    56 
       
    57 #ifdef ASSERT
       
    58 bool Bytecodes::check_method(const methodOopDesc* method, address bcp) {
       
    59   return method->contains(bcp);
       
    60 }
       
    61 #endif
       
    62 
       
    63 bool Bytecodes::check_must_rewrite(Bytecodes::Code code) {
       
    64   assert(can_rewrite(code), "post-check only");
       
    65 
       
    66   // Some codes are conditionally rewriting.  Look closely at them.
       
    67   switch (code) {
       
    68   case Bytecodes::_aload_0:
       
    69     // Even if RewriteFrequentPairs is turned on,
       
    70     // the _aload_0 code might delay its rewrite until
       
    71     // a following _getfield rewrites itself.
       
    72     return false;
       
    73 
       
    74   case Bytecodes::_lookupswitch:
       
    75     return false;  // the rewrite is not done by the interpreter
       
    76 
       
    77   case Bytecodes::_new:
       
    78     // (Could actually look at the class here, but the profit would be small.)
       
    79     return false;  // the rewrite is not always done
       
    80   }
       
    81 
       
    82   // No other special cases.
       
    83   return true;
       
    84 }
    57 
    85 
    58 Bytecodes::Code Bytecodes::code_at(methodOop method, int bci) {
    86 Bytecodes::Code Bytecodes::code_at(methodOop method, int bci) {
    59   return code_at(method->bcp_from(bci), method);
    87   return code_at(method, method->bcp_from(bci));
    60 }
    88 }
    61 
    89 
    62 Bytecodes::Code Bytecodes::non_breakpoint_code_at(address bcp, methodOop method) {
    90 Bytecodes::Code Bytecodes::non_breakpoint_code_at(const methodOopDesc* method, address bcp) {
    63   if (method == NULL)  method = methodOopDesc::method_from_bcp(bcp);
    91   assert(method != NULL, "must have the method for breakpoint conversion");
       
    92   assert(method->contains(bcp), "must be valid bcp in method");
    64   return method->orig_bytecode_at(method->bci_from(bcp));
    93   return method->orig_bytecode_at(method->bci_from(bcp));
    65 }
    94 }
    66 
    95 
    67 int Bytecodes::special_length_at(address bcp, address end) {
    96 int Bytecodes::special_length_at(Bytecodes::Code code, address bcp, address end) {
    68   Code code = code_at(bcp);
       
    69   switch (code) {
    97   switch (code) {
    70   case _wide:
    98   case _wide:
    71     if (end != NULL && bcp + 1 >= end) {
    99     if (end != NULL && bcp + 1 >= end) {
    72       return -1; // don't read past end of code buffer
   100       return -1; // don't read past end of code buffer
    73     }
   101     }
   118 int Bytecodes::raw_special_length_at(address bcp, address end) {
   146 int Bytecodes::raw_special_length_at(address bcp, address end) {
   119   Code code = code_or_bp_at(bcp);
   147   Code code = code_or_bp_at(bcp);
   120   if (code == _breakpoint) {
   148   if (code == _breakpoint) {
   121     return 1;
   149     return 1;
   122   } else {
   150   } else {
   123     return special_length_at(bcp, end);
   151     return special_length_at(code, bcp, end);
   124   }
   152   }
   125 }
   153 }
   126 
   154 
   127 
   155 
   128 
   156