src/share/vm/compiler/oopMap.cpp

Wed, 02 Jul 2008 12:55:16 -0700

author
xdono
date
Wed, 02 Jul 2008 12:55:16 -0700
changeset 631
d1605aabd0a1
parent 548
ba764ed4b6f2
child 680
4a4c365f777d
permissions
-rw-r--r--

6719955: Update copyright year
Summary: Update copyright year for files that have been modified in 2008
Reviewed-by: ohair, tbell

     1 /*
     2  * Copyright 1998-2008 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_narrowoop(VMReg reg) {
   173   set_xxx(reg, OopMapValue::narrowoop_value, VMRegImpl::Bad());
   174 }
   177 void OopMap::set_callee_saved(VMReg reg, VMReg caller_machine_register ) {
   178   set_xxx(reg, OopMapValue::callee_saved_value, caller_machine_register);
   179 }
   182 void OopMap::set_derived_oop(VMReg reg, VMReg derived_from_local_register ) {
   183   if( reg == derived_from_local_register ) {
   184     // Actually an oop, derived shares storage with base,
   185     set_oop(reg);
   186   } else {
   187     set_xxx(reg, OopMapValue::derived_oop_value, derived_from_local_register);
   188   }
   189 }
   191 void OopMap::set_stack_obj(VMReg reg) {
   192   set_xxx(reg, OopMapValue::stack_obj, VMRegImpl::Bad());
   193 }
   195 // OopMapSet
   197 OopMapSet::OopMapSet() {
   198   set_om_size(MinOopMapAllocation);
   199   set_om_count(0);
   200   OopMap** temp = NEW_RESOURCE_ARRAY(OopMap*, om_size());
   201   set_om_data(temp);
   202 }
   205 void OopMapSet::grow_om_data() {
   206   int new_size = om_size() * 2;
   207   OopMap** new_data = NEW_RESOURCE_ARRAY(OopMap*, new_size);
   208   memcpy(new_data,om_data(),om_size() * sizeof(OopMap*));
   209   set_om_size(new_size);
   210   set_om_data(new_data);
   211 }
   214 void OopMapSet::copy_to(address addr) {
   215   address temp = addr;
   216   int align = sizeof(void *) - 1;
   217   // Copy this
   218   memcpy(addr,this,sizeof(OopMapSet));
   219   temp += sizeof(OopMapSet);
   220   temp = (address)((intptr_t)(temp + align) & ~align);
   221   // Do the needed fixups to the new OopMapSet
   222   OopMapSet* new_set = (OopMapSet*)addr;
   223   new_set->set_om_data((OopMap**)temp);
   224   // Allow enough space for the OopMap pointers
   225   temp += (om_count() * sizeof(OopMap*));
   227   for(int i=0; i < om_count(); i++) {
   228     OopMap* map = at(i);
   229     map->copy_to((address)temp);
   230     new_set->set(i,(OopMap*)temp);
   231     temp += map->heap_size();
   232   }
   233   // This "locks" the OopMapSet
   234   new_set->set_om_size(-1);
   235 }
   238 void OopMapSet::add_gc_map(int pc_offset, OopMap *map ) {
   239   assert(om_size() != -1,"Cannot grow a fixed OopMapSet");
   241   if(om_count() >= om_size()) {
   242     grow_om_data();
   243   }
   244   map->set_offset(pc_offset);
   246 #ifdef ASSERT
   247   if(om_count() > 0) {
   248     OopMap* last = at(om_count()-1);
   249     if (last->offset() == map->offset() ) {
   250       fatal("OopMap inserted twice");
   251     }
   252     if(last->offset() > map->offset()) {
   253       tty->print_cr( "WARNING, maps not sorted: pc[%d]=%d, pc[%d]=%d",
   254                       om_count(),last->offset(),om_count()+1,map->offset());
   255     }
   256   }
   257 #endif // ASSERT
   259   set(om_count(),map);
   260   increment_count();
   261 }
   264 int OopMapSet::heap_size() const {
   265   // The space we use
   266   int size = sizeof(OopMap);
   267   int align = sizeof(void *) - 1;
   268   size = ((size+align) & ~align);
   269   size += om_count() * sizeof(OopMap*);
   271   // Now add in the space needed for the indivdiual OopMaps
   272   for(int i=0; i < om_count(); i++) {
   273     size += at(i)->heap_size();
   274   }
   275   // We don't need to align this, it will be naturally pointer aligned
   276   return size;
   277 }
   280 OopMap* OopMapSet::singular_oop_map() {
   281   guarantee(om_count() == 1, "Make sure we only have a single gc point");
   282   return at(0);
   283 }
   286 OopMap* OopMapSet::find_map_at_offset(int pc_offset) const {
   287   int i, len = om_count();
   288   assert( len > 0, "must have pointer maps" );
   290   // Scan through oopmaps. Stop when current offset is either equal or greater
   291   // than the one we are looking for.
   292   for( i = 0; i < len; i++) {
   293     if( at(i)->offset() >= pc_offset )
   294       break;
   295   }
   297   assert( i < len, "oopmap not found" );
   299   OopMap* m = at(i);
   300   assert( m->offset() == pc_offset, "oopmap not found" );
   301   return m;
   302 }
   304 class DoNothingClosure: public OopClosure {
   305  public:
   306   void do_oop(oop* p)       {}
   307   void do_oop(narrowOop* p) {}
   308 };
   309 static DoNothingClosure do_nothing;
   311 static void add_derived_oop(oop* base, oop* derived) {
   312 #ifndef TIERED
   313   COMPILER1_PRESENT(ShouldNotReachHere();)
   314 #endif // TIERED
   315 #ifdef COMPILER2
   316   DerivedPointerTable::add(derived, base);
   317 #endif // COMPILER2
   318 }
   321 #ifndef PRODUCT
   322 static void trace_codeblob_maps(const frame *fr, const RegisterMap *reg_map) {
   323   // Print oopmap and regmap
   324   tty->print_cr("------ ");
   325   CodeBlob* cb = fr->cb();
   326   OopMapSet* maps = cb->oop_maps();
   327   OopMap* map = cb->oop_map_for_return_address(fr->pc());
   328   map->print();
   329   if( cb->is_nmethod() ) {
   330     nmethod* nm = (nmethod*)cb;
   331     // native wrappers have no scope data, it is implied
   332     if (nm->is_native_method()) {
   333       tty->print("bci: 0 (native)");
   334     } else {
   335       ScopeDesc* scope  = nm->scope_desc_at(fr->pc());
   336       tty->print("bci: %d ",scope->bci());
   337     }
   338   }
   339   tty->cr();
   340   fr->print_on(tty);
   341   tty->print("     ");
   342   cb->print_value_on(tty);  tty->cr();
   343   reg_map->print();
   344   tty->print_cr("------ ");
   346 }
   347 #endif // PRODUCT
   349 void OopMapSet::oops_do(const frame *fr, const RegisterMap* reg_map, OopClosure* f) {
   350   // add derived oops to a table
   351   all_do(fr, reg_map, f, add_derived_oop, &do_nothing);
   352 }
   355 void OopMapSet::all_do(const frame *fr, const RegisterMap *reg_map,
   356                        OopClosure* oop_fn, void derived_oop_fn(oop*, oop*),
   357                        OopClosure* value_fn) {
   358   CodeBlob* cb = fr->cb();
   359   assert(cb != NULL, "no codeblob");
   361   NOT_PRODUCT(if (TraceCodeBlobStacks) trace_codeblob_maps(fr, reg_map);)
   363   OopMapSet* maps = cb->oop_maps();
   364   OopMap* map = cb->oop_map_for_return_address(fr->pc());
   365   assert(map != NULL, "no ptr map found");
   367   // handle derived pointers first (otherwise base pointer may be
   368   // changed before derived pointer offset has been collected)
   369   OopMapValue omv;
   370   {
   371     OopMapStream oms(map,OopMapValue::derived_oop_value);
   372     if (!oms.is_done()) {
   373 #ifndef TIERED
   374       COMPILER1_PRESENT(ShouldNotReachHere();)
   375 #endif // !TIERED
   376       // Protect the operation on the derived pointers.  This
   377       // protects the addition of derived pointers to the shared
   378       // derived pointer table in DerivedPointerTable::add().
   379       MutexLockerEx x(DerivedPointerTableGC_lock, Mutex::_no_safepoint_check_flag);
   380       do {
   381         omv = oms.current();
   382         oop* loc = fr->oopmapreg_to_location(omv.reg(),reg_map);
   383         if ( loc != NULL ) {
   384           oop *base_loc    = fr->oopmapreg_to_location(omv.content_reg(), reg_map);
   385           oop *derived_loc = loc;
   386           derived_oop_fn(base_loc, derived_loc);
   387         }
   388         oms.next();
   389       }  while (!oms.is_done());
   390     }
   391   }
   393   // We want coop, value and oop oop_types
   394   int mask = OopMapValue::oop_value | OopMapValue::value_value | OopMapValue::narrowoop_value;
   395   {
   396     for (OopMapStream oms(map,mask); !oms.is_done(); oms.next()) {
   397       omv = oms.current();
   398       oop* loc = fr->oopmapreg_to_location(omv.reg(),reg_map);
   399       if ( loc != NULL ) {
   400         if ( omv.type() == OopMapValue::oop_value ) {
   401 #ifdef ASSERT
   402           if (COMPILER2_PRESENT(!DoEscapeAnalysis &&)
   403              (((uintptr_t)loc & (sizeof(*loc)-1)) != 0) ||
   404              !Universe::heap()->is_in_or_null(*loc)) {
   405             tty->print_cr("# Found non oop pointer.  Dumping state at failure");
   406             // try to dump out some helpful debugging information
   407             trace_codeblob_maps(fr, reg_map);
   408             omv.print();
   409             tty->print_cr("register r");
   410             omv.reg()->print();
   411             tty->print_cr("loc = %p *loc = %p\n", loc, (address)*loc);
   412             // do the real assert.
   413             assert(Universe::heap()->is_in_or_null(*loc), "found non oop pointer");
   414           }
   415 #endif // ASSERT
   416           oop_fn->do_oop(loc);
   417         } else if ( omv.type() == OopMapValue::value_value ) {
   418           value_fn->do_oop(loc);
   419         } else if ( omv.type() == OopMapValue::narrowoop_value ) {
   420           narrowOop *nl = (narrowOop*)loc;
   421 #ifndef VM_LITTLE_ENDIAN
   422           if (!omv.reg()->is_stack()) {
   423             // compressed oops in registers only take up 4 bytes of an
   424             // 8 byte register but they are in the wrong part of the
   425             // word so adjust loc to point at the right place.
   426             nl = (narrowOop*)((address)nl + 4);
   427           }
   428 #endif
   429           oop_fn->do_oop(nl);
   430         }
   431       }
   432     }
   433   }
   435 #ifdef COMPILER2
   436   if (DoEscapeAnalysis) {
   437     for (OopMapStream oms(map, OopMapValue::stack_obj); !oms.is_done(); oms.next()) {
   438       omv = oms.current();
   439       assert(omv.is_stack_loc(), "should refer to stack location");
   440       oop loc = (oop) fr->oopmapreg_to_location(omv.reg(),reg_map);
   441       oop_fn->do_oop(&loc);
   442     }
   443   }
   444 #endif // COMPILER2
   445 }
   448 // Update callee-saved register info for the following frame
   449 void OopMapSet::update_register_map(const frame *fr, RegisterMap *reg_map) {
   450   ResourceMark rm;
   451   CodeBlob* cb = fr->cb();
   452   assert(cb != NULL, "no codeblob");
   454   // Any reg might be saved by a safepoint handler (see generate_handler_blob).
   455   const int max_saved_on_entry_reg_count = ConcreteRegisterImpl::number_of_registers;
   456   assert( reg_map->_update_for_id == NULL || fr->is_older(reg_map->_update_for_id),
   457          "already updated this map; do not 'update' it twice!" );
   458   debug_only(reg_map->_update_for_id = fr->id());
   460   // Check if caller must update oop argument
   461   assert((reg_map->include_argument_oops() ||
   462           !cb->caller_must_gc_arguments(reg_map->thread())),
   463          "include_argument_oops should already be set");
   465   int nof_callee = 0;
   466   oop*        locs[2*max_saved_on_entry_reg_count+1];
   467   VMReg regs[2*max_saved_on_entry_reg_count+1];
   468   // ("+1" because max_saved_on_entry_reg_count might be zero)
   470   // Scan through oopmap and find location of all callee-saved registers
   471   // (we do not do update in place, since info could be overwritten)
   473   address pc = fr->pc();
   475   OopMap* map  = cb->oop_map_for_return_address(pc);
   477   assert(map != NULL, " no ptr map found");
   479   OopMapValue omv;
   480   for(OopMapStream oms(map,OopMapValue::callee_saved_value); !oms.is_done(); oms.next()) {
   481     omv = oms.current();
   482     assert(nof_callee < 2*max_saved_on_entry_reg_count, "overflow");
   483     regs[nof_callee] = omv.content_reg();
   484     locs[nof_callee] = fr->oopmapreg_to_location(omv.reg(),reg_map);
   485     nof_callee++;
   486   }
   488   // Check that runtime stubs save all callee-saved registers
   489 #ifdef COMPILER2
   490   assert(cb->is_compiled_by_c1() || !cb->is_runtime_stub() ||
   491          (nof_callee >= SAVED_ON_ENTRY_REG_COUNT || nof_callee >= C_SAVED_ON_ENTRY_REG_COUNT),
   492          "must save all");
   493 #endif // COMPILER2
   495   // Copy found callee-saved register to reg_map
   496   for(int i = 0; i < nof_callee; i++) {
   497     reg_map->set_location(regs[i], (address)locs[i]);
   498   }
   499 }
   501 //=============================================================================
   502 // Non-Product code
   504 #ifndef PRODUCT
   506 bool OopMap::has_derived_pointer() const {
   507 #ifndef TIERED
   508   COMPILER1_PRESENT(return false);
   509 #endif // !TIERED
   510 #ifdef COMPILER2
   511   OopMapStream oms((OopMap*)this,OopMapValue::derived_oop_value);
   512   return oms.is_done();
   513 #else
   514   return false;
   515 #endif // COMPILER2
   516 }
   518 #endif //PRODUCT
   520 // Printing code is present in product build for -XX:+PrintAssembly.
   522 static
   523 void print_register_type(OopMapValue::oop_types x, VMReg optional,
   524                          outputStream* st) {
   525   switch( x ) {
   526   case OopMapValue::oop_value:
   527     st->print("Oop");
   528     break;
   529   case OopMapValue::value_value:
   530     st->print("Value" );
   531     break;
   532   case OopMapValue::narrowoop_value:
   533     tty->print("NarrowOop" );
   534     break;
   535   case OopMapValue::callee_saved_value:
   536     st->print("Callers_" );
   537     optional->print_on(st);
   538     break;
   539   case OopMapValue::derived_oop_value:
   540     st->print("Derived_oop_" );
   541     optional->print_on(st);
   542     break;
   543   case OopMapValue::stack_obj:
   544     st->print("Stack");
   545     break;
   546   default:
   547     ShouldNotReachHere();
   548   }
   549 }
   552 void OopMapValue::print_on(outputStream* st) const {
   553   reg()->print_on(st);
   554   st->print("=");
   555   print_register_type(type(),content_reg(),st);
   556   st->print(" ");
   557 }
   560 void OopMap::print_on(outputStream* st) const {
   561   OopMapValue omv;
   562   st->print("OopMap{");
   563   for(OopMapStream oms((OopMap*)this); !oms.is_done(); oms.next()) {
   564     omv = oms.current();
   565     omv.print_on(st);
   566   }
   567   st->print("off=%d}", (int) offset());
   568 }
   571 void OopMapSet::print_on(outputStream* st) const {
   572   int i, len = om_count();
   574   st->print_cr("OopMapSet contains %d OopMaps\n",len);
   576   for( i = 0; i < len; i++) {
   577     OopMap* m = at(i);
   578     st->print_cr("#%d ",i);
   579     m->print_on(st);
   580     st->cr();
   581   }
   582 }
   586 //------------------------------DerivedPointerTable---------------------------
   588 #ifdef COMPILER2
   590 class DerivedPointerEntry : public CHeapObj {
   591  private:
   592   oop*     _location; // Location of derived pointer (also pointing to the base)
   593   intptr_t _offset;   // Offset from base pointer
   594  public:
   595   DerivedPointerEntry(oop* location, intptr_t offset) { _location = location; _offset = offset; }
   596   oop* location()    { return _location; }
   597   intptr_t  offset() { return _offset; }
   598 };
   601 GrowableArray<DerivedPointerEntry*>* DerivedPointerTable::_list = NULL;
   602 bool DerivedPointerTable::_active = false;
   605 void DerivedPointerTable::clear() {
   606   // The first time, we create the list.  Otherwise it should be
   607   // empty.  If not, then we have probably forgotton to call
   608   // update_pointers after last GC/Scavenge.
   609   assert (!_active, "should not be active");
   610   assert(_list == NULL || _list->length() == 0, "table not empty");
   611   if (_list == NULL) {
   612     _list = new (ResourceObj::C_HEAP) GrowableArray<DerivedPointerEntry*>(10, true); // Allocated on C heap
   613   }
   614   _active = true;
   615 }
   618 // Returns value of location as an int
   619 intptr_t value_of_loc(oop *pointer) { return (intptr_t)(*pointer); }
   622 void DerivedPointerTable::add(oop *derived_loc, oop *base_loc) {
   623   assert(Universe::heap()->is_in_or_null(*base_loc), "not an oop");
   624   assert(derived_loc != base_loc, "Base and derived in same location");
   625   if (_active) {
   626     assert(*derived_loc != (oop)base_loc, "location already added");
   627     assert(_list != NULL, "list must exist");
   628     intptr_t offset = value_of_loc(derived_loc) - value_of_loc(base_loc);
   629     assert(offset >= -1000000, "wrong derived pointer info");
   631     if (TraceDerivedPointers) {
   632       tty->print_cr(
   633         "Add derived pointer@" INTPTR_FORMAT
   634         " - Derived: " INTPTR_FORMAT
   635         " Base: " INTPTR_FORMAT " (@" INTPTR_FORMAT ") (Offset: %d)",
   636         derived_loc, (address)*derived_loc, (address)*base_loc, base_loc, offset
   637       );
   638     }
   639     // Set derived oop location to point to base.
   640     *derived_loc = (oop)base_loc;
   641     assert_lock_strong(DerivedPointerTableGC_lock);
   642     DerivedPointerEntry *entry = new DerivedPointerEntry(derived_loc, offset);
   643     _list->append(entry);
   644   }
   645 }
   648 void DerivedPointerTable::update_pointers() {
   649   assert(_list != NULL, "list must exist");
   650   for(int i = 0; i < _list->length(); i++) {
   651     DerivedPointerEntry* entry = _list->at(i);
   652     oop* derived_loc = entry->location();
   653     intptr_t offset  = entry->offset();
   654     // The derived oop was setup to point to location of base
   655     oop  base        = **(oop**)derived_loc;
   656     assert(Universe::heap()->is_in_or_null(base), "must be an oop");
   658     *derived_loc = (oop)(((address)base) + offset);
   659     assert(value_of_loc(derived_loc) - value_of_loc(&base) == offset, "sanity check");
   661     if (TraceDerivedPointers) {
   662       tty->print_cr("Updating derived pointer@" INTPTR_FORMAT
   663                     " - Derived: " INTPTR_FORMAT "  Base: " INTPTR_FORMAT " (Offset: %d)",
   664           derived_loc, (address)*derived_loc, (address)base, offset);
   665     }
   667     // Delete entry
   668     delete entry;
   669     _list->at_put(i, NULL);
   670   }
   671   // Clear list, so it is ready for next traversal (this is an invariant)
   672   if (TraceDerivedPointers && !_list->is_empty()) {
   673     tty->print_cr("--------------------------");
   674   }
   675   _list->clear();
   676   _active = false;
   677 }
   679 #endif // COMPILER2

mercurial