hotspot/src/share/vm/oops/oop.inline.hpp
changeset 8725 8c1e3dd5fe1b
parent 8107 78e5bd944384
child 10540 92d59dba2407
equal deleted inserted replaced
8724:693c6b883b54 8725:8c1e3dd5fe1b
     1 /*
     1 /*
     2  * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
   139 inline Klass* oopDesc::blueprint()           const { return klass()->klass_part(); }
   139 inline Klass* oopDesc::blueprint()           const { return klass()->klass_part(); }
   140 
   140 
   141 inline bool oopDesc::is_a(klassOop k)        const { return blueprint()->is_subtype_of(k); }
   141 inline bool oopDesc::is_a(klassOop k)        const { return blueprint()->is_subtype_of(k); }
   142 
   142 
   143 inline bool oopDesc::is_instance()           const { return blueprint()->oop_is_instance(); }
   143 inline bool oopDesc::is_instance()           const { return blueprint()->oop_is_instance(); }
       
   144 inline bool oopDesc::is_instanceMirror()     const { return blueprint()->oop_is_instanceMirror(); }
   144 inline bool oopDesc::is_instanceRef()        const { return blueprint()->oop_is_instanceRef(); }
   145 inline bool oopDesc::is_instanceRef()        const { return blueprint()->oop_is_instanceRef(); }
   145 inline bool oopDesc::is_array()              const { return blueprint()->oop_is_array(); }
   146 inline bool oopDesc::is_array()              const { return blueprint()->oop_is_array(); }
   146 inline bool oopDesc::is_objArray()           const { return blueprint()->oop_is_objArray(); }
   147 inline bool oopDesc::is_objArray()           const { return blueprint()->oop_is_objArray(); }
   147 inline bool oopDesc::is_typeArray()          const { return blueprint()->oop_is_typeArray(); }
   148 inline bool oopDesc::is_typeArray()          const { return blueprint()->oop_is_typeArray(); }
   148 inline bool oopDesc::is_javaArray()          const { return blueprint()->oop_is_javaArray(); }
   149 inline bool oopDesc::is_javaArray()          const { return blueprint()->oop_is_javaArray(); }
   397 inline address oopDesc::address_field_acquire(int offset) const             { return (address) OrderAccess::load_ptr_acquire(address_field_addr(offset)); }
   398 inline address oopDesc::address_field_acquire(int offset) const             { return (address) OrderAccess::load_ptr_acquire(address_field_addr(offset)); }
   398 inline void oopDesc::release_address_field_put(int offset, address contents) { OrderAccess::release_store_ptr(address_field_addr(offset), contents); }
   399 inline void oopDesc::release_address_field_put(int offset, address contents) { OrderAccess::release_store_ptr(address_field_addr(offset), contents); }
   399 
   400 
   400 inline int oopDesc::size_given_klass(Klass* klass)  {
   401 inline int oopDesc::size_given_klass(Klass* klass)  {
   401   int lh = klass->layout_helper();
   402   int lh = klass->layout_helper();
   402   int s  = lh >> LogHeapWordSize;  // deliver size scaled by wordSize
   403   int s;
   403 
   404 
   404   // lh is now a value computed at class initialization that may hint
   405   // lh is now a value computed at class initialization that may hint
   405   // at the size.  For instances, this is positive and equal to the
   406   // at the size.  For instances, this is positive and equal to the
   406   // size.  For arrays, this is negative and provides log2 of the
   407   // size.  For arrays, this is negative and provides log2 of the
   407   // array element size.  For other oops, it is zero and thus requires
   408   // array element size.  For other oops, it is zero and thus requires
   410   // We go to all this trouble because the size computation is at the
   411   // We go to all this trouble because the size computation is at the
   411   // heart of phase 2 of mark-compaction, and called for every object,
   412   // heart of phase 2 of mark-compaction, and called for every object,
   412   // alive or dead.  So the speed here is equal in importance to the
   413   // alive or dead.  So the speed here is equal in importance to the
   413   // speed of allocation.
   414   // speed of allocation.
   414 
   415 
   415   if (lh <= Klass::_lh_neutral_value) {
   416   if (lh > Klass::_lh_neutral_value) {
       
   417     if (!Klass::layout_helper_needs_slow_path(lh)) {
       
   418       s = lh >> LogHeapWordSize;  // deliver size scaled by wordSize
       
   419     } else {
       
   420       s = klass->oop_size(this);
       
   421     }
       
   422   } else if (lh <= Klass::_lh_neutral_value) {
   416     // The most common case is instances; fall through if so.
   423     // The most common case is instances; fall through if so.
   417     if (lh < Klass::_lh_neutral_value) {
   424     if (lh < Klass::_lh_neutral_value) {
   418       // Second most common case is arrays.  We have to fetch the
   425       // Second most common case is arrays.  We have to fetch the
   419       // length of the array, shift (multiply) it appropriately,
   426       // length of the array, shift (multiply) it appropriately,
   420       // up to wordSize, add the header, and align to object size.
   427       // up to wordSize, add the header, and align to object size.