src/share/vm/compiler/oopMap.cpp

Wed, 02 Apr 2008 12:09:59 -0700

author
jrose
date
Wed, 02 Apr 2008 12:09:59 -0700
changeset 535
c7c777385a15
parent 460
c5cbd367e4d1
child 548
ba764ed4b6f2
permissions
-rw-r--r--

6667042: PrintAssembly option does not work without special plugin
Summary: remove old private plugin interface, simplify, rework old plugin to use unchanged Gnu sources
Reviewed-by: kvn, rasbold

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

mercurial