src/share/vm/oops/methodData.cpp

Print this page
rev 4136 : 7153771: array bound check elimination for c1
Summary: when possible optimize out array bound checks, inserting predicates when needed.
Reviewed-by:


 375   for (int i = 0; i < nargs; i++) {
 376     st->print("  0x%x", arg_modified(i));
 377   }
 378   st->cr();
 379 }
 380 
 381 #endif
 382 // ==================================================================
 383 // MethodData*
 384 //
 385 // A MethodData* holds information which has been collected about
 386 // a method.
 387 
 388 MethodData* MethodData::allocate(ClassLoaderData* loader_data, methodHandle method, TRAPS) {
 389   int size = MethodData::compute_allocation_size_in_words(method);
 390 
 391   return new (loader_data, size, false, THREAD) MethodData(method(), size, CHECK_NULL);
 392 }
 393 
 394 int MethodData::bytecode_cell_count(Bytecodes::Code code) {



 395   switch (code) {
 396   case Bytecodes::_checkcast:
 397   case Bytecodes::_instanceof:
 398   case Bytecodes::_aastore:
 399     if (TypeProfileCasts) {
 400       return ReceiverTypeData::static_cell_count();
 401     } else {
 402       return BitData::static_cell_count();
 403     }
 404   case Bytecodes::_invokespecial:
 405   case Bytecodes::_invokestatic:
 406     return CounterData::static_cell_count();
 407   case Bytecodes::_goto:
 408   case Bytecodes::_goto_w:
 409   case Bytecodes::_jsr:
 410   case Bytecodes::_jsr_w:
 411     return JumpData::static_cell_count();
 412   case Bytecodes::_invokevirtual:
 413   case Bytecodes::_invokeinterface:
 414     return VirtualCallData::static_cell_count();


 492   object_size += extra_data_count * DataLayout::compute_size_in_bytes(0);
 493 
 494   // Add a cell to record information about modified arguments.
 495   int arg_size = method->size_of_parameters();
 496   object_size += DataLayout::compute_size_in_bytes(arg_size+1);
 497   return object_size;
 498 }
 499 
 500 // Compute the size of the MethodData* necessary to store
 501 // profiling information about a given method.  Size is in words
 502 int MethodData::compute_allocation_size_in_words(methodHandle method) {
 503   int byte_size = compute_allocation_size_in_bytes(method);
 504   int word_size = align_size_up(byte_size, BytesPerWord) / BytesPerWord;
 505   return align_object_size(word_size);
 506 }
 507 
 508 // Initialize an individual data segment.  Returns the size of
 509 // the segment in bytes.
 510 int MethodData::initialize_data(BytecodeStream* stream,
 511                                        int data_index) {



 512   int cell_count = -1;
 513   int tag = DataLayout::no_tag;
 514   DataLayout* data_layout = data_layout_at(data_index);
 515   Bytecodes::Code c = stream->code();
 516   switch (c) {
 517   case Bytecodes::_checkcast:
 518   case Bytecodes::_instanceof:
 519   case Bytecodes::_aastore:
 520     if (TypeProfileCasts) {
 521       cell_count = ReceiverTypeData::static_cell_count();
 522       tag = DataLayout::receiver_type_data_tag;
 523     } else {
 524       cell_count = BitData::static_cell_count();
 525       tag = DataLayout::bit_data_tag;
 526     }
 527     break;
 528   case Bytecodes::_invokespecial:
 529   case Bytecodes::_invokestatic:
 530     cell_count = CounterData::static_cell_count();
 531     tag = DataLayout::counter_data_tag;




 375   for (int i = 0; i < nargs; i++) {
 376     st->print("  0x%x", arg_modified(i));
 377   }
 378   st->cr();
 379 }
 380 
 381 #endif
 382 // ==================================================================
 383 // MethodData*
 384 //
 385 // A MethodData* holds information which has been collected about
 386 // a method.
 387 
 388 MethodData* MethodData::allocate(ClassLoaderData* loader_data, methodHandle method, TRAPS) {
 389   int size = MethodData::compute_allocation_size_in_words(method);
 390 
 391   return new (loader_data, size, false, THREAD) MethodData(method(), size, CHECK_NULL);
 392 }
 393 
 394 int MethodData::bytecode_cell_count(Bytecodes::Code code) {
 395 #if defined(COMPILER1) && !defined(COMPILER2)
 396   return no_profile_data;
 397 #endif
 398   switch (code) {
 399   case Bytecodes::_checkcast:
 400   case Bytecodes::_instanceof:
 401   case Bytecodes::_aastore:
 402     if (TypeProfileCasts) {
 403       return ReceiverTypeData::static_cell_count();
 404     } else {
 405       return BitData::static_cell_count();
 406     }
 407   case Bytecodes::_invokespecial:
 408   case Bytecodes::_invokestatic:
 409     return CounterData::static_cell_count();
 410   case Bytecodes::_goto:
 411   case Bytecodes::_goto_w:
 412   case Bytecodes::_jsr:
 413   case Bytecodes::_jsr_w:
 414     return JumpData::static_cell_count();
 415   case Bytecodes::_invokevirtual:
 416   case Bytecodes::_invokeinterface:
 417     return VirtualCallData::static_cell_count();


 495   object_size += extra_data_count * DataLayout::compute_size_in_bytes(0);
 496 
 497   // Add a cell to record information about modified arguments.
 498   int arg_size = method->size_of_parameters();
 499   object_size += DataLayout::compute_size_in_bytes(arg_size+1);
 500   return object_size;
 501 }
 502 
 503 // Compute the size of the MethodData* necessary to store
 504 // profiling information about a given method.  Size is in words
 505 int MethodData::compute_allocation_size_in_words(methodHandle method) {
 506   int byte_size = compute_allocation_size_in_bytes(method);
 507   int word_size = align_size_up(byte_size, BytesPerWord) / BytesPerWord;
 508   return align_object_size(word_size);
 509 }
 510 
 511 // Initialize an individual data segment.  Returns the size of
 512 // the segment in bytes.
 513 int MethodData::initialize_data(BytecodeStream* stream,
 514                                        int data_index) {
 515 #if defined(COMPILER1) && !defined(COMPILER2)
 516   return 0;
 517 #endif
 518   int cell_count = -1;
 519   int tag = DataLayout::no_tag;
 520   DataLayout* data_layout = data_layout_at(data_index);
 521   Bytecodes::Code c = stream->code();
 522   switch (c) {
 523   case Bytecodes::_checkcast:
 524   case Bytecodes::_instanceof:
 525   case Bytecodes::_aastore:
 526     if (TypeProfileCasts) {
 527       cell_count = ReceiverTypeData::static_cell_count();
 528       tag = DataLayout::receiver_type_data_tag;
 529     } else {
 530       cell_count = BitData::static_cell_count();
 531       tag = DataLayout::bit_data_tag;
 532     }
 533     break;
 534   case Bytecodes::_invokespecial:
 535   case Bytecodes::_invokestatic:
 536     cell_count = CounterData::static_cell_count();
 537     tag = DataLayout::counter_data_tag;