< prev index next >

src/hotspot/share/runtime/handles.hpp

Print this page




  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_RUNTIME_HANDLES_HPP
  26 #define SHARE_VM_RUNTIME_HANDLES_HPP
  27 
  28 #include "memory/arena.hpp"
  29 #include "oops/oop.hpp"
  30 #include "oops/oopsHierarchy.hpp"
  31 
  32 class InstanceKlass;
  33 class Klass;
  34 
  35 //------------------------------------------------------------------------------------------------------------------------
  36 // In order to preserve oops during garbage collection, they should be
  37 // allocated and passed around via Handles within the VM. A handle is
  38 // simply an extra indirection allocated in a thread local handle area.
  39 //
  40 // A handle is a ValueObj, so it can be passed around as a value, can
  41 // be used as a parameter w/o using &-passing, and can be returned as a
  42 // return value.
  43 //
  44 // oop parameters and return types should be Handles whenever feasible.
  45 //
  46 // Handles are declared in a straight-forward manner, e.g.
  47 //
  48 //   oop obj = ...;
  49 //   Handle h2(thread, obj);      // allocate a new handle in thread
  50 //   Handle h3;                   // declare handle only, no allocation occurs
  51 //   ...
  52 //   h3 = h1;                     // make h3 refer to same indirection as h1
  53 //   oop obj2 = h2();             // get handle value
  54 //   h1->print();                 // invoking operation on oop
  55 //
  56 // Handles are specialized for different oop types to provide extra type
  57 // information and avoid unnecessary casting. For each oop type xxxOop
  58 // there is a corresponding handle called xxxHandle.
  59 
  60 //------------------------------------------------------------------------------------------------------------------------




  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_RUNTIME_HANDLES_HPP
  26 #define SHARE_VM_RUNTIME_HANDLES_HPP
  27 
  28 #include "memory/arena.hpp"
  29 #include "oops/oop.hpp"
  30 #include "oops/oopsHierarchy.hpp"
  31 
  32 class InstanceKlass;
  33 class Klass;
  34 
  35 //------------------------------------------------------------------------------------------------------------------------
  36 // In order to preserve oops during garbage collection, they should be
  37 // allocated and passed around via Handles within the VM. A handle is
  38 // simply an extra indirection allocated in a thread local handle area.
  39 //
  40 // A handle is a value object, so it can be passed around as a value, can
  41 // be used as a parameter w/o using &-passing, and can be returned as a
  42 // return value.
  43 //
  44 // oop parameters and return types should be Handles whenever feasible.
  45 //
  46 // Handles are declared in a straight-forward manner, e.g.
  47 //
  48 //   oop obj = ...;
  49 //   Handle h2(thread, obj);      // allocate a new handle in thread
  50 //   Handle h3;                   // declare handle only, no allocation occurs
  51 //   ...
  52 //   h3 = h1;                     // make h3 refer to same indirection as h1
  53 //   oop obj2 = h2();             // get handle value
  54 //   h1->print();                 // invoking operation on oop
  55 //
  56 // Handles are specialized for different oop types to provide extra type
  57 // information and avoid unnecessary casting. For each oop type xxxOop
  58 // there is a corresponding handle called xxxHandle.
  59 
  60 //------------------------------------------------------------------------------------------------------------------------


< prev index next >