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 #ifndef SHARE_RUNTIME_STACKCHUNKFRAMESTREAM_HPP
26 #define SHARE_RUNTIME_STACKCHUNKFRAMESTREAM_HPP
27
28 #include "memory/allocation.hpp"
29 #include "oops/oopsHierarchy.hpp"
30 #include "utilities/globalDefinitions.hpp"
31 #include "utilities/macros.hpp"
32
33 class CodeBlob;
34 class frame;
35 class ImmutableOopMap;
36 class RegisterMap;
37 class VMRegImpl;
38 typedef VMRegImpl* VMReg;
39
40 enum ChunkFrames { CompiledOnly, Mixed };
41
42 template <ChunkFrames frame_kind>
43 class StackChunkFrameStream : public StackObj {
44 private:
45 intptr_t* _end;
46 intptr_t* _sp;
47 intptr_t* _unextended_sp; // used only when mixed
48 CodeBlob* _cb;
62 inline StackChunkFrameStream(stackChunkOop chunk);
63 inline StackChunkFrameStream(stackChunkOop chunk, const frame& f);
64
65 bool is_done() const { return _sp >= _end; }
66
67 // Query
68 intptr_t* sp() const { return _sp; }
69 inline address pc() const { return get_pc(); }
70 inline intptr_t* fp() const;
71 inline intptr_t* unextended_sp() const { return frame_kind == ChunkFrames::Mixed ? _unextended_sp : _sp; }
72 inline address orig_pc() const;
73
74 inline bool is_interpreted() const;
75 inline bool is_stub() const;
76 inline bool is_compiled() const;
77 CodeBlob* cb() const { return _cb; }
78 inline void get_cb();
79 const ImmutableOopMap* oopmap() const { if (_oopmap == nullptr) get_oopmap(); return _oopmap; }
80 inline int frame_size() const;
81 inline int stack_argsize() const;
82 inline int num_oops() const;
83
84 inline void initialize_register_map(RegisterMap* map);
85 template <typename RegisterMapT> inline void next(RegisterMapT* map, bool stop = false);
86
87 template <typename RegisterMapT> inline void update_reg_map(RegisterMapT* map);
88
89 void handle_deopted() const;
90
91 inline frame to_frame() const;
92
93 #ifdef ASSERT
94 bool is_in_frame(void* p) const;
95 template <typename RegisterMapT> bool is_in_oops(void* p, const RegisterMapT* map) const;
96 #endif
97
98 void print_on(outputStream* st) const PRODUCT_RETURN;
99
100 private:
101 inline address get_pc() const;
102
103 inline int interpreter_frame_size() const;
104 inline int interpreter_frame_num_oops() const;
105 inline int interpreter_frame_stack_argsize() const;
106 inline void next_for_interpreter_frame();
107 inline intptr_t* unextended_sp_for_interpreter_frame() const;
108 inline intptr_t* derelativize(int offset) const;
109 inline void get_oopmap() const;
110 inline void get_oopmap(address pc, int oopmap_slot) const;
111
112 template <typename RegisterMapT> inline void update_reg_map_pd(RegisterMapT* map);
113
114 template <typename RegisterMapT>
115 inline void* reg_to_loc(VMReg reg, const RegisterMapT* map) const;
116
117 void assert_is_interpreted_and_frame_type_mixed() const NOT_DEBUG_RETURN;
118
119 public:
120 template <class OopClosureType, class RegisterMapT>
121 inline void iterate_oops(OopClosureType* closure, const RegisterMapT* map) const;
122 template <class DerivedOopClosureType, class RegisterMapT>
123 inline void iterate_derived_pointers(DerivedOopClosureType* closure, const RegisterMapT* map) const;
124 };
125
126 #endif // SHARE_RUNTIME_STACKCHUNKFRAMESTREAM_HPP
|
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 #ifndef SHARE_RUNTIME_STACKCHUNKFRAMESTREAM_HPP
26 #define SHARE_RUNTIME_STACKCHUNKFRAMESTREAM_HPP
27
28 #include "memory/allocation.hpp"
29 #include "memory/iterator.hpp"
30 #include "oops/oopsHierarchy.hpp"
31 #include "utilities/globalDefinitions.hpp"
32 #include "utilities/macros.hpp"
33
34 class CodeBlob;
35 class frame;
36 class ImmutableOopMap;
37 class RegisterMap;
38 class VMRegImpl;
39 typedef VMRegImpl* VMReg;
40
41 enum ChunkFrames { CompiledOnly, Mixed };
42
43 template <ChunkFrames frame_kind>
44 class StackChunkFrameStream : public StackObj {
45 private:
46 intptr_t* _end;
47 intptr_t* _sp;
48 intptr_t* _unextended_sp; // used only when mixed
49 CodeBlob* _cb;
63 inline StackChunkFrameStream(stackChunkOop chunk);
64 inline StackChunkFrameStream(stackChunkOop chunk, const frame& f);
65
66 bool is_done() const { return _sp >= _end; }
67
68 // Query
69 intptr_t* sp() const { return _sp; }
70 inline address pc() const { return get_pc(); }
71 inline intptr_t* fp() const;
72 inline intptr_t* unextended_sp() const { return frame_kind == ChunkFrames::Mixed ? _unextended_sp : _sp; }
73 inline address orig_pc() const;
74
75 inline bool is_interpreted() const;
76 inline bool is_stub() const;
77 inline bool is_compiled() const;
78 CodeBlob* cb() const { return _cb; }
79 inline void get_cb();
80 const ImmutableOopMap* oopmap() const { if (_oopmap == nullptr) get_oopmap(); return _oopmap; }
81 inline int frame_size() const;
82 inline int stack_argsize() const;
83 template <typename RegisterMapT>
84 inline int num_oops(RegisterMapT* map) const;
85
86 inline void initialize_register_map(RegisterMap* map);
87 template <typename RegisterMapT> inline void next(RegisterMapT* map, bool stop = false);
88
89 template <typename RegisterMapT> inline void update_reg_map(RegisterMapT* map);
90
91 void handle_deopted() const;
92
93 inline frame to_frame() const;
94
95 #ifdef ASSERT
96 bool is_in_frame(void* p) const;
97 template <typename RegisterMapT> bool is_in_oops(void* p, const RegisterMapT* map) const;
98 #endif
99
100 void print_on(outputStream* st) const PRODUCT_RETURN;
101
102 private:
103 inline address get_pc() const;
104
105 inline int interpreter_frame_size() const;
106 template <typename RegisterMapT>
107 inline int interpreter_frame_num_oops(RegisterMapT* map) const;
108 inline int interpreter_frame_stack_argsize() const;
109 inline void next_for_interpreter_frame();
110 inline intptr_t* unextended_sp_for_interpreter_frame() const;
111 inline intptr_t* derelativize(int offset) const;
112 inline void get_oopmap() const;
113 inline void get_oopmap(address pc, int oopmap_slot) const;
114
115 template <typename RegisterMapT> inline void update_reg_map_pd(RegisterMapT* map);
116
117 template <typename RegisterMapT>
118 inline void* reg_to_loc(VMReg reg, const RegisterMapT* map) const;
119
120 void assert_is_interpreted_and_frame_type_mixed() const NOT_DEBUG_RETURN;
121
122 public:
123 template <class OopClosureType, class RegisterMapT>
124 inline void iterate_oops(OopClosureType* closure, const RegisterMapT* map) const;
125 template <class DerivedOopClosureType, class RegisterMapT>
126 inline void iterate_derived_pointers(DerivedOopClosureType* closure, const RegisterMapT* map) const;
127 };
128
129 class InterpreterOopCount : public OopClosure {
130 int _count;
131 public:
132 InterpreterOopCount() : _count(0) {}
133 void do_oop(oop* p) override { _count++; }
134 void do_oop(narrowOop* p) override { _count++; }
135 int count() { return _count; }
136 };
137
138 #endif // SHARE_RUNTIME_STACKCHUNKFRAMESTREAM_HPP
|