< prev index next >

src/hotspot/share/oops/stackChunkOop.hpp

Print this page

 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 #ifndef SHARE_OOPS_STACKCHUNKOOP_HPP
 26 #define SHARE_OOPS_STACKCHUNKOOP_HPP
 27 
 28 
 29 #include "oops/instanceOop.hpp"
 30 #include "runtime/handles.hpp"
 31 #include "runtime/stackChunkFrameStream.hpp"
 32 #include "utilities/bitMap.hpp"
 33 #include "utilities/macros.hpp"
 34 
 35 class frame;
 36 class MemRegion;
 37 class RegisterMap;
 38 class VMRegImpl;


 39 typedef VMRegImpl* VMReg;
 40 
 41 // A continuation stack-chunk oop.
 42 // See InstanceStackChunkKlass for a description of continuation stack-chunks.
 43 //
 44 // size and sp are in machine words
 45 // max_size is the maximum space a thawed chunk would take up on the stack, *not* including top-most frame's metadata
 46 class stackChunkOopDesc : public instanceOopDesc {
 47 public:
 48   enum class BarrierType { Load, Store };
 49 
 50 private:
 51   template <BarrierType barrier> friend class DoBarriersStackClosure;
 52 
 53   // Chunk flags.
 54   // FLAG_HAS_INTERPRETED_FRAMES actually means "thaw slow because of some content-based chunk condition"
 55   // It is set whenever we freeze slow, but generally signifies there might be interpreted/deoptimized/stub frames
 56   static const uint8_t FLAG_HAS_INTERPRETED_FRAMES = 1 << 0;
 57   static const uint8_t FLAG_CLAIM_RELATIVIZE = 1 << 1; // Only one thread claims relativization of derived pointers
 58   static const uint8_t FLAG_NOTIFY_RELATIVIZE = 1 << 2; // Someone is waiting for relativization to complete
 59   static const uint8_t FLAG_GC_MODE = 1 << 3; // Once true it and FLAG_HAS_INTERPRETED_FRAMES can't change
 60   static const uint8_t FLAG_HAS_BITMAP = 1 << 4; // Can only be true if FLAG_GC_MODE is true






 61 
 62   bool try_acquire_relativization();
 63   void release_relativization();
 64 
 65 public:
 66   static inline stackChunkOop cast(oop obj);
 67 
 68   inline stackChunkOop parent() const;
 69   inline void set_parent(stackChunkOop value);
 70   template<typename P>
 71   inline void set_parent_raw(oop value);
 72   template<DecoratorSet decorators>
 73   inline void set_parent_access(oop value);
 74 
 75   inline int stack_size() const;
 76 
 77   inline int sp() const;
 78   inline void set_sp(int value);
 79 
 80   inline address pc() const;
 81   inline void set_pc(address value);
 82 
 83   inline int argsize() const;
 84   inline void set_argsize(int value);
 85 
 86   inline uint8_t flags() const;
 87   inline uint8_t flags_acquire() const;
 88   inline void set_flags(uint8_t value);
 89   inline void release_set_flags(uint8_t value);
 90 
 91   inline int max_thawing_size() const;
 92   inline void set_max_thawing_size(int value);
 93 









 94   inline oop cont() const;
 95   template<typename P>
 96   inline oop cont() const;
 97   inline void set_cont(oop value);
 98   template<typename P>
 99   inline void set_cont_raw(oop value);
100   template<DecoratorSet decorators>
101   inline void set_cont_access(oop value);
102 
103   inline int bottom() const;
104   inline void set_bottom(int value);
105 
106   inline HeapWord* start_of_stack() const;
107 
108   inline intptr_t* start_address() const;
109   inline intptr_t* end_address() const;
110   inline intptr_t* bottom_address() const; // = end_address - argsize
111   inline intptr_t* sp_address() const;
112 
113 
114   inline int to_offset(intptr_t* p) const;
115   inline intptr_t* from_offset(int offset) const;
116 
117   inline bool is_empty() const;
118   inline bool is_in_chunk(void* p) const;
119   inline bool is_usable_in_chunk(void* p) const;
120 
121   inline bool is_flag(uint8_t flag) const;
122   inline bool is_flag_acquire(uint8_t flag) const;
123   inline void set_flag(uint8_t flag, bool value);
124   inline bool try_set_flags(uint8_t prev_flags, uint8_t new_flags);

125   inline void clear_flags();
126 
127   inline bool has_mixed_frames() const;
128   inline void set_has_mixed_frames(bool value);
129 






130   inline bool is_gc_mode() const;
131   inline bool is_gc_mode_acquire() const;
132   inline void set_gc_mode(bool value);
133 
134   inline bool has_bitmap() const;
135   inline void set_has_bitmap(bool value);
136 
137   inline bool has_thaw_slowpath_condition() const;
138 
139   inline bool requires_barriers();
140 
141   template <BarrierType>
142   void do_barriers();
143 
144   template <BarrierType, ChunkFrames frames, typename RegisterMapT>
145   inline void do_barriers(const StackChunkFrameStream<frames>& f, const RegisterMapT* map);
146 
147   template <typename RegisterMapT>
148   void fix_thawed_frame(const frame& f, const RegisterMapT* map);
149 





150   template <class StackChunkFrameClosureType>
151   inline void iterate_stack(StackChunkFrameClosureType* closure);
152 
153   // Derived pointers are relativized, with respect to their oop base.
154   void relativize_derived_pointers_concurrently();
155   void transform();
156 
157   inline void* gc_data() const;
158   inline BitMapView bitmap() const;
159   inline BitMap::idx_t bit_index_for(address p) const;
160   inline intptr_t* address_for_bit(BitMap::idx_t index) const;
161   template <typename OopT> inline BitMap::idx_t bit_index_for(OopT* p) const;
162   template <typename OopT> inline OopT* address_for_bit(BitMap::idx_t index) const;
163 
164   MemRegion range();
165 
166   // Returns a relative frame (with offset_sp, offset_unextended_sp, and offset_fp) that can be held
167   // during safepoints.  This is orthogonal to the relativizing of the actual content of interpreted frames.
168   // To be used, frame objects need to be derelativized with `derelativize`.
169   inline frame relativize(frame fr) const;

 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 #ifndef SHARE_OOPS_STACKCHUNKOOP_HPP
 26 #define SHARE_OOPS_STACKCHUNKOOP_HPP
 27 
 28 
 29 #include "oops/instanceOop.hpp"
 30 #include "runtime/handles.hpp"
 31 #include "runtime/stackChunkFrameStream.hpp"
 32 #include "utilities/bitMap.hpp"
 33 #include "utilities/macros.hpp"
 34 
 35 class frame;
 36 class MemRegion;
 37 class RegisterMap;
 38 class VMRegImpl;
 39 class ObjectMonitor;
 40 class ObjectWaiter;
 41 typedef VMRegImpl* VMReg;
 42 
 43 // A continuation stack-chunk oop.
 44 // See InstanceStackChunkKlass for a description of continuation stack-chunks.
 45 //
 46 // size and sp are in machine words
 47 // max_size is the maximum space a thawed chunk would take up on the stack, *not* including top-most frame's metadata
 48 class stackChunkOopDesc : public instanceOopDesc {
 49 public:
 50   enum class BarrierType { Load, Store };
 51 
 52 private:
 53   template <BarrierType barrier> friend class DoBarriersStackClosure;
 54 
 55   // Chunk flags.
 56   // FLAG_HAS_INTERPRETED_FRAMES actually means "thaw slow because of some content-based chunk condition"
 57   // It is set whenever we freeze slow, but generally signifies there might be interpreted/deoptimized/stub frames
 58   static const uint8_t FLAG_HAS_INTERPRETED_FRAMES = 1 << 0;
 59   static const uint8_t FLAG_CLAIM_RELATIVIZE = 1 << 1; // Only one thread claims relativization of derived pointers
 60   static const uint8_t FLAG_NOTIFY_RELATIVIZE = 1 << 2; // Someone is waiting for relativization to complete
 61   static const uint8_t FLAG_GC_MODE = 1 << 3; // Once true it and FLAG_HAS_INTERPRETED_FRAMES can't change
 62   static const uint8_t FLAG_HAS_BITMAP = 1 << 4; // Can only be true if FLAG_GC_MODE is true
 63   static const uint8_t FLAG_HAS_LOCKSTACK = 1 << 5; // LockStack was copied into stackChunk
 64   static const uint8_t FLAG_PREEMPTED_MONITORENTER = 1 << 6; // Continuation was preempted on monitorenter
 65   static const uint8_t FLAG_PREEMPTED_WAIT = 1 << 7; // Continuation was preempted on Object.wait()
 66 
 67   static const uint8_t FLAGS_PREEMPTED = FLAG_PREEMPTED_MONITORENTER | FLAG_PREEMPTED_WAIT;
 68   static const int preempt_shift = 6;
 69 
 70   bool try_acquire_relativization();
 71   void release_relativization();
 72 
 73 public:
 74   static inline stackChunkOop cast(oop obj);
 75 
 76   inline stackChunkOop parent() const;
 77   inline void set_parent(stackChunkOop value);
 78   template<typename P>
 79   inline void set_parent_raw(oop value);
 80   template<DecoratorSet decorators>
 81   inline void set_parent_access(oop value);
 82 
 83   inline int stack_size() const;
 84 
 85   inline int sp() const;
 86   inline void set_sp(int value);
 87 
 88   inline address pc() const;
 89   inline void set_pc(address value);
 90 
 91   inline int argsize() const;
 92   inline void set_argsize(int value);
 93 
 94   inline uint8_t flags() const;
 95   inline uint8_t flags_acquire() const;
 96   inline void set_flags(uint8_t value);
 97   inline void release_set_flags(uint8_t value);
 98 
 99   inline int max_thawing_size() const;
100   inline void set_max_thawing_size(int value);
101 
102   inline uint8_t lockstack_size() const;
103   inline void set_lockstack_size(uint8_t value);
104 
105   inline ObjectWaiter* object_waiter() const;
106   inline void set_object_waiter(ObjectWaiter* obj_waiter);
107 
108   inline ObjectMonitor* current_pending_monitor() const;
109   inline ObjectMonitor* current_waiting_monitor() const;
110 
111   inline oop cont() const;
112   template<typename P>
113   inline oop cont() const;
114   inline void set_cont(oop value);
115   template<typename P>
116   inline void set_cont_raw(oop value);
117   template<DecoratorSet decorators>
118   inline void set_cont_access(oop value);
119 
120   inline int bottom() const;
121   inline void set_bottom(int value);
122 
123   inline HeapWord* start_of_stack() const;
124 
125   inline intptr_t* start_address() const;
126   inline intptr_t* end_address() const;
127   inline intptr_t* bottom_address() const; // = end_address - argsize
128   inline intptr_t* sp_address() const;
129 
130 
131   inline int to_offset(intptr_t* p) const;
132   inline intptr_t* from_offset(int offset) const;
133 
134   inline bool is_empty() const;
135   inline bool is_in_chunk(void* p) const;
136   inline bool is_usable_in_chunk(void* p) const;
137 
138   inline bool is_flag(uint8_t flag) const;
139   inline bool is_flag_acquire(uint8_t flag) const;
140   inline void set_flag(uint8_t flag, bool value);
141   inline bool try_set_flags(uint8_t prev_flags, uint8_t new_flags);
142   inline void clear_flags(uint8_t flag);
143   inline void clear_flags();
144 
145   inline bool has_mixed_frames() const;
146   inline void set_has_mixed_frames(bool value);
147 
148   inline void set_preempt_kind(int freeze_kind);
149   inline int get_and_clear_preempt_kind();
150 
151   inline bool has_lockstack() const;
152   inline void set_has_lockstack(bool value);
153 
154   inline bool is_gc_mode() const;
155   inline bool is_gc_mode_acquire() const;
156   inline void set_gc_mode(bool value);
157 
158   inline bool has_bitmap() const;
159   inline void set_has_bitmap(bool value);
160 
161   inline bool has_thaw_slowpath_condition() const;
162 
163   inline bool requires_barriers();
164 
165   template <BarrierType>
166   void do_barriers();
167 
168   template <BarrierType, ChunkFrames frames, typename RegisterMapT>
169   inline void do_barriers(const StackChunkFrameStream<frames>& f, const RegisterMapT* map);
170 
171   template <typename RegisterMapT>
172   void fix_thawed_frame(const frame& f, const RegisterMapT* map);
173 
174   void copy_lockstack(oop* start);
175 
176   template <typename OopT, class StackChunkLockStackClosureType>
177   inline void iterate_lockstack(StackChunkLockStackClosureType* closure);
178 
179   template <class StackChunkFrameClosureType>
180   inline void iterate_stack(StackChunkFrameClosureType* closure);
181 
182   // Derived pointers are relativized, with respect to their oop base.
183   void relativize_derived_pointers_concurrently();
184   void transform();
185 
186   inline void* gc_data() const;
187   inline BitMapView bitmap() const;
188   inline BitMap::idx_t bit_index_for(address p) const;
189   inline intptr_t* address_for_bit(BitMap::idx_t index) const;
190   template <typename OopT> inline BitMap::idx_t bit_index_for(OopT* p) const;
191   template <typename OopT> inline OopT* address_for_bit(BitMap::idx_t index) const;
192 
193   MemRegion range();
194 
195   // Returns a relative frame (with offset_sp, offset_unextended_sp, and offset_fp) that can be held
196   // during safepoints.  This is orthogonal to the relativizing of the actual content of interpreted frames.
197   // To be used, frame objects need to be derelativized with `derelativize`.
198   inline frame relativize(frame fr) const;
< prev index next >