comparison src/share/vm/prims/jvmtiEnv.cpp @ 14653:0d8d78c0329a

6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync") Summary: It is more safe to get/update data for suspended threads at a safepoint Reviewed-by: dcubed, twisti, dholmes Contributed-by: serguei.spitsyn@oracle.com
author sspitsyn
date Sat, 01 Mar 2014 08:05:55 -0800
parents 402677ca28ed
children b51e29501f30
comparison
equal deleted inserted replaced
14652:ef7328717719 14653:0d8d78c0329a
1462 // (see call_VM_base() in assembler_<cpu>.cpp). 1462 // (see call_VM_base() in assembler_<cpu>.cpp).
1463 1463
1464 // It's fine to update the thread state here because no JVMTI events 1464 // It's fine to update the thread state here because no JVMTI events
1465 // shall be posted for this PopFrame. 1465 // shall be posted for this PopFrame.
1466 1466
1467 state->update_for_pop_top_frame(); 1467 // It is only safe to perform the direct operation on the current
1468 // thread. All other usage needs to use a vm-safepoint-op for safety.
1469 if (java_thread == JavaThread::current()) {
1470 state->update_for_pop_top_frame();
1471 } else {
1472 VM_UpdateForPopTopFrame op(state);
1473 VMThread::execute(&op);
1474 jvmtiError err = op.result();
1475 if (err != JVMTI_ERROR_NONE) {
1476 return err;
1477 }
1478 }
1479
1468 java_thread->set_popframe_condition(JavaThread::popframe_pending_bit); 1480 java_thread->set_popframe_condition(JavaThread::popframe_pending_bit);
1469 // Set pending step flag for this popframe and it is cleared when next 1481 // Set pending step flag for this popframe and it is cleared when next
1470 // step event is posted. 1482 // step event is posted.
1471 state->set_pending_step_for_popframe(); 1483 state->set_pending_step_for_popframe();
1472 } 1484 }
1503 // java_thread - pre-checked 1515 // java_thread - pre-checked
1504 // java_thread - unchecked 1516 // java_thread - unchecked
1505 // depth - pre-checked as non-negative 1517 // depth - pre-checked as non-negative
1506 jvmtiError 1518 jvmtiError
1507 JvmtiEnv::NotifyFramePop(JavaThread* java_thread, jint depth) { 1519 JvmtiEnv::NotifyFramePop(JavaThread* java_thread, jint depth) {
1520 jvmtiError err = JVMTI_ERROR_NONE;
1508 ResourceMark rm; 1521 ResourceMark rm;
1509 uint32_t debug_bits = 0; 1522 uint32_t debug_bits = 0;
1510 1523
1511 JvmtiThreadState *state = JvmtiThreadState::state_for(java_thread); 1524 JvmtiThreadState *state = JvmtiThreadState::state_for(java_thread);
1512 if (state == NULL) { 1525 if (state == NULL) {
1530 return JVMTI_ERROR_OPAQUE_FRAME; 1543 return JVMTI_ERROR_OPAQUE_FRAME;
1531 } 1544 }
1532 1545
1533 assert(vf->frame_pointer() != NULL, "frame pointer mustn't be NULL"); 1546 assert(vf->frame_pointer() != NULL, "frame pointer mustn't be NULL");
1534 1547
1535 int frame_number = state->count_frames() - depth; 1548 // It is only safe to perform the direct operation on the current
1536 state->env_thread_state(this)->set_frame_pop(frame_number); 1549 // thread. All other usage needs to use a vm-safepoint-op for safety.
1537 1550 if (java_thread == JavaThread::current()) {
1538 return JVMTI_ERROR_NONE; 1551 int frame_number = state->count_frames() - depth;
1552 state->env_thread_state(this)->set_frame_pop(frame_number);
1553 } else {
1554 VM_SetFramePop op(this, state, depth);
1555 VMThread::execute(&op);
1556 err = op.result();
1557 }
1558 return err;
1539 } /* end NotifyFramePop */ 1559 } /* end NotifyFramePop */
1540 1560
1541 1561
1542 // 1562 //
1543 // Force Early Return functions 1563 // Force Early Return functions