45 #endif
46
47 #ifdef ASSERT
48 void RegisterMap::check_location_valid() {
49 }
50 #endif // ASSERT
51
52 bool frame::safe_for_sender(JavaThread *thread) {
53 bool safe = false;
54 address sp = (address)_sp;
55 address fp = (address)_fp;
56 address unextended_sp = (address)_unextended_sp;
57
58 // consider stack guards when trying to determine "safe" stack pointers
59 // sp must be within the usable part of the stack (not in guards)
60 if (!thread->is_in_usable_stack(sp)) {
61 return false;
62 }
63
64 // Unextended sp must be within the stack
65 bool unextended_sp_safe = (unextended_sp < thread->stack_base());
66
67 if (!unextended_sp_safe) {
68 return false;
69 }
70
71 // An fp must be within the stack and above (but not equal) sp.
72 bool fp_safe = (fp < thread->stack_base()) && (fp > sp);
73 // An interpreter fp must be within the stack and above (but not equal) sp.
74 // Moreover, it must be at least the size of the ijava_state structure.
75 bool fp_interp_safe = (fp < thread->stack_base()) && (fp > sp) &&
76 ((fp - sp) >= ijava_state_size);
77
78 // We know sp/unextended_sp are safe, only fp is questionable here
79
80 // If the current frame is known to the code cache then we can attempt to
81 // to construct the sender and do some validation of it. This goes a long way
82 // toward eliminating issues when we get in frame construction code
83
84 if (_cb != NULL ){
85 // Entry frame checks
86 if (is_entry_frame()) {
87 // An entry frame must have a valid fp.
88 return fp_safe && is_entry_frame_valid(thread);
89 }
90
91 // Now check if the frame is complete and the test is
92 // reliable. Unfortunately we can only check frame completeness for
93 // runtime stubs and nmethods. Other generic buffer blobs are more
94 // problematic so we just assume they are OK. Adapter blobs never have a
95 // complete frame and are never OK
96 if (!_cb->is_frame_complete_at(_pc)) {
115 // We must always be able to find a recognizable pc.
116 CodeBlob* sender_blob = CodeCache::find_blob_unsafe(sender_pc);
117 if (sender_blob == NULL) {
118 return false;
119 }
120
121 // Could be a zombie method
122 if (sender_blob->is_zombie() || sender_blob->is_unloaded()) {
123 return false;
124 }
125
126 // It should be safe to construct the sender though it might not be valid.
127
128 frame sender(sender_sp, sender_pc);
129
130 // Do we have a valid fp?
131 address sender_fp = (address) sender.fp();
132
133 // sender_fp must be within the stack and above (but not
134 // equal) current frame's fp.
135 if (sender_fp >= thread->stack_base() || sender_fp <= fp) {
136 return false;
137 }
138
139 // If the potential sender is the interpreter then we can do some more checking.
140 if (Interpreter::contains(sender_pc)) {
141 return sender.is_interpreted_frame_valid(thread);
142 }
143
144 // Could just be some random pointer within the codeBlob.
145 if (!sender.cb()->code_contains(sender_pc)) {
146 return false;
147 }
148
149 // We should never be able to see an adapter if the current frame is something from code cache.
150 if (sender_blob->is_adapter_blob()) {
151 return false;
152 }
153
154 if (sender.is_entry_frame()) {
155 return sender.is_entry_frame_valid(thread);
|
45 #endif
46
47 #ifdef ASSERT
48 void RegisterMap::check_location_valid() {
49 }
50 #endif // ASSERT
51
52 bool frame::safe_for_sender(JavaThread *thread) {
53 bool safe = false;
54 address sp = (address)_sp;
55 address fp = (address)_fp;
56 address unextended_sp = (address)_unextended_sp;
57
58 // consider stack guards when trying to determine "safe" stack pointers
59 // sp must be within the usable part of the stack (not in guards)
60 if (!thread->is_in_usable_stack(sp)) {
61 return false;
62 }
63
64 // Unextended sp must be within the stack
65 if (!thread->is_in_full_stack(unextended_sp)) {
66 return false;
67 }
68
69 // An fp must be within the stack and above (but not equal) sp.
70 bool fp_safe = thread->is_in_stack_range_excl(fp, sp);
71 // An interpreter fp must be within the stack and above (but not equal) sp.
72 // Moreover, it must be at least the size of the ijava_state structure.
73 bool fp_interp_safe = fp_safe && ((fp - sp) >= ijava_state_size);
74
75 // We know sp/unextended_sp are safe, only fp is questionable here
76
77 // If the current frame is known to the code cache then we can attempt to
78 // to construct the sender and do some validation of it. This goes a long way
79 // toward eliminating issues when we get in frame construction code
80
81 if (_cb != NULL ){
82 // Entry frame checks
83 if (is_entry_frame()) {
84 // An entry frame must have a valid fp.
85 return fp_safe && is_entry_frame_valid(thread);
86 }
87
88 // Now check if the frame is complete and the test is
89 // reliable. Unfortunately we can only check frame completeness for
90 // runtime stubs and nmethods. Other generic buffer blobs are more
91 // problematic so we just assume they are OK. Adapter blobs never have a
92 // complete frame and are never OK
93 if (!_cb->is_frame_complete_at(_pc)) {
112 // We must always be able to find a recognizable pc.
113 CodeBlob* sender_blob = CodeCache::find_blob_unsafe(sender_pc);
114 if (sender_blob == NULL) {
115 return false;
116 }
117
118 // Could be a zombie method
119 if (sender_blob->is_zombie() || sender_blob->is_unloaded()) {
120 return false;
121 }
122
123 // It should be safe to construct the sender though it might not be valid.
124
125 frame sender(sender_sp, sender_pc);
126
127 // Do we have a valid fp?
128 address sender_fp = (address) sender.fp();
129
130 // sender_fp must be within the stack and above (but not
131 // equal) current frame's fp.
132 if (!thread->is_in_stack_range_excl(sender_fp, fp)) {
133 return false;
134 }
135
136 // If the potential sender is the interpreter then we can do some more checking.
137 if (Interpreter::contains(sender_pc)) {
138 return sender.is_interpreted_frame_valid(thread);
139 }
140
141 // Could just be some random pointer within the codeBlob.
142 if (!sender.cb()->code_contains(sender_pc)) {
143 return false;
144 }
145
146 // We should never be able to see an adapter if the current frame is something from code cache.
147 if (sender_blob->is_adapter_blob()) {
148 return false;
149 }
150
151 if (sender.is_entry_frame()) {
152 return sender.is_entry_frame_valid(thread);
|