src/share/vm/oops/oop.hpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File bug_8003424.4 Sdiff src/share/vm/oops

src/share/vm/oops/oop.hpp

Print this page


   1 /*
   2  * Copyright (c) 1997, 2012, Oracle and/or its affiliates. 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 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  *


  45 
  46 extern bool always_do_update_barrier;
  47 
  48 // Forward declarations.
  49 class OopClosure;
  50 class ScanClosure;
  51 class FastScanClosure;
  52 class FilteringClosure;
  53 class BarrierSet;
  54 class CMSIsAliveClosure;
  55 
  56 class PSPromotionManager;
  57 class ParCompactionManager;
  58 
  59 class oopDesc {
  60   friend class VMStructs;
  61  private:
  62   volatile markOop  _mark;
  63   union _metadata {
  64     Klass*      _klass;
  65     narrowOop       _compressed_klass;
  66   } _metadata;
  67 
  68   // Fast access to barrier set.  Must be initialized.
  69   static BarrierSet* _bs;
  70 
  71  public:
  72   markOop  mark() const         { return _mark; }
  73   markOop* mark_addr() const    { return (markOop*) &_mark; }
  74 
  75   void set_mark(volatile markOop m)      { _mark = m;   }
  76 
  77   void    release_set_mark(markOop m);
  78   markOop cas_set_mark(markOop new_mark, markOop old_mark);
  79 
  80   // Used only to re-initialize the mark word (e.g., of promoted
  81   // objects during a GC) -- requires a valid klass pointer
  82   void init_mark();
  83 
  84   Klass* klass() const;
  85   Klass* klass_or_null() const volatile;
  86   Klass** klass_addr();
  87   narrowOop* compressed_klass_addr();
  88 
  89   void set_klass(Klass* k);
  90 
  91   // For klass field compression
  92   int klass_gap() const;
  93   void set_klass_gap(int z);
  94   // For when the klass pointer is being used as a linked list "next" field.
  95   void set_klass_to_list_ptr(oop k);
  96   oop list_ptr_from_klass();
  97 
  98   // size of object header, aligned to platform wordSize
  99   static int header_size()          { return sizeof(oopDesc)/HeapWordSize; }
 100 
 101   // Returns whether this is an instance of k or an instance of a subclass of k
 102   bool is_a(Klass* k)  const;
 103 
 104   // Returns the actual oop size of the object
 105   int size();
 106 
 107   // Sometimes (for complicated concurrency-related reasons), it is useful


 172   // Encode oop if UseCompressedOops and store into the heap.
 173   static void encode_store_heap_oop_not_null(narrowOop* p, oop v);
 174   static void encode_store_heap_oop_not_null(oop* p, oop v);
 175   static void encode_store_heap_oop(narrowOop* p, oop v);
 176   static void encode_store_heap_oop(oop* p, oop v);
 177 
 178   static void release_store_heap_oop(volatile narrowOop* p, narrowOop v);
 179   static void release_store_heap_oop(volatile oop* p, oop v);
 180 
 181   static void release_encode_store_heap_oop_not_null(volatile narrowOop* p, oop v);
 182   static void release_encode_store_heap_oop_not_null(volatile oop* p, oop v);
 183   static void release_encode_store_heap_oop(volatile narrowOop* p, oop v);
 184   static void release_encode_store_heap_oop(volatile oop* p, oop v);
 185 
 186   static oop atomic_exchange_oop(oop exchange_value, volatile HeapWord *dest);
 187   static oop atomic_compare_exchange_oop(oop exchange_value,
 188                                          volatile HeapWord *dest,
 189                                          oop compare_value,
 190                                          bool prebarrier = false);
 191 
 192   // klass encoding for klass pointer in objects.
 193   static narrowOop encode_klass_not_null(Klass* v);
 194   static narrowOop encode_klass(Klass* v);
 195 
 196   static Klass* decode_klass_not_null(narrowOop v);
 197   static Klass* decode_klass(narrowOop v);
 198 
 199   // Access to fields in a instanceOop through these methods.
 200   oop obj_field(int offset) const;
 201   volatile oop obj_field_volatile(int offset) const;
 202   void obj_field_put(int offset, oop value);
 203   void obj_field_put_raw(int offset, oop value);
 204   void obj_field_put_volatile(int offset, oop value);
 205 
 206   Metadata* metadata_field(int offset) const;
 207   void metadata_field_put(int offset, Metadata* value);
 208 
 209   jbyte byte_field(int offset) const;
 210   void byte_field_put(int offset, jbyte contents);
 211 
 212   jchar char_field(int offset) const;
 213   void char_field_put(int offset, jchar contents);
 214 
 215   jboolean bool_field(int offset) const;
 216   void bool_field_put(int offset, jboolean contents);
 217 
 218   jint int_field(int offset) const;


   1 /*
   2  * Copyright (c) 1997, 2013, Oracle and/or its affiliates. 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 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  *


  45 
  46 extern bool always_do_update_barrier;
  47 
  48 // Forward declarations.
  49 class OopClosure;
  50 class ScanClosure;
  51 class FastScanClosure;
  52 class FilteringClosure;
  53 class BarrierSet;
  54 class CMSIsAliveClosure;
  55 
  56 class PSPromotionManager;
  57 class ParCompactionManager;
  58 
  59 class oopDesc {
  60   friend class VMStructs;
  61  private:
  62   volatile markOop  _mark;
  63   union _metadata {
  64     Klass*      _klass;
  65     narrowKlass _compressed_klass;
  66   } _metadata;
  67 
  68   // Fast access to barrier set.  Must be initialized.
  69   static BarrierSet* _bs;
  70 
  71  public:
  72   markOop  mark() const         { return _mark; }
  73   markOop* mark_addr() const    { return (markOop*) &_mark; }
  74 
  75   void set_mark(volatile markOop m)      { _mark = m;   }
  76 
  77   void    release_set_mark(markOop m);
  78   markOop cas_set_mark(markOop new_mark, markOop old_mark);
  79 
  80   // Used only to re-initialize the mark word (e.g., of promoted
  81   // objects during a GC) -- requires a valid klass pointer
  82   void init_mark();
  83 
  84   Klass* klass() const;
  85   Klass* klass_or_null() const volatile;
  86   Klass** klass_addr();
  87   narrowKlass* compressed_klass_addr();
  88 
  89   void set_klass(Klass* k);
  90 
  91   // For klass field compression
  92   int klass_gap() const;
  93   void set_klass_gap(int z);
  94   // For when the klass pointer is being used as a linked list "next" field.
  95   void set_klass_to_list_ptr(oop k);
  96   oop list_ptr_from_klass();
  97 
  98   // size of object header, aligned to platform wordSize
  99   static int header_size()          { return sizeof(oopDesc)/HeapWordSize; }
 100 
 101   // Returns whether this is an instance of k or an instance of a subclass of k
 102   bool is_a(Klass* k)  const;
 103 
 104   // Returns the actual oop size of the object
 105   int size();
 106 
 107   // Sometimes (for complicated concurrency-related reasons), it is useful


 172   // Encode oop if UseCompressedOops and store into the heap.
 173   static void encode_store_heap_oop_not_null(narrowOop* p, oop v);
 174   static void encode_store_heap_oop_not_null(oop* p, oop v);
 175   static void encode_store_heap_oop(narrowOop* p, oop v);
 176   static void encode_store_heap_oop(oop* p, oop v);
 177 
 178   static void release_store_heap_oop(volatile narrowOop* p, narrowOop v);
 179   static void release_store_heap_oop(volatile oop* p, oop v);
 180 
 181   static void release_encode_store_heap_oop_not_null(volatile narrowOop* p, oop v);
 182   static void release_encode_store_heap_oop_not_null(volatile oop* p, oop v);
 183   static void release_encode_store_heap_oop(volatile narrowOop* p, oop v);
 184   static void release_encode_store_heap_oop(volatile oop* p, oop v);
 185 
 186   static oop atomic_exchange_oop(oop exchange_value, volatile HeapWord *dest);
 187   static oop atomic_compare_exchange_oop(oop exchange_value,
 188                                          volatile HeapWord *dest,
 189                                          oop compare_value,
 190                                          bool prebarrier = false);
 191 







 192   // Access to fields in a instanceOop through these methods.
 193   oop obj_field(int offset) const;
 194   volatile oop obj_field_volatile(int offset) const;
 195   void obj_field_put(int offset, oop value);
 196   void obj_field_put_raw(int offset, oop value);
 197   void obj_field_put_volatile(int offset, oop value);
 198 
 199   Metadata* metadata_field(int offset) const;
 200   void metadata_field_put(int offset, Metadata* value);
 201 
 202   jbyte byte_field(int offset) const;
 203   void byte_field_put(int offset, jbyte contents);
 204 
 205   jchar char_field(int offset) const;
 206   void char_field_put(int offset, jchar contents);
 207 
 208   jboolean bool_field(int offset) const;
 209   void bool_field_put(int offset, jboolean contents);
 210 
 211   jint int_field(int offset) const;


src/share/vm/oops/oop.hpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File