214
215 bool frame::entry_frame_is_first() const {
216 return entry_frame_call_wrapper()->is_first_frame();
217 }
218
219 JavaCallWrapper* frame::entry_frame_call_wrapper_if_safe(JavaThread* thread) const {
220 JavaCallWrapper** jcw = entry_frame_call_wrapper_addr();
221 address addr = (address) jcw;
222
223 // addr must be within the usable part of the stack
224 if (thread->is_in_usable_stack(addr)) {
225 return *jcw;
226 }
227
228 return NULL;
229 }
230
231 bool frame::is_entry_frame_valid(JavaThread* thread) const {
232 // Validate the JavaCallWrapper an entry frame must have
233 address jcw = (address)entry_frame_call_wrapper();
234 bool jcw_safe = (jcw < thread->stack_base()) && (jcw > (address)fp()); // less than stack base
235 if (!jcw_safe) {
236 return false;
237 }
238
239 // Validate sp saved in the java frame anchor
240 JavaFrameAnchor* jfa = entry_frame_call_wrapper()->anchor();
241 return (jfa->last_Java_sp() > sp());
242 }
243
244 bool frame::should_be_deoptimized() const {
245 if (_deopt_state == is_deoptimized ||
246 !is_compiled_frame() ) return false;
247 assert(_cb != NULL && _cb->is_compiled(), "must be an nmethod");
248 CompiledMethod* nm = (CompiledMethod *)_cb;
249 if (TraceDependencies) {
250 tty->print("checking (%s) ", nm->is_marked_for_deoptimization() ? "true" : "false");
251 nm->print_value_on(tty);
252 tty->cr();
253 }
254
255 if( !nm->is_marked_for_deoptimization() )
1267 } else {
1268 prev = fv;
1269 }
1270 }
1271 assert(!error, "invalid layout");
1272 }
1273 #endif // ASSERT
1274
1275 void FrameValues::print(JavaThread* thread) {
1276 _values.sort(compare);
1277
1278 // Sometimes values like the fp can be invalid values if the
1279 // register map wasn't updated during the walk. Trim out values
1280 // that aren't actually in the stack of the thread.
1281 int min_index = 0;
1282 int max_index = _values.length() - 1;
1283 intptr_t* v0 = _values.at(min_index).location;
1284 intptr_t* v1 = _values.at(max_index).location;
1285
1286 if (thread == Thread::current()) {
1287 while (!thread->is_in_stack((address)v0)) {
1288 v0 = _values.at(++min_index).location;
1289 }
1290 while (!thread->is_in_stack((address)v1)) {
1291 v1 = _values.at(--max_index).location;
1292 }
1293 } else {
1294 while (!thread->on_local_stack((address)v0)) {
1295 v0 = _values.at(++min_index).location;
1296 }
1297 while (!thread->on_local_stack((address)v1)) {
1298 v1 = _values.at(--max_index).location;
1299 }
1300 }
1301 intptr_t* min = MIN2(v0, v1);
1302 intptr_t* max = MAX2(v0, v1);
1303 intptr_t* cur = max;
1304 intptr_t* last = NULL;
1305 for (int i = max_index; i >= min_index; i--) {
1306 FrameValue fv = _values.at(i);
1307 while (cur > fv.location) {
1308 tty->print_cr(" " INTPTR_FORMAT ": " INTPTR_FORMAT, p2i(cur), *cur);
1309 cur--;
1310 }
1311 if (last == fv.location) {
1312 const char* spacer = " " LP64_ONLY(" ");
1313 tty->print_cr(" %s %s %s", spacer, spacer, fv.description);
1314 } else {
1315 tty->print_cr(" " INTPTR_FORMAT ": " INTPTR_FORMAT " %s", p2i(fv.location), *fv.location, fv.description);
1316 last = fv.location;
1317 cur--;
|
214
215 bool frame::entry_frame_is_first() const {
216 return entry_frame_call_wrapper()->is_first_frame();
217 }
218
219 JavaCallWrapper* frame::entry_frame_call_wrapper_if_safe(JavaThread* thread) const {
220 JavaCallWrapper** jcw = entry_frame_call_wrapper_addr();
221 address addr = (address) jcw;
222
223 // addr must be within the usable part of the stack
224 if (thread->is_in_usable_stack(addr)) {
225 return *jcw;
226 }
227
228 return NULL;
229 }
230
231 bool frame::is_entry_frame_valid(JavaThread* thread) const {
232 // Validate the JavaCallWrapper an entry frame must have
233 address jcw = (address)entry_frame_call_wrapper();
234 if (!thread->is_in_stack_range_excl(jcw, (address)fp())) {
235 return false;
236 }
237
238 // Validate sp saved in the java frame anchor
239 JavaFrameAnchor* jfa = entry_frame_call_wrapper()->anchor();
240 return (jfa->last_Java_sp() > sp());
241 }
242
243 bool frame::should_be_deoptimized() const {
244 if (_deopt_state == is_deoptimized ||
245 !is_compiled_frame() ) return false;
246 assert(_cb != NULL && _cb->is_compiled(), "must be an nmethod");
247 CompiledMethod* nm = (CompiledMethod *)_cb;
248 if (TraceDependencies) {
249 tty->print("checking (%s) ", nm->is_marked_for_deoptimization() ? "true" : "false");
250 nm->print_value_on(tty);
251 tty->cr();
252 }
253
254 if( !nm->is_marked_for_deoptimization() )
1266 } else {
1267 prev = fv;
1268 }
1269 }
1270 assert(!error, "invalid layout");
1271 }
1272 #endif // ASSERT
1273
1274 void FrameValues::print(JavaThread* thread) {
1275 _values.sort(compare);
1276
1277 // Sometimes values like the fp can be invalid values if the
1278 // register map wasn't updated during the walk. Trim out values
1279 // that aren't actually in the stack of the thread.
1280 int min_index = 0;
1281 int max_index = _values.length() - 1;
1282 intptr_t* v0 = _values.at(min_index).location;
1283 intptr_t* v1 = _values.at(max_index).location;
1284
1285 if (thread == Thread::current()) {
1286 while (!thread->is_in_live_stack((address)v0)) {
1287 v0 = _values.at(++min_index).location;
1288 }
1289 while (!thread->is_in_live_stack((address)v1)) {
1290 v1 = _values.at(--max_index).location;
1291 }
1292 } else {
1293 while (!thread->is_in_full_stack((address)v0)) {
1294 v0 = _values.at(++min_index).location;
1295 }
1296 while (!thread->is_in_full_stack((address)v1)) {
1297 v1 = _values.at(--max_index).location;
1298 }
1299 }
1300 intptr_t* min = MIN2(v0, v1);
1301 intptr_t* max = MAX2(v0, v1);
1302 intptr_t* cur = max;
1303 intptr_t* last = NULL;
1304 for (int i = max_index; i >= min_index; i--) {
1305 FrameValue fv = _values.at(i);
1306 while (cur > fv.location) {
1307 tty->print_cr(" " INTPTR_FORMAT ": " INTPTR_FORMAT, p2i(cur), *cur);
1308 cur--;
1309 }
1310 if (last == fv.location) {
1311 const char* spacer = " " LP64_ONLY(" ");
1312 tty->print_cr(" %s %s %s", spacer, spacer, fv.description);
1313 } else {
1314 tty->print_cr(" " INTPTR_FORMAT ": " INTPTR_FORMAT " %s", p2i(fv.location), *fv.location, fv.description);
1315 last = fv.location;
1316 cur--;
|