1 #ifdef USE_PRAGMA_IDENT_SRC
   2 #pragma ident "@(#)oopMap.cpp   1.153 07/09/28 10:23:20 JVM"
   3 #endif
   4 /*
   5  * Copyright 1998-2007 Sun Microsystems, Inc.  All Rights Reserved.
   6  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   7  *
   8  * This code is free software; you can redistribute it and/or modify it
   9  * under the terms of the GNU General Public License version 2 only, as
  10  * published by the Free Software Foundation.
  11  *
  12  * This code is distributed in the hope that it will be useful, but WITHOUT
  13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  15  * version 2 for more details (a copy is included in the LICENSE file that
  16  * accompanied this code).
  17  *
  18  * You should have received a copy of the GNU General Public License version
  19  * 2 along with this work; if not, write to the Free Software Foundation,
  20  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  21  *
  22  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  23  * CA 95054 USA or visit www.sun.com if you need additional information or
  24  * have any questions.
  25  *  
  26  */
  27 
  28 # include "incls/_precompiled.incl"
  29 # include "incls/_oopMap.cpp.incl"
  30 
  31 // OopMapStream
  32 
  33 OopMapStream::OopMapStream(OopMap* oop_map) {
  34   if(oop_map->omv_data() == NULL) {
  35     _stream = new CompressedReadStream(oop_map->write_stream()->buffer());
  36   } else {
  37     _stream = new CompressedReadStream(oop_map->omv_data());
  38   }
  39   _mask = OopMapValue::type_mask_in_place;
  40   _size = oop_map->omv_count();
  41   _position = 0;
  42   _valid_omv = false;
  43 }
  44 
  45 
  46 OopMapStream::OopMapStream(OopMap* oop_map, int oop_types_mask) {
  47   if(oop_map->omv_data() == NULL) {
  48     _stream = new CompressedReadStream(oop_map->write_stream()->buffer());
  49   } else {
  50     _stream = new CompressedReadStream(oop_map->omv_data());
  51   }
  52   _mask = oop_types_mask;
  53   _size = oop_map->omv_count();
  54   _position = 0;
  55   _valid_omv = false;
  56 }
  57 
  58 
  59 void OopMapStream::find_next() {
  60   while(_position++ < _size) {
  61     _omv.read_from(_stream);
  62     if(((int)_omv.type() & _mask) > 0) {
  63       _valid_omv = true;
  64       return;
  65     }
  66   }
  67   _valid_omv = false;
  68 }
  69 
  70 
  71 // OopMap
  72 
  73 // frame_size units are stack-slots (4 bytes) NOT intptr_t; we can name odd
  74 // slots to hold 4-byte values like ints and floats in the LP64 build.
  75 OopMap::OopMap(int frame_size, int arg_count) {
  76   // OopMaps are usually quite so small, so pick a small initial size
  77   set_write_stream(new CompressedWriteStream(32));
  78   set_omv_data(NULL);
  79   set_omv_count(0);
  80 
  81 #ifdef ASSERT  
  82   _locs_length = VMRegImpl::stack2reg(0)->value() + frame_size + arg_count;
  83   _locs_used   = NEW_RESOURCE_ARRAY(OopMapValue::oop_types, _locs_length);
  84   for(int i = 0; i < _locs_length; i++) _locs_used[i] = OopMapValue::unused_value;
  85 #endif
  86 }
  87 
  88 
  89 OopMap::OopMap(OopMap::DeepCopyToken, OopMap* source) {
  90   // This constructor does a deep copy
  91   // of the source OopMap.
  92   set_write_stream(new CompressedWriteStream(source->omv_count() * 2));
  93   set_omv_data(NULL);
  94   set_omv_count(0);
  95   set_offset(source->offset());
  96 
  97 #ifdef ASSERT  
  98   _locs_length = source->_locs_length;
  99   _locs_used = NEW_RESOURCE_ARRAY(OopMapValue::oop_types, _locs_length);
 100   for(int i = 0; i < _locs_length; i++) _locs_used[i] = OopMapValue::unused_value;
 101 #endif
 102 
 103   // We need to copy the entries too.
 104   for (OopMapStream oms(source); !oms.is_done(); oms.next()) {
 105     OopMapValue omv = oms.current();
 106     omv.write_on(write_stream());
 107     increment_count();
 108   }
 109 }
 110 
 111 
 112 OopMap* OopMap::deep_copy() {
 113   return new OopMap(_deep_copy_token, this);
 114 }
 115 
 116 
 117 void OopMap::copy_to(address addr) {
 118   memcpy(addr,this,sizeof(OopMap));
 119   memcpy(addr + sizeof(OopMap),write_stream()->buffer(),write_stream()->position());
 120   OopMap* new_oop = (OopMap*)addr;
 121   new_oop->set_omv_data_size(write_stream()->position());
 122   new_oop->set_omv_data((unsigned char *)(addr + sizeof(OopMap)));
 123   new_oop->set_write_stream(NULL);
 124 }
 125 
 126 
 127 int OopMap::heap_size() const {
 128   int size = sizeof(OopMap);
 129   int align = sizeof(void *) - 1;
 130   if(write_stream() != NULL) {
 131     size += write_stream()->position();
 132   } else {
 133     size += omv_data_size();
 134   }
 135   // Align to a reasonable ending point
 136   size = ((size+align) & ~align);
 137   return size;
 138 }
 139 
 140 // frame_size units are stack-slots (4 bytes) NOT intptr_t; we can name odd
 141 // slots to hold 4-byte values like ints and floats in the LP64 build.
 142 void OopMap::set_xxx(VMReg reg, OopMapValue::oop_types x, VMReg optional) {
 143   
 144   assert(reg->value() < _locs_length, "too big reg value for stack size");
 145   assert( _locs_used[reg->value()] == OopMapValue::unused_value, "cannot insert twice" );
 146   debug_only( _locs_used[reg->value()] = x; )
 147 
 148   OopMapValue o(reg, x);
 149 
 150   if(x == OopMapValue::callee_saved_value) {
 151     // This can never be a stack location, so we don't need to transform it.
 152     assert(optional->is_reg(), "Trying to callee save a stack location");
 153     o.set_content_reg(optional);
 154   } else if(x == OopMapValue::derived_oop_value) {
 155     o.set_content_reg(optional);
 156   }
 157 
 158   o.write_on(write_stream());
 159   increment_count();
 160 }
 161 
 162 
 163 void OopMap::set_oop(VMReg reg) {
 164   set_xxx(reg, OopMapValue::oop_value, VMRegImpl::Bad());
 165 }
 166 
 167 
 168 void OopMap::set_value(VMReg reg) {
 169   // At this time, we only need value entries in our OopMap when ZapDeadCompiledLocals is active.
 170   if (ZapDeadCompiledLocals)
 171     set_xxx(reg, OopMapValue::value_value, VMRegImpl::Bad());
 172 }
 173 
 174 
 175 void OopMap::set_dead(VMReg reg) {
 176   // At this time, we only need dead entries in our OopMap when ZapDeadCompiledLocals is active.
 177   if (ZapDeadCompiledLocals) {
 178     set_xxx(reg, OopMapValue::dead_value, VMRegImpl::Bad());
 179   }
 180 }
 181 
 182 
 183 void OopMap::set_callee_saved(VMReg reg, VMReg caller_machine_register ) {
 184   set_xxx(reg, OopMapValue::callee_saved_value, caller_machine_register);
 185 }
 186 
 187 
 188 void OopMap::set_derived_oop(VMReg reg, VMReg derived_from_local_register ) {
 189   if( reg == derived_from_local_register ) {
 190     // Actually an oop, derived shares storage with base, 
 191     set_oop(reg);
 192   } else {
 193     set_xxx(reg, OopMapValue::derived_oop_value, derived_from_local_register);
 194   }
 195 }
 196 
 197 void OopMap::set_stack_obj(VMReg reg) {
 198   set_xxx(reg, OopMapValue::stack_obj, VMRegImpl::Bad());
 199 }
 200 
 201 // OopMapSet
 202 
 203 OopMapSet::OopMapSet() {
 204   set_om_size(MinOopMapAllocation);
 205   set_om_count(0);
 206   OopMap** temp = NEW_RESOURCE_ARRAY(OopMap*, om_size());
 207   set_om_data(temp);
 208 }
 209 
 210 
 211 void OopMapSet::grow_om_data() {  
 212   int new_size = om_size() * 2;
 213   OopMap** new_data = NEW_RESOURCE_ARRAY(OopMap*, new_size);
 214   memcpy(new_data,om_data(),om_size() * sizeof(OopMap*));
 215   set_om_size(new_size);
 216   set_om_data(new_data);
 217 }
 218 
 219 
 220 void OopMapSet::copy_to(address addr) {
 221   address temp = addr;
 222   int align = sizeof(void *) - 1;
 223   // Copy this
 224   memcpy(addr,this,sizeof(OopMapSet));
 225   temp += sizeof(OopMapSet);
 226   temp = (address)((intptr_t)(temp + align) & ~align);
 227   // Do the needed fixups to the new OopMapSet
 228   OopMapSet* new_set = (OopMapSet*)addr;
 229   new_set->set_om_data((OopMap**)temp);
 230   // Allow enough space for the OopMap pointers
 231   temp += (om_count() * sizeof(OopMap*));
 232 
 233   for(int i=0; i < om_count(); i++) {
 234     OopMap* map = at(i);
 235     map->copy_to((address)temp);
 236     new_set->set(i,(OopMap*)temp);
 237     temp += map->heap_size();
 238   }
 239   // This "locks" the OopMapSet
 240   new_set->set_om_size(-1);
 241 }
 242 
 243 
 244 void OopMapSet::add_gc_map(int pc_offset, OopMap *map ) {
 245   assert(om_size() != -1,"Cannot grow a fixed OopMapSet");
 246 
 247   if(om_count() >= om_size()) {
 248     grow_om_data();
 249   }
 250   map->set_offset(pc_offset);
 251 
 252 #ifdef ASSERT
 253   if(om_count() > 0) {
 254     OopMap* last = at(om_count()-1);
 255     if (last->offset() == map->offset() ) {
 256       fatal("OopMap inserted twice");
 257     }
 258     if(last->offset() > map->offset()) {
 259       tty->print_cr( "WARNING, maps not sorted: pc[%d]=%d, pc[%d]=%d",
 260                       om_count(),last->offset(),om_count()+1,map->offset());
 261     }
 262   }
 263 #endif // ASSERT
 264 
 265   set(om_count(),map);
 266   increment_count();
 267 }
 268 
 269 
 270 int OopMapSet::heap_size() const {
 271   // The space we use
 272   int size = sizeof(OopMap);
 273   int align = sizeof(void *) - 1;
 274   size = ((size+align) & ~align);
 275   size += om_count() * sizeof(OopMap*);
 276 
 277   // Now add in the space needed for the indivdiual OopMaps
 278   for(int i=0; i < om_count(); i++) {
 279     size += at(i)->heap_size();
 280   }
 281   // We don't need to align this, it will be naturally pointer aligned
 282   return size;
 283 }
 284 
 285 
 286 OopMap* OopMapSet::singular_oop_map() {
 287   guarantee(om_count() == 1, "Make sure we only have a single gc point");
 288   return at(0);
 289 }
 290 
 291 
 292 OopMap* OopMapSet::find_map_at_offset(int pc_offset) const {
 293   int i, len = om_count();
 294   assert( len > 0, "must have pointer maps" );
 295 
 296   // Scan through oopmaps. Stop when current offset is either equal or greater
 297   // than the one we are looking for.
 298   for( i = 0; i < len; i++) {
 299     if( at(i)->offset() >= pc_offset )
 300       break;
 301   }
 302   
 303   assert( i < len, "oopmap not found" );
 304 
 305   OopMap* m = at(i);
 306   assert( m->offset() == pc_offset, "oopmap not found" );
 307   return m;
 308 }
 309 
 310 class DoNothingClosure: public OopClosure {
 311 public: void do_oop(oop* p) {}
 312 };
 313 static DoNothingClosure do_nothing;
 314 
 315 static void add_derived_oop(oop* base, oop* derived) {
 316 #ifndef TIERED
 317   COMPILER1_PRESENT(ShouldNotReachHere();)
 318 #endif // TIERED
 319 #ifdef COMPILER2
 320   DerivedPointerTable::add(derived, base);
 321 #endif // COMPILER2
 322 }
 323 
 324 
 325 #ifndef PRODUCT
 326 static void trace_codeblob_maps(const frame *fr, const RegisterMap *reg_map) {
 327   // Print oopmap and regmap
 328   tty->print_cr("------ ");
 329   CodeBlob* cb = fr->cb();
 330   OopMapSet* maps = cb->oop_maps();
 331   OopMap* map = cb->oop_map_for_return_address(fr->pc());
 332   map->print();
 333   if( cb->is_nmethod() ) {
 334     nmethod* nm = (nmethod*)cb;            
 335     // native wrappers have no scope data, it is implied
 336     if (nm->is_native_method()) {
 337       tty->print("bci: 0 (native)");
 338     } else {
 339       ScopeDesc* scope  = nm->scope_desc_at(fr->pc());
 340       tty->print("bci: %d ",scope->bci());
 341     }
 342   }
 343   tty->cr();
 344   fr->print_on(tty);   
 345   tty->print("     "); 
 346   cb->print_value_on(tty);  tty->cr();
 347   reg_map->print();
 348   tty->print_cr("------ ");
 349   
 350 }
 351 #endif // PRODUCT
 352 
 353 void OopMapSet::oops_do(const frame *fr, const RegisterMap* reg_map, OopClosure* f) {
 354   // add derived oops to a table
 355   all_do(fr, reg_map, f, add_derived_oop, &do_nothing, &do_nothing);
 356 }
 357 
 358 
 359 void OopMapSet::all_do(const frame *fr, const RegisterMap *reg_map, 
 360                        OopClosure* oop_fn, void derived_oop_fn(oop*, oop*),
 361                        OopClosure* value_fn, OopClosure* dead_fn) {    
 362   CodeBlob* cb = fr->cb();
 363   { 
 364     assert(cb != NULL, "no codeblob");      
 365   }  
 366 
 367   NOT_PRODUCT(if (TraceCodeBlobStacks) trace_codeblob_maps(fr, reg_map);)
 368 
 369   OopMapSet* maps = cb->oop_maps();
 370   OopMap* map  = cb->oop_map_for_return_address(fr->pc());
 371   assert(map != NULL, " no ptr map found");   
 372   
 373   // handle derived pointers first (otherwise base pointer may be
 374   // changed before derived pointer offset has been collected)
 375   OopMapValue omv;
 376   {    
 377     OopMapStream oms(map,OopMapValue::derived_oop_value);
 378     if (!oms.is_done()) {
 379 #ifndef TIERED
 380       COMPILER1_PRESENT(ShouldNotReachHere();)
 381 #endif // !TIERED
 382       // Protect the operation on the derived pointers.  This
 383       // protects the addition of derived pointers to the shared 
 384       // derived pointer table in DerivedPointerTable::add().
 385       MutexLockerEx x(DerivedPointerTableGC_lock, Mutex::_no_safepoint_check_flag);
 386       do {
 387         omv = oms.current();
 388         oop* loc = fr->oopmapreg_to_location(omv.reg(),reg_map);
 389         if ( loc != NULL ) {
 390           oop *base_loc    = fr->oopmapreg_to_location(omv.content_reg(), reg_map);
 391           oop *derived_loc = loc;
 392           derived_oop_fn(base_loc, derived_loc); 
 393         }
 394         oms.next();
 395       }  while (!oms.is_done()); 
 396     }
 397   }
 398 
 399   // We want dead, value and oop oop_types
 400   int mask = OopMapValue::oop_value | OopMapValue::value_value | OopMapValue::dead_value;
 401   {
 402     for (OopMapStream oms(map,mask); !oms.is_done(); oms.next()) {
 403       omv = oms.current();
 404       oop* loc = fr->oopmapreg_to_location(omv.reg(),reg_map);
 405       if ( loc != NULL ) {
 406         if ( omv.type() == OopMapValue::oop_value ) {
 407 #ifdef ASSERT
 408           if (COMPILER2_PRESENT(!DoEscapeAnalysis &&) !Universe::heap()->is_in_or_null(*loc)) {
 409             tty->print_cr("# Found non oop pointer.  Dumping state at failure");
 410             // try to dump out some helpful debugging information
 411             trace_codeblob_maps(fr, reg_map);
 412             omv.print();
 413             tty->print_cr("loc = %p *loc = %p\n", loc, (address)*loc);
 414             // do the real assert.
 415             assert(Universe::heap()->is_in_or_null(*loc), "found non oop pointer");
 416           }
 417 #endif // ASSERT
 418           oop_fn->do_oop(loc);
 419         } else if ( omv.type() == OopMapValue::value_value ) {
 420           value_fn->do_oop(loc);
 421         } else if ( omv.type() == OopMapValue::dead_value ) {
 422           dead_fn->do_oop(loc);
 423         }
 424       }
 425     }
 426   }
 427 
 428 #ifdef COMPILER2
 429   if (DoEscapeAnalysis) {
 430     for (OopMapStream oms(map, OopMapValue::stack_obj); !oms.is_done(); oms.next()) {
 431       omv = oms.current();
 432       assert(omv.is_stack_loc(), "should refer to stack location");
 433       oop loc = (oop) fr->oopmapreg_to_location(omv.reg(),reg_map);
 434       oop_fn->do_oop(&loc);
 435     }
 436   }
 437 #endif // COMPILER2
 438 }
 439 
 440 
 441 // Update callee-saved register info for the following frame
 442 void OopMapSet::update_register_map(const frame *fr, RegisterMap *reg_map) {
 443   ResourceMark rm;
 444   CodeBlob* cb = fr->cb();
 445   assert(cb != NULL, "no codeblob");
 446 
 447   // Any reg might be saved by a safepoint handler (see generate_handler_blob).
 448   const int max_saved_on_entry_reg_count = ConcreteRegisterImpl::number_of_registers;
 449   assert( reg_map->_update_for_id == NULL || fr->is_older(reg_map->_update_for_id),
 450          "already updated this map; do not 'update' it twice!" );
 451   debug_only(reg_map->_update_for_id = fr->id());
 452 
 453   // Check if caller must update oop argument  
 454   assert((reg_map->include_argument_oops() || 
 455           !cb->caller_must_gc_arguments(reg_map->thread())), 
 456          "include_argument_oops should already be set");
 457 
 458   int nof_callee = 0;
 459   oop*        locs[2*max_saved_on_entry_reg_count+1]; 
 460   VMReg regs[2*max_saved_on_entry_reg_count+1]; 
 461   // ("+1" because max_saved_on_entry_reg_count might be zero)
 462 
 463   // Scan through oopmap and find location of all callee-saved registers
 464   // (we do not do update in place, since info could be overwritten)
 465 
 466   address pc = fr->pc();
 467 
 468   OopMap* map  = cb->oop_map_for_return_address(pc);
 469 
 470   assert(map != NULL, " no ptr map found"); 
 471 
 472   OopMapValue omv;
 473   for(OopMapStream oms(map,OopMapValue::callee_saved_value); !oms.is_done(); oms.next()) {
 474     omv = oms.current();
 475     assert(nof_callee < 2*max_saved_on_entry_reg_count, "overflow");
 476     regs[nof_callee] = omv.content_reg();
 477     locs[nof_callee] = fr->oopmapreg_to_location(omv.reg(),reg_map);
 478     nof_callee++;
 479   }
 480 
 481   // Check that runtime stubs save all callee-saved registers
 482 #ifdef COMPILER2
 483   assert(cb->is_compiled_by_c1() || !cb->is_runtime_stub() || 
 484          (nof_callee >= SAVED_ON_ENTRY_REG_COUNT || nof_callee >= C_SAVED_ON_ENTRY_REG_COUNT),
 485          "must save all");
 486 #endif // COMPILER2
 487 
 488   // Copy found callee-saved register to reg_map
 489   for(int i = 0; i < nof_callee; i++) {
 490     reg_map->set_location(regs[i], (address)locs[i]);
 491   }
 492 }
 493 
 494 //=============================================================================
 495 // Non-Product code
 496 
 497 #ifndef PRODUCT
 498 
 499 bool OopMap::has_derived_pointer() const {
 500 #ifndef TIERED
 501   COMPILER1_PRESENT(return false);
 502 #endif // !TIERED
 503 #ifdef COMPILER2
 504   OopMapStream oms((OopMap*)this,OopMapValue::derived_oop_value);
 505   return oms.is_done();
 506 #else
 507   return false;
 508 #endif // COMPILER2
 509 }
 510 
 511 
 512 void print_register_type(OopMapValue::oop_types x, VMReg optional) {
 513   switch( x ) {
 514   case OopMapValue::oop_value:
 515     tty->print("Oop");
 516     break;
 517   case OopMapValue::value_value:
 518     tty->print("Value" );
 519     break;
 520   case OopMapValue::dead_value:
 521     tty->print("Dead" );
 522     break;
 523   case OopMapValue::callee_saved_value:
 524     tty->print("Callers_" );
 525     optional->print();
 526     break;
 527   case OopMapValue::derived_oop_value:
 528     tty->print("Derived_oop_" );
 529     optional->print();
 530     break;
 531   case OopMapValue::stack_obj:
 532     tty->print("Stack");
 533     break;
 534   default:
 535     ShouldNotReachHere();
 536   }
 537 }
 538 
 539 
 540 void OopMapValue::print() const {
 541   reg()->print();
 542   tty->print("=");
 543   print_register_type(type(),content_reg());
 544   tty->print(" ");
 545 }
 546 
 547 
 548 void OopMap::print_on(outputStream* st) const {
 549   OopMapValue omv;
 550   for(OopMapStream oms((OopMap*)this); !oms.is_done(); oms.next()) {
 551     omv = oms.current();
 552     omv.print_on(st);
 553   }
 554 }
 555 
 556 
 557 void OopMapSet::print_on(outputStream* st) const {
 558   int i, len = om_count();
 559 
 560   st->print_cr("OopMapSet contains %d OopMaps\n",len);
 561   
 562   for( i = 0; i < len; i++) {
 563     OopMap* m = at(i);
 564     st->print_cr("OopMap #%d offset:%p",i,m->offset());
 565     m->print_on(st);
 566     st->print_cr("\n");
 567   }
 568 }
 569 #endif // !PRODUCT
 570 
 571 
 572 //------------------------------DerivedPointerTable---------------------------
 573 
 574 #ifdef COMPILER2
 575 
 576 class DerivedPointerEntry : public CHeapObj {
 577  private:
 578   oop*     _location; // Location of derived pointer (also pointing to the base)
 579   intptr_t _offset;   // Offset from base pointer   
 580  public:
 581   DerivedPointerEntry(oop* location, intptr_t offset) { _location = location; _offset = offset; }
 582   oop* location()    { return _location; }
 583   intptr_t  offset() { return _offset; }
 584 };
 585 
 586 
 587 GrowableArray<DerivedPointerEntry*>* DerivedPointerTable::_list = NULL;
 588 bool DerivedPointerTable::_active = false;
 589 
 590 
 591 void DerivedPointerTable::clear() {
 592   // The first time, we create the list.  Otherwise it should be
 593   // empty.  If not, then we have probably forgotton to call
 594   // update_pointers after last GC/Scavenge.
 595   assert (!_active, "should not be active");
 596   assert(_list == NULL || _list->length() == 0, "table not empty");
 597   if (_list == NULL) {
 598     _list = new (ResourceObj::C_HEAP) GrowableArray<DerivedPointerEntry*>(10, true); // Allocated on C heap
 599   }
 600   _active = true;
 601 }
 602 
 603 
 604 // Returns value of location as an int
 605 intptr_t value_of_loc(oop *pointer) { return (intptr_t)(*pointer); }
 606 
 607 
 608 void DerivedPointerTable::add(oop *derived_loc, oop *base_loc) {      
 609   assert(Universe::heap()->is_in_or_null(*base_loc), "not an oop");  
 610   assert(derived_loc != base_loc, "Base and derived in same location");
 611   if (_active) {
 612     assert(*derived_loc != (oop)base_loc, "location already added");    
 613     assert(_list != NULL, "list must exist");
 614     intptr_t offset = value_of_loc(derived_loc) - value_of_loc(base_loc);
 615     assert(offset >= -1000000, "wrong derived pointer info");
 616 
 617     if (TraceDerivedPointers) {
 618       tty->print_cr(
 619         "Add derived pointer@" INTPTR_FORMAT 
 620         " - Derived: " INTPTR_FORMAT 
 621         " Base: " INTPTR_FORMAT " (@" INTPTR_FORMAT ") (Offset: %d)", 
 622         derived_loc, (address)*derived_loc, (address)*base_loc, base_loc, offset
 623       );
 624     }    
 625     // Set derived oop location to point to base.
 626     *derived_loc = (oop)base_loc;  
 627     assert_lock_strong(DerivedPointerTableGC_lock);
 628     DerivedPointerEntry *entry = new DerivedPointerEntry(derived_loc, offset);
 629     _list->append(entry);    
 630   }
 631 }
 632 
 633 
 634 void DerivedPointerTable::update_pointers() {  
 635   assert(_list != NULL, "list must exist");
 636   for(int i = 0; i < _list->length(); i++) {
 637     DerivedPointerEntry* entry = _list->at(i);
 638     oop* derived_loc = entry->location();
 639     intptr_t offset  = entry->offset();
 640     // The derived oop was setup to point to location of base
 641     oop  base        = **(oop**)derived_loc; 
 642     assert(Universe::heap()->is_in_or_null(base), "must be an oop");
 643     
 644     *derived_loc = (oop)(((address)base) + offset);
 645     assert(value_of_loc(derived_loc) - value_of_loc(&base) == offset, "sanity check");
 646 
 647     if (TraceDerivedPointers) {
 648       tty->print_cr("Updating derived pointer@" INTPTR_FORMAT 
 649                     " - Derived: " INTPTR_FORMAT "  Base: " INTPTR_FORMAT " (Offset: %d)",
 650           derived_loc, (address)*derived_loc, (address)base, offset);
 651     }
 652 
 653     // Delete entry
 654     delete entry;
 655     _list->at_put(i, NULL);
 656   }
 657   // Clear list, so it is ready for next traversal (this is an invariant)
 658   if (TraceDerivedPointers && !_list->is_empty()) {
 659     tty->print_cr("--------------------------");
 660   }
 661   _list->clear();
 662   _active = false;
 663 }
 664 
 665 #endif // COMPILER2