void InterfaceSupport::verify_last_frame() { JavaThread* thread = JavaThread::current(); ResourceMark rm(thread); RegisterMap reg_map(thread); frame fr = thread->last_frame(); fr.verify(®_map); }
void ThreadStackTrace::dump_stack_at_safepoint(int maxDepth) { assert(SafepointSynchronize::is_at_safepoint(), "all threads are stopped"); if (_thread->has_last_Java_frame()) { RegisterMap reg_map(_thread); vframe* start_vf = _thread->last_java_vframe(®_map); int count = 0; for (vframe* f = start_vf; f; f = f->sender() ) { if (f->is_java_frame()) { javaVFrame* jvf = javaVFrame::cast(f); add_stack_frame(jvf); count++; } else { // Ignore non-Java frames } if (maxDepth > 0 && count == maxDepth) { // Skip frames if more than maxDepth break; } } } if (_with_locked_monitors) { // Iterate inflated monitors and find monitors locked by this thread // not found in the stack InflatedMonitorsClosure imc(_thread, this); ObjectSynchronizer::monitors_iterate(&imc); } }
unsigned long VpuWriteReg(unsigned long addr, unsigned int data) { unsigned long *reg_addr = reg_map(addr); *(volatile unsigned long *)reg_addr = data; return 0; }
/*{{{ log_open -- log bit_open*/ void log_open(BITMAP *bp) { bp->id = get_mid(); reg_map(bp); if (do_save) SEND_screen(bp->id, bp->wide, bp->high, 0); }
// // Count the number of objects for a lightweight monitor. The hobj // parameter is object that owns the monitor so this routine will // count the number of times the same object was locked by frames // in java_thread. // jint JvmtiEnvBase::count_locked_objects(JavaThread *java_thread, Handle hobj) { jint ret = 0; if (!java_thread->has_last_Java_frame()) { return ret; // no Java frames so no monitors } ResourceMark rm; HandleMark hm; RegisterMap reg_map(java_thread); for(javaVFrame *jvf=java_thread->last_java_vframe(®_map); jvf != NULL; jvf = jvf->java_sender()) { GrowableArray<MonitorInfo*>* mons = jvf->monitors(); if (!mons->is_empty()) { for (int i = 0; i < mons->length(); i++) { MonitorInfo *mi = mons->at(i); if (mi->owner_is_scalar_replaced()) continue; // see if owner of the monitor is our object if (mi->owner() != NULL && mi->owner() == hobj()) { ret++; } } } } return ret; }
void InterfaceSupport::walk_stack() { JavaThread* thread = JavaThread::current(); walk_stack_counter++; if (!thread->has_last_Java_frame()) return; ResourceMark rm(thread); RegisterMap reg_map(thread); walk_stack_from(thread->last_java_vframe(®_map)); }
static bool caller_is_deopted() { JavaThread* thread = JavaThread::current(); RegisterMap reg_map(thread, false); frame runtime_frame = thread->last_frame(); frame caller_frame = runtime_frame.sender(®_map); assert(caller_frame.is_compiled_frame(), "must be compiled"); return caller_frame.is_deoptimized_frame(); }
/*! * @brief * When the system starts up, resetting is needed in advance. */ void ResetVpu(void) { unsigned long *reg_addr = reg_map(BIT_CODE_RESET); (*(volatile unsigned long *)reg_addr) |= 0x1; usleep(10); (*(volatile unsigned long *)reg_addr) &= ~0x1; return; }
// Stress deoptimization static void deopt_caller() { if ( !caller_is_deopted()) { JavaThread* thread = JavaThread::current(); RegisterMap reg_map(thread, false); frame runtime_frame = thread->last_frame(); frame caller_frame = runtime_frame.sender(®_map); Deoptimization::deoptimize_frame(thread, caller_frame.id()); assert(caller_is_deopted(), "Must be deoptimized"); } }
/*{{{ log_alloc -- log bit_alloc*/ void log_alloc(BITMAP *bp) { int id; id = get_mid(); bp->id = id; reg_map(bp); if (do_save) SEND_data(id, BIT_WIDE(bp), BIT_HIGH(bp), BIT_DATA(bp)); }
/*{{{ log_create -- log bit_create*/ void log_create(BITMAP *bp) { if (bp->id == 0) { /* static bitmap */ bp->id = get_mid(); reg_map(bp); if (do_save) SEND_data(bp->id, bp->wide, bp->high, bp->data); /* create a "real" bitmap */ bp->type &= ~_DIRTY; } }
// return the vframe on the specified thread and depth, NULL if no such frame vframe* JvmtiEnvBase::vframeFor(JavaThread* java_thread, jint depth) { if (!java_thread->has_last_Java_frame()) { return NULL; } RegisterMap reg_map(java_thread); vframe *vf = java_thread->last_java_vframe(®_map); int d = 0; while ((vf != NULL) && (d < depth)) { vf = vf->java_sender(); d++; } return vf; }
/*{{{ check_map -- check bitmap, register and/or download if needed*/ static int check_map(BITMAP *map) { if (map && map->primary->id == 0) { /* static bitmap */ map->primary->id = get_mid(); reg_map(map->primary); map->primary->type |= _DIRTY; } if (map && do_save && map->primary->type & _DIRTY) { SEND_data(map->id, map->primary->wide, map->primary->high, map->data); map->primary->type &= ~_DIRTY; return (1); } return (0); }
extern "C" void ps() { // print stack Command c("ps"); // Prints the stack of the current Java thread JavaThread* p = JavaThread::active(); tty->print(" for thread: "); p->print(); tty->cr(); if (p->has_last_Java_frame()) { // If the last_Java_fp is set we are in C land and // can call the standard stack_trace function. p->trace_stack(); } else { frame f = os::current_frame(); RegisterMap reg_map(p); f = f.sender(®_map); tty->print("(guessing starting frame id=%#p based on current fp)\n", f.id()); p->trace_stack_from(vframe::new_vframe(&f, ®_map, p)); pd_ps(f); } }
jvmtiError JvmtiEnvBase::get_owned_monitors(JavaThread *calling_thread, JavaThread* java_thread, GrowableArray<jvmtiMonitorStackDepthInfo*> *owned_monitors_list) { jvmtiError err = JVMTI_ERROR_NONE; #ifdef ASSERT uint32_t debug_bits = 0; #endif assert((SafepointSynchronize::is_at_safepoint() || is_thread_fully_suspended(java_thread, false, &debug_bits)), "at safepoint or target thread is suspended"); if (java_thread->has_last_Java_frame()) { ResourceMark rm; HandleMark hm; RegisterMap reg_map(java_thread); int depth = 0; for (javaVFrame *jvf = java_thread->last_java_vframe(®_map); jvf != NULL; jvf = jvf->java_sender()) { if (depth++ < MaxJavaStackTraceDepth) { // check for stack too deep // add locked objects for this frame into list err = get_locked_objects_in_frame(calling_thread, java_thread, jvf, owned_monitors_list, depth-1); if (err != JVMTI_ERROR_NONE) { return err; } } } } // Get off stack monitors. (e.g. acquired via jni MonitorEnter). JvmtiMonitorClosure jmc(java_thread, calling_thread, owned_monitors_list, this); ObjectSynchronizer::monitors_iterate(&jmc); err = jmc.error(); return err; }
unsigned long VpuReadReg(unsigned long addr) { unsigned long *reg_addr = reg_map(addr); return *(volatile unsigned long *)reg_addr; }
jvmtiError JvmtiEnvBase::get_stack_trace(JavaThread *java_thread, jint start_depth, jint max_count, jvmtiFrameInfo* frame_buffer, jint* count_ptr) { #ifdef ASSERT uint32_t debug_bits = 0; #endif assert((SafepointSynchronize::is_at_safepoint() || is_thread_fully_suspended(java_thread, false, &debug_bits)), "at safepoint or target thread is suspended"); int count = 0; if (java_thread->has_last_Java_frame()) { RegisterMap reg_map(java_thread); Thread* current_thread = Thread::current(); ResourceMark rm(current_thread); javaVFrame *jvf = java_thread->last_java_vframe(®_map); HandleMark hm(current_thread); if (start_depth != 0) { if (start_depth > 0) { for (int j = 0; j < start_depth && jvf != NULL; j++) { jvf = jvf->java_sender(); } if (jvf == NULL) { // start_depth is deeper than the stack depth return JVMTI_ERROR_ILLEGAL_ARGUMENT; } } else { // start_depth < 0 // we are referencing the starting depth based on the oldest // part of the stack. // optimize to limit the number of times that java_sender() is called javaVFrame *jvf_cursor = jvf; javaVFrame *jvf_prev = NULL; javaVFrame *jvf_prev_prev; int j = 0; while (jvf_cursor != NULL) { jvf_prev_prev = jvf_prev; jvf_prev = jvf_cursor; for (j = 0; j > start_depth && jvf_cursor != NULL; j--) { jvf_cursor = jvf_cursor->java_sender(); } } if (j == start_depth) { // previous pointer is exactly where we want to start jvf = jvf_prev; } else { // we need to back up further to get to the right place if (jvf_prev_prev == NULL) { // the -start_depth is greater than the stack depth return JVMTI_ERROR_ILLEGAL_ARGUMENT; } // j now is the number of frames on the stack starting with // jvf_prev, we start from jvf_prev_prev and move older on // the stack that many, the result is -start_depth frames // remaining. jvf = jvf_prev_prev; for (; j < 0; j++) { jvf = jvf->java_sender(); } } } } for (; count < max_count && jvf != NULL; count++) { frame_buffer[count].method = jvf->method()->jmethod_id(); frame_buffer[count].location = (jvf->method()->is_native() ? -1 : jvf->bci()); jvf = jvf->java_sender(); } } else { if (start_depth != 0) { // no frames and there is a starting depth return JVMTI_ERROR_ILLEGAL_ARGUMENT; } } *count_ptr = count; return JVMTI_ERROR_NONE; }