src/share/vm/ci/ciMethod.cpp

Print this page


   1 /*
   2  * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  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  *


  62 //
  63 // This class represents a methodOop in the HotSpot virtual
  64 // machine.
  65 
  66 
  67 // ------------------------------------------------------------------
  68 // ciMethod::ciMethod
  69 //
  70 // Loaded method.
  71 ciMethod::ciMethod(methodHandle h_m) : ciObject(h_m) {
  72   assert(h_m() != NULL, "no null method");
  73 
  74   // These fields are always filled in in loaded methods.
  75   _flags = ciFlags(h_m()->access_flags());
  76 
  77   // Easy to compute, so fill them in now.
  78   _max_stack          = h_m()->max_stack();
  79   _max_locals         = h_m()->max_locals();
  80   _code_size          = h_m()->code_size();
  81   _intrinsic_id       = h_m()->intrinsic_id();
  82   _handler_count      = h_m()->exception_table()->length() / 4;
  83   _uses_monitors      = h_m()->access_flags().has_monitor_bytecodes();
  84   _balanced_monitors  = !_uses_monitors || h_m()->access_flags().is_monitor_matching();
  85   _is_c1_compilable   = !h_m()->is_not_c1_compilable();
  86   _is_c2_compilable   = !h_m()->is_not_c2_compilable();
  87   // Lazy fields, filled in on demand.  Require allocation.
  88   _code               = NULL;
  89   _exception_handlers = NULL;
  90   _liveness           = NULL;
  91   _method_blocks = NULL;
  92 #if defined(COMPILER2) || defined(SHARK)
  93   _flow               = NULL;
  94   _bcea               = NULL;
  95 #endif // COMPILER2 || SHARK
  96 
  97   ciEnv *env = CURRENT_ENV;
  98   if (env->jvmti_can_hotswap_or_post_breakpoint() && can_be_compiled()) {
  99     // 6328518 check hotswap conditions under the right lock.
 100     MutexLocker locker(Compile_lock);
 101     if (Dependencies::check_evol_method(h_m()) != NULL) {
 102       _is_c1_compilable = false;


 181   assert(is_loaded(), "only loaded methods have code");
 182 
 183   methodOop me = get_methodOop();
 184   Arena* arena = CURRENT_THREAD_ENV->arena();
 185 
 186   // Load the bytecodes.
 187   _code = (address)arena->Amalloc(code_size());
 188   memcpy(_code, me->code_base(), code_size());
 189 
 190   // Revert any breakpoint bytecodes in ci's copy
 191   if (me->number_of_breakpoints() > 0) {
 192     BreakpointInfo* bp = instanceKlass::cast(me->method_holder())->breakpoints();
 193     for (; bp != NULL; bp = bp->next()) {
 194       if (bp->match(me)) {
 195         code_at_put(bp->bci(), bp->orig_bytecode());
 196       }
 197     }
 198   }
 199 
 200   // And load the exception table.
 201   typeArrayOop exc_table = me->exception_table();
 202 
 203   // Allocate one extra spot in our list of exceptions.  This
 204   // last entry will be used to represent the possibility that
 205   // an exception escapes the method.  See ciExceptionHandlerStream
 206   // for details.
 207   _exception_handlers =
 208     (ciExceptionHandler**)arena->Amalloc(sizeof(ciExceptionHandler*)
 209                                          * (_handler_count + 1));
 210   if (_handler_count > 0) {
 211     for (int i=0; i<_handler_count; i++) {
 212       int base = i*4;
 213       _exception_handlers[i] = new (arena) ciExceptionHandler(
 214                                 holder(),
 215             /* start    */      exc_table->int_at(base),
 216             /* limit    */      exc_table->int_at(base+1),
 217             /* goto pc  */      exc_table->int_at(base+2),
 218             /* cp index */      exc_table->int_at(base+3));
 219     }
 220   }
 221 
 222   // Put an entry at the end of our list to represent the possibility
 223   // of exceptional exit.
 224   _exception_handlers[_handler_count] =
 225     new (arena) ciExceptionHandler(holder(), 0, code_size(), -1, 0);
 226 
 227   if (CIPrintMethodCodes) {
 228     print_codes();
 229   }
 230 }
 231 
 232 
 233 // ------------------------------------------------------------------
 234 // ciMethod::has_linenumber_table
 235 //
 236 // length unknown until decompression
 237 bool    ciMethod::has_linenumber_table() const {
 238   check_is_loaded();


   1 /*
   2  * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  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  *


  62 //
  63 // This class represents a methodOop in the HotSpot virtual
  64 // machine.
  65 
  66 
  67 // ------------------------------------------------------------------
  68 // ciMethod::ciMethod
  69 //
  70 // Loaded method.
  71 ciMethod::ciMethod(methodHandle h_m) : ciObject(h_m) {
  72   assert(h_m() != NULL, "no null method");
  73 
  74   // These fields are always filled in in loaded methods.
  75   _flags = ciFlags(h_m()->access_flags());
  76 
  77   // Easy to compute, so fill them in now.
  78   _max_stack          = h_m()->max_stack();
  79   _max_locals         = h_m()->max_locals();
  80   _code_size          = h_m()->code_size();
  81   _intrinsic_id       = h_m()->intrinsic_id();
  82   _handler_count      = h_m()->exception_table_length();
  83   _uses_monitors      = h_m()->access_flags().has_monitor_bytecodes();
  84   _balanced_monitors  = !_uses_monitors || h_m()->access_flags().is_monitor_matching();
  85   _is_c1_compilable   = !h_m()->is_not_c1_compilable();
  86   _is_c2_compilable   = !h_m()->is_not_c2_compilable();
  87   // Lazy fields, filled in on demand.  Require allocation.
  88   _code               = NULL;
  89   _exception_handlers = NULL;
  90   _liveness           = NULL;
  91   _method_blocks = NULL;
  92 #if defined(COMPILER2) || defined(SHARK)
  93   _flow               = NULL;
  94   _bcea               = NULL;
  95 #endif // COMPILER2 || SHARK
  96 
  97   ciEnv *env = CURRENT_ENV;
  98   if (env->jvmti_can_hotswap_or_post_breakpoint() && can_be_compiled()) {
  99     // 6328518 check hotswap conditions under the right lock.
 100     MutexLocker locker(Compile_lock);
 101     if (Dependencies::check_evol_method(h_m()) != NULL) {
 102       _is_c1_compilable = false;


 181   assert(is_loaded(), "only loaded methods have code");
 182 
 183   methodOop me = get_methodOop();
 184   Arena* arena = CURRENT_THREAD_ENV->arena();
 185 
 186   // Load the bytecodes.
 187   _code = (address)arena->Amalloc(code_size());
 188   memcpy(_code, me->code_base(), code_size());
 189 
 190   // Revert any breakpoint bytecodes in ci's copy
 191   if (me->number_of_breakpoints() > 0) {
 192     BreakpointInfo* bp = instanceKlass::cast(me->method_holder())->breakpoints();
 193     for (; bp != NULL; bp = bp->next()) {
 194       if (bp->match(me)) {
 195         code_at_put(bp->bci(), bp->orig_bytecode());
 196       }
 197     }
 198   }
 199 
 200   // And load the exception table.
 201   ExceptionTable exc_table(me);
 202 
 203   // Allocate one extra spot in our list of exceptions.  This
 204   // last entry will be used to represent the possibility that
 205   // an exception escapes the method.  See ciExceptionHandlerStream
 206   // for details.
 207   _exception_handlers =
 208     (ciExceptionHandler**)arena->Amalloc(sizeof(ciExceptionHandler*)
 209                                          * (_handler_count + 1));
 210   if (_handler_count > 0) {
 211     for (int i=0; i<_handler_count; i++) {

 212       _exception_handlers[i] = new (arena) ciExceptionHandler(
 213                                 holder(),
 214             /* start    */      exc_table.start_pc(i),
 215             /* limit    */      exc_table.end_pc(i),
 216             /* goto pc  */      exc_table.handler_pc(i),
 217             /* cp index */      exc_table.catch_type_index(i));
 218     }
 219   }
 220 
 221   // Put an entry at the end of our list to represent the possibility
 222   // of exceptional exit.
 223   _exception_handlers[_handler_count] =
 224     new (arena) ciExceptionHandler(holder(), 0, code_size(), -1, 0);
 225 
 226   if (CIPrintMethodCodes) {
 227     print_codes();
 228   }
 229 }
 230 
 231 
 232 // ------------------------------------------------------------------
 233 // ciMethod::has_linenumber_table
 234 //
 235 // length unknown until decompression
 236 bool    ciMethod::has_linenumber_table() const {
 237   check_is_loaded();