hotspot/src/share/vm/code/codeBlob.cpp
changeset 5702 201c5cde25bb
parent 5547 f4b087cbb361
parent 5686 5435e77aa3df
child 5924 dc9d04930c82
equal deleted inserted replaced
5685:0e4c848d5c06 5702:201c5cde25bb
    64   _frame_complete_offset = frame_complete;
    64   _frame_complete_offset = frame_complete;
    65   _header_size           = header_size;
    65   _header_size           = header_size;
    66   _relocation_size       = locs_size;
    66   _relocation_size       = locs_size;
    67   _instructions_offset   = align_code_offset(header_size + locs_size);
    67   _instructions_offset   = align_code_offset(header_size + locs_size);
    68   _data_offset           = size;
    68   _data_offset           = size;
    69   _oops_offset           = size;
       
    70   _oops_length           =  0;
       
    71   _frame_size            =  0;
    69   _frame_size            =  0;
    72   set_oop_maps(NULL);
    70   set_oop_maps(NULL);
    73 }
    71 }
    74 
    72 
    75 
    73 
    92   _frame_complete_offset = frame_complete;
    90   _frame_complete_offset = frame_complete;
    93   _header_size           = header_size;
    91   _header_size           = header_size;
    94   _relocation_size       = round_to(cb->total_relocation_size(), oopSize);
    92   _relocation_size       = round_to(cb->total_relocation_size(), oopSize);
    95   _instructions_offset   = align_code_offset(header_size + _relocation_size);
    93   _instructions_offset   = align_code_offset(header_size + _relocation_size);
    96   _data_offset           = _instructions_offset + round_to(cb->total_code_size(), oopSize);
    94   _data_offset           = _instructions_offset + round_to(cb->total_code_size(), oopSize);
    97   _oops_offset           = _size - round_to(cb->total_oop_size(), oopSize);
       
    98   _oops_length           = 0;  // temporary, until the copy_oops handshake
       
    99   assert(_oops_offset >=   _data_offset, "codeBlob is too small");
       
   100   assert(_data_offset <= size, "codeBlob is too small");
    95   assert(_data_offset <= size, "codeBlob is too small");
   101 
    96 
   102   cb->copy_code_and_locs_to(this);
    97   cb->copy_code_and_locs_to(this);
   103   set_oop_maps(oop_maps);
    98   set_oop_maps(oop_maps);
   104   _frame_size = frame_size;
    99   _frame_size = frame_size;
   128     _oop_maps = NULL;
   123     _oop_maps = NULL;
   129   }
   124   }
   130   _comments.free();
   125   _comments.free();
   131 }
   126 }
   132 
   127 
   133 
       
   134 // Promote one word from an assembly-time handle to a live embedded oop.
       
   135 inline void CodeBlob::initialize_immediate_oop(oop* dest, jobject handle) {
       
   136   if (handle == NULL ||
       
   137       // As a special case, IC oops are initialized to 1 or -1.
       
   138       handle == (jobject) Universe::non_oop_word()) {
       
   139     (*dest) = (oop)handle;
       
   140   } else {
       
   141     (*dest) = JNIHandles::resolve_non_null(handle);
       
   142   }
       
   143 }
       
   144 
       
   145 
       
   146 void CodeBlob::copy_oops(GrowableArray<jobject>* array) {
       
   147   assert(_oops_length == 0, "do this handshake just once, please");
       
   148   int length = array->length();
       
   149   assert((address)(oops_begin() + length) <= data_end(), "oops big enough");
       
   150   oop* dest = oops_begin();
       
   151   for (int index = 0 ; index < length; index++) {
       
   152     initialize_immediate_oop(&dest[index], array->at(index));
       
   153   }
       
   154   _oops_length = length;
       
   155 
       
   156   // Now we can fix up all the oops in the code.
       
   157   // We need to do this in the code because
       
   158   // the assembler uses jobjects as placeholders.
       
   159   // The code and relocations have already been
       
   160   // initialized by the CodeBlob constructor,
       
   161   // so it is valid even at this early point to
       
   162   // iterate over relocations and patch the code.
       
   163   fix_oop_relocations(NULL, NULL, /*initialize_immediates=*/ true);
       
   164 }
       
   165 
       
   166 
       
   167 relocInfo::relocType CodeBlob::reloc_type_for_address(address pc) {
       
   168   RelocIterator iter(this, pc, pc+1);
       
   169   while (iter.next()) {
       
   170     return (relocInfo::relocType) iter.type();
       
   171   }
       
   172   // No relocation info found for pc
       
   173   ShouldNotReachHere();
       
   174   return relocInfo::none; // dummy return value
       
   175 }
       
   176 
       
   177 
       
   178 bool CodeBlob::is_at_poll_return(address pc) {
       
   179   RelocIterator iter(this, pc, pc+1);
       
   180   while (iter.next()) {
       
   181     if (iter.type() == relocInfo::poll_return_type)
       
   182       return true;
       
   183   }
       
   184   return false;
       
   185 }
       
   186 
       
   187 
       
   188 bool CodeBlob::is_at_poll_or_poll_return(address pc) {
       
   189   RelocIterator iter(this, pc, pc+1);
       
   190   while (iter.next()) {
       
   191     relocInfo::relocType t = iter.type();
       
   192     if (t == relocInfo::poll_return_type || t == relocInfo::poll_type)
       
   193       return true;
       
   194   }
       
   195   return false;
       
   196 }
       
   197 
       
   198 
       
   199 void CodeBlob::fix_oop_relocations(address begin, address end,
       
   200                                    bool initialize_immediates) {
       
   201   // re-patch all oop-bearing instructions, just in case some oops moved
       
   202   RelocIterator iter(this, begin, end);
       
   203   while (iter.next()) {
       
   204     if (iter.type() == relocInfo::oop_type) {
       
   205       oop_Relocation* reloc = iter.oop_reloc();
       
   206       if (initialize_immediates && reloc->oop_is_immediate()) {
       
   207         oop* dest = reloc->oop_addr();
       
   208         initialize_immediate_oop(dest, (jobject) *dest);
       
   209       }
       
   210       // Refresh the oop-related bits of this instruction.
       
   211       reloc->fix_oop_relocation();
       
   212     }
       
   213 
       
   214     // There must not be any interfering patches or breakpoints.
       
   215     assert(!(iter.type() == relocInfo::breakpoint_type
       
   216              && iter.breakpoint_reloc()->active()),
       
   217            "no active breakpoint");
       
   218   }
       
   219 }
       
   220 
       
   221 void CodeBlob::do_unloading(BoolObjectClosure* is_alive,
       
   222                             OopClosure* keep_alive,
       
   223                             bool unloading_occurred) {
       
   224   ShouldNotReachHere();
       
   225 }
       
   226 
   128 
   227 OopMap* CodeBlob::oop_map_for_return_address(address return_address) {
   129 OopMap* CodeBlob::oop_map_for_return_address(address return_address) {
   228   address pc = return_address ;
   130   address pc = return_address ;
   229   assert (oop_maps() != NULL, "nope");
   131   assert (oop_maps() != NULL, "nope");
   230   return oop_maps()->find_map_at_offset ((intptr_t) pc - (intptr_t) instructions_begin());
   132   return oop_maps()->find_map_at_offset ((intptr_t) pc - (intptr_t) instructions_begin());