< prev index next >

src/share/vm/oops/constMethod.cpp

Print this page


  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  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "gc/shared/gcLocker.hpp"
  27 #include "interpreter/interpreter.hpp"
  28 #include "memory/heapInspection.hpp"
  29 #include "memory/metadataFactory.hpp"

  30 #include "memory/resourceArea.hpp"
  31 #include "oops/constMethod.hpp"
  32 #include "oops/method.hpp"
  33 
  34 // Static initialization
  35 const u2 ConstMethod::MAX_IDNUM   = 0xFFFE;
  36 const u2 ConstMethod::UNSET_IDNUM = 0xFFFF;
  37 
  38 ConstMethod* ConstMethod::allocate(ClassLoaderData* loader_data,
  39                                    int byte_code_size,
  40                                    InlineTableSizes* sizes,
  41                                    MethodType method_type,
  42                                    TRAPS) {
  43   int size = ConstMethod::size(byte_code_size, sizes);
  44   return new (loader_data, size, true, MetaspaceObj::ConstMethodType, THREAD) ConstMethod(
  45       byte_code_size, sizes, method_type, size);
  46 }
  47 
  48 ConstMethod::ConstMethod(int byte_code_size,
  49                          InlineTableSizes* sizes,
  50                          MethodType method_type,
  51                          int size) {
  52 
  53   NoSafepointVerifier no_safepoint;
  54   init_fingerprint();
  55   set_constants(NULL);
  56   set_stackmap_data(NULL);
  57   set_code_size(byte_code_size);
  58   set_constMethod_size(size);
  59   set_inlined_tables_length(sizes); // sets _flags
  60   set_method_type(method_type);
  61   assert(this->size() == size, "wrong size for object");
  62   set_name_index(0);
  63   set_signature_index(0);
  64   set_constants(NULL);


 381   Array<u1>* a;
 382   if (cm->has_method_annotations()) {
 383     assert(has_method_annotations(), "should be allocated already");
 384     a = copy_annotations(loader_data, cm->method_annotations(), CHECK);
 385     set_method_annotations(a);
 386   }
 387   if (cm->has_parameter_annotations()) {
 388     assert(has_parameter_annotations(), "should be allocated already");
 389     a = copy_annotations(loader_data, cm->parameter_annotations(), CHECK);
 390     set_parameter_annotations(a);
 391   }
 392   if (cm->has_type_annotations()) {
 393     assert(has_type_annotations(), "should be allocated already");
 394     a = copy_annotations(loader_data, cm->type_annotations(), CHECK);
 395     set_type_annotations(a);
 396   }
 397   if (cm->has_default_annotations()) {
 398     assert(has_default_annotations(), "should be allocated already");
 399     a = copy_annotations(loader_data, cm->default_annotations(), CHECK);
 400     set_default_annotations(a);



















 401   }
 402 }
 403 
 404 // Printing
 405 
 406 void ConstMethod::print_on(outputStream* st) const {
 407   ResourceMark rm;
 408   assert(is_constMethod(), "must be constMethod");
 409   st->print_cr("%s", internal_name());
 410   Method* m = method();
 411   st->print(" - method:       " INTPTR_FORMAT " ", p2i((address)m));
 412   if (m != NULL) {
 413     m->print_value_on(st);
 414   }
 415   st->cr();
 416   if (has_stackmap_table()) {
 417     st->print(" - stackmap data:       ");
 418     stackmap_data()->print_value_on(st);
 419     st->cr();
 420   }




  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  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "gc/shared/gcLocker.hpp"
  27 #include "interpreter/interpreter.hpp"
  28 #include "memory/heapInspection.hpp"
  29 #include "memory/metadataFactory.hpp"
  30 #include "memory/metaspaceClosure.hpp"
  31 #include "memory/resourceArea.hpp"
  32 #include "oops/constMethod.hpp"
  33 #include "oops/method.hpp"
  34 
  35 // Static initialization
  36 const u2 ConstMethod::MAX_IDNUM   = 0xFFFE;
  37 const u2 ConstMethod::UNSET_IDNUM = 0xFFFF;
  38 
  39 ConstMethod* ConstMethod::allocate(ClassLoaderData* loader_data,
  40                                    int byte_code_size,
  41                                    InlineTableSizes* sizes,
  42                                    MethodType method_type,
  43                                    TRAPS) {
  44   int size = ConstMethod::size(byte_code_size, sizes);
  45   return new (loader_data, size, MetaspaceObj::ConstMethodType, THREAD) ConstMethod(
  46       byte_code_size, sizes, method_type, size);
  47 }
  48 
  49 ConstMethod::ConstMethod(int byte_code_size,
  50                          InlineTableSizes* sizes,
  51                          MethodType method_type,
  52                          int size) {
  53 
  54   NoSafepointVerifier no_safepoint;
  55   init_fingerprint();
  56   set_constants(NULL);
  57   set_stackmap_data(NULL);
  58   set_code_size(byte_code_size);
  59   set_constMethod_size(size);
  60   set_inlined_tables_length(sizes); // sets _flags
  61   set_method_type(method_type);
  62   assert(this->size() == size, "wrong size for object");
  63   set_name_index(0);
  64   set_signature_index(0);
  65   set_constants(NULL);


 382   Array<u1>* a;
 383   if (cm->has_method_annotations()) {
 384     assert(has_method_annotations(), "should be allocated already");
 385     a = copy_annotations(loader_data, cm->method_annotations(), CHECK);
 386     set_method_annotations(a);
 387   }
 388   if (cm->has_parameter_annotations()) {
 389     assert(has_parameter_annotations(), "should be allocated already");
 390     a = copy_annotations(loader_data, cm->parameter_annotations(), CHECK);
 391     set_parameter_annotations(a);
 392   }
 393   if (cm->has_type_annotations()) {
 394     assert(has_type_annotations(), "should be allocated already");
 395     a = copy_annotations(loader_data, cm->type_annotations(), CHECK);
 396     set_type_annotations(a);
 397   }
 398   if (cm->has_default_annotations()) {
 399     assert(has_default_annotations(), "should be allocated already");
 400     a = copy_annotations(loader_data, cm->default_annotations(), CHECK);
 401     set_default_annotations(a);
 402   }
 403 }
 404 
 405 void ConstMethod::metaspace_pointers_do(MetaspaceClosure* it) {
 406   log_trace(cds)("Iter(ConstMethod): %p", this);
 407 
 408   it->push(&_constants);
 409   it->push(&_stackmap_data);
 410   if (has_method_annotations()) {
 411     it->push(method_annotations_addr());
 412   }
 413   if (has_parameter_annotations()) {
 414       it->push(parameter_annotations_addr());
 415   }
 416   if (has_type_annotations()) {
 417       it->push(type_annotations_addr());
 418   }
 419   if (has_default_annotations()) {
 420       it->push(default_annotations_addr());
 421   }
 422 }
 423 
 424 // Printing
 425 
 426 void ConstMethod::print_on(outputStream* st) const {
 427   ResourceMark rm;
 428   assert(is_constMethod(), "must be constMethod");
 429   st->print_cr("%s", internal_name());
 430   Method* m = method();
 431   st->print(" - method:       " INTPTR_FORMAT " ", p2i((address)m));
 432   if (m != NULL) {
 433     m->print_value_on(st);
 434   }
 435   st->cr();
 436   if (has_stackmap_table()) {
 437     st->print(" - stackmap data:       ");
 438     stackmap_data()->print_value_on(st);
 439     st->cr();
 440   }


< prev index next >