src/share/vm/oops/constantPoolOop.cpp

Print this page




   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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 # include "incls/_precompiled.incl"
  26 # include "incls/_constantPoolOop.cpp.incl"













  27 
  28 void constantPoolOopDesc::set_flag_at(FlagBit fb) {
  29   const int MAX_STATE_CHANGES = 2;
  30   for (int i = MAX_STATE_CHANGES + 10; i > 0; i--) {
  31     int oflags = _flags;
  32     int nflags = oflags | (1 << (int)fb);
  33     if (Atomic::cmpxchg(nflags, &_flags, oflags) == oflags)
  34       return;
  35   }
  36   assert(false, "failed to cmpxchg flags");
  37   _flags |= (1 << (int)fb);     // better than nothing
  38 }
  39 
  40 klassOop constantPoolOopDesc::klass_at_impl(constantPoolHandle this_oop, int which, TRAPS) {
  41   // A resolved constantPool entry will contain a klassOop, otherwise a symbolOop.
  42   // It is not safe to rely on the tag bit's here, since we don't have a lock, and the entry and
  43   // tag is not updated atomicly.
  44   oop entry = *(this_oop->obj_at_addr(which));
  45   if (entry->is_klass()) {
  46     // Already resolved - return entry.




   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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/javaClasses.hpp"
  27 #include "classfile/symbolTable.hpp"
  28 #include "classfile/systemDictionary.hpp"
  29 #include "classfile/vmSymbols.hpp"
  30 #include "interpreter/linkResolver.hpp"
  31 #include "memory/universe.inline.hpp"
  32 #include "oops/constantPoolOop.hpp"
  33 #include "oops/instanceKlass.hpp"
  34 #include "oops/objArrayKlass.hpp"
  35 #include "oops/oop.inline.hpp"
  36 #include "runtime/fieldType.hpp"
  37 #include "runtime/init.hpp"
  38 #include "runtime/signature.hpp"
  39 #include "runtime/vframe.hpp"
  40 
  41 void constantPoolOopDesc::set_flag_at(FlagBit fb) {
  42   const int MAX_STATE_CHANGES = 2;
  43   for (int i = MAX_STATE_CHANGES + 10; i > 0; i--) {
  44     int oflags = _flags;
  45     int nflags = oflags | (1 << (int)fb);
  46     if (Atomic::cmpxchg(nflags, &_flags, oflags) == oflags)
  47       return;
  48   }
  49   assert(false, "failed to cmpxchg flags");
  50   _flags |= (1 << (int)fb);     // better than nothing
  51 }
  52 
  53 klassOop constantPoolOopDesc::klass_at_impl(constantPoolHandle this_oop, int which, TRAPS) {
  54   // A resolved constantPool entry will contain a klassOop, otherwise a symbolOop.
  55   // It is not safe to rely on the tag bit's here, since we don't have a lock, and the entry and
  56   // tag is not updated atomicly.
  57   oop entry = *(this_oop->obj_at_addr(which));
  58   if (entry->is_klass()) {
  59     // Already resolved - return entry.