hotspot/src/share/vm/code/relocInfo.cpp
changeset 9124 f60dee480d49
parent 8921 14bfe81f2a9d
parent 9111 c100c09c66f2
child 13728 882756847a04
equal deleted inserted replaced
9093:62b8e328f8c8 9124:f60dee480d49
   470   itr.set_current(ri);
   470   itr.set_current(ri);
   471   itr.reloc();
   471   itr.reloc();
   472   return itr._rh;
   472   return itr._rh;
   473 }
   473 }
   474 
   474 
   475 
       
   476 static inline bool is_index(intptr_t index) {
       
   477   return 0 < index && index < os::vm_page_size();
       
   478 }
       
   479 
       
   480 
       
   481 int32_t Relocation::runtime_address_to_index(address runtime_address) {
   475 int32_t Relocation::runtime_address_to_index(address runtime_address) {
   482   assert(!is_index((intptr_t)runtime_address), "must not look like an index");
   476   assert(!is_reloc_index((intptr_t)runtime_address), "must not look like an index");
   483 
   477 
   484   if (runtime_address == NULL)  return 0;
   478   if (runtime_address == NULL)  return 0;
   485 
   479 
   486   StubCodeDesc* p = StubCodeDesc::desc_for(runtime_address);
   480   StubCodeDesc* p = StubCodeDesc::desc_for(runtime_address);
   487   if (p != NULL && p->begin() == runtime_address) {
   481   if (p != NULL && p->begin() == runtime_address) {
   488     assert(is_index(p->index()), "there must not be too many stubs");
   482     assert(is_reloc_index(p->index()), "there must not be too many stubs");
   489     return (int32_t)p->index();
   483     return (int32_t)p->index();
   490   } else {
   484   } else {
   491     // Known "miscellaneous" non-stub pointers:
   485     // Known "miscellaneous" non-stub pointers:
   492     // os::get_polling_page(), SafepointSynchronize::address_of_state()
   486     // os::get_polling_page(), SafepointSynchronize::address_of_state()
   493     if (PrintRelocations) {
   487     if (PrintRelocations) {
   504 
   498 
   505 
   499 
   506 address Relocation::index_to_runtime_address(int32_t index) {
   500 address Relocation::index_to_runtime_address(int32_t index) {
   507   if (index == 0)  return NULL;
   501   if (index == 0)  return NULL;
   508 
   502 
   509   if (is_index(index)) {
   503   if (is_reloc_index(index)) {
   510     StubCodeDesc* p = StubCodeDesc::desc_for_index(index);
   504     StubCodeDesc* p = StubCodeDesc::desc_for_index(index);
   511     assert(p != NULL, "there must be a stub for this index");
   505     assert(p != NULL, "there must be a stub for this index");
   512     return p->begin();
   506     return p->begin();
   513   } else {
   507   } else {
   514 #ifndef _LP64
   508 #ifndef _LP64
   632   short* p = (short*) dest->locs_end();
   626   short* p = (short*) dest->locs_end();
   633   int32_t index = runtime_address_to_index(_target);
   627   int32_t index = runtime_address_to_index(_target);
   634 #ifndef _LP64
   628 #ifndef _LP64
   635   p = pack_1_int_to(p, index);
   629   p = pack_1_int_to(p, index);
   636 #else
   630 #else
   637   if (is_index(index)) {
   631   if (is_reloc_index(index)) {
   638     p = pack_2_ints_to(p, index, 0);
   632     p = pack_2_ints_to(p, index, 0);
   639   } else {
   633   } else {
   640     jlong t = (jlong) _target;
   634     jlong t = (jlong) _target;
   641     int32_t lo = low(t);
   635     int32_t lo = low(t);
   642     int32_t hi = high(t);
   636     int32_t hi = high(t);
   643     p = pack_2_ints_to(p, lo, hi);
   637     p = pack_2_ints_to(p, lo, hi);
   644     DEBUG_ONLY(jlong t1 = jlong_from(hi, lo));
   638     DEBUG_ONLY(jlong t1 = jlong_from(hi, lo));
   645     assert(!is_index(t1) && (address) t1 == _target, "not symmetric");
   639     assert(!is_reloc_index(t1) && (address) t1 == _target, "not symmetric");
   646   }
   640   }
   647 #endif /* _LP64 */
   641 #endif /* _LP64 */
   648   dest->set_locs_end((relocInfo*) p);
   642   dest->set_locs_end((relocInfo*) p);
   649 }
   643 }
   650 
   644 
   654   _target = index_to_runtime_address(unpack_1_int());
   648   _target = index_to_runtime_address(unpack_1_int());
   655 #else
   649 #else
   656   int32_t lo, hi;
   650   int32_t lo, hi;
   657   unpack_2_ints(lo, hi);
   651   unpack_2_ints(lo, hi);
   658   jlong t = jlong_from(hi, lo);;
   652   jlong t = jlong_from(hi, lo);;
   659   if (is_index(t)) {
   653   if (is_reloc_index(t)) {
   660     _target = index_to_runtime_address(t);
   654     _target = index_to_runtime_address(t);
   661   } else {
   655   } else {
   662     _target = (address) t;
   656     _target = (address) t;
   663   }
   657   }
   664 #endif /* _LP64 */
   658 #endif /* _LP64 */