< prev index next >

src/hotspot/share/prims/jvmtiImpl.cpp

Print this page




 571   javaVFrame *jvf = (javaVFrame*)vf;
 572 
 573   if (!vf->is_java_frame()) {
 574     _result = JVMTI_ERROR_OPAQUE_FRAME;
 575     return NULL;
 576   }
 577   return jvf;
 578 }
 579 
 580 // Check that the klass is assignable to a type with the given signature.
 581 // Another solution could be to use the function Klass::is_subtype_of(type).
 582 // But the type class can be forced to load/initialize eagerly in such a case.
 583 // This may cause unexpected consequences like CFLH or class-init JVMTI events.
 584 // It is better to avoid such a behavior.
 585 bool VM_GetOrSetLocal::is_assignable(const char* ty_sign, Klass* klass, Thread* thread) {
 586   assert(ty_sign != NULL, "type signature must not be NULL");
 587   assert(thread != NULL, "thread must not be NULL");
 588   assert(klass != NULL, "klass must not be NULL");
 589 
 590   int len = (int) strlen(ty_sign);
 591   if (ty_sign[0] == 'L' && ty_sign[len-1] == ';') { // Need pure class/interface name
 592     ty_sign++;
 593     len -= 2;
 594   }
 595   TempNewSymbol ty_sym = SymbolTable::new_symbol(ty_sign, len);
 596   if (klass->name() == ty_sym) {
 597     return true;
 598   }
 599   // Compare primary supers
 600   int super_depth = klass->super_depth();
 601   int idx;
 602   for (idx = 0; idx < super_depth; idx++) {
 603     if (klass->primary_super_of_depth(idx)->name() == ty_sym) {
 604       return true;
 605     }
 606   }
 607   // Compare secondary supers
 608   const Array<Klass*>* sec_supers = klass->secondary_supers();
 609   for (idx = 0; idx < sec_supers->length(); idx++) {
 610     if (((Klass*) sec_supers->at(idx))->name() == ty_sym) {
 611       return true;


 754     // Force deoptimization of frame if compiled because it's
 755     // possible the compiler emitted some locals as constant values,
 756     // meaning they are not mutable.
 757     if (can_be_deoptimized(_jvf)) {
 758 
 759       // Schedule deoptimization so that eventually the local
 760       // update will be written to an interpreter frame.
 761       Deoptimization::deoptimize_frame(_jvf->thread(), _jvf->fr().id());
 762 
 763       // Now store a new value for the local which will be applied
 764       // once deoptimization occurs. Note however that while this
 765       // write is deferred until deoptimization actually happens
 766       // can vframe created after this point will have its locals
 767       // reflecting this update so as far as anyone can see the
 768       // write has already taken place.
 769 
 770       // If we are updating an oop then get the oop from the handle
 771       // since the handle will be long gone by the time the deopt
 772       // happens. The oop stored in the deferred local will be
 773       // gc'd on its own.
 774       if (_type == T_OBJECT) {
 775         _value.l = (jobject) (JNIHandles::resolve_external_guard(_value.l));
 776       }
 777       // Re-read the vframe so we can see that it is deoptimized
 778       // [ Only need because of assert in update_local() ]
 779       _jvf = get_java_vframe();
 780       ((compiledVFrame*)_jvf)->update_local(_type, _index, _value);
 781       return;
 782     }
 783     StackValueCollection *locals = _jvf->locals();
 784     HandleMark hm;
 785 
 786     switch (_type) {
 787       case T_INT:    locals->set_int_at   (_index, _value.i); break;
 788       case T_LONG:   locals->set_long_at  (_index, _value.j); break;
 789       case T_FLOAT:  locals->set_float_at (_index, _value.f); break;
 790       case T_DOUBLE: locals->set_double_at(_index, _value.d); break;
 791       case T_OBJECT: {

 792         Handle ob_h(Thread::current(), JNIHandles::resolve_external_guard(_value.l));
 793         locals->set_obj_at (_index, ob_h);
 794         break;
 795       }
 796       default: ShouldNotReachHere();
 797     }
 798     _jvf->set_locals(locals);
 799   } else {
 800     if (_jvf->method()->is_native() && _jvf->is_compiled_frame()) {
 801       assert(getting_receiver(), "Can only get here when getting receiver");
 802       oop receiver = _jvf->fr().get_native_receiver();
 803       _value.l = JNIHandles::make_local(_calling_thread, receiver);
 804     } else {
 805       StackValueCollection *locals = _jvf->locals();
 806 
 807       switch (_type) {
 808         case T_INT:    _value.i = locals->int_at   (_index);   break;
 809         case T_LONG:   _value.j = locals->long_at  (_index);   break;
 810         case T_FLOAT:  _value.f = locals->float_at (_index);   break;
 811         case T_DOUBLE: _value.d = locals->double_at(_index);   break;
 812         case T_OBJECT: {

 813           // Wrap the oop to be returned in a local JNI handle since
 814           // oops_do() no longer applies after doit() is finished.
 815           oop obj = locals->obj_at(_index)();
 816           _value.l = JNIHandles::make_local(_calling_thread, obj);
 817           break;
 818         }
 819         default: ShouldNotReachHere();
 820       }
 821     }
 822   }
 823 }
 824 
 825 
 826 bool VM_GetOrSetLocal::allow_nested_vm_operations() const {
 827   return true; // May need to deoptimize
 828 }
 829 
 830 
 831 VM_GetReceiver::VM_GetReceiver(
 832     JavaThread* thread, JavaThread* caller_thread, jint depth)




 571   javaVFrame *jvf = (javaVFrame*)vf;
 572 
 573   if (!vf->is_java_frame()) {
 574     _result = JVMTI_ERROR_OPAQUE_FRAME;
 575     return NULL;
 576   }
 577   return jvf;
 578 }
 579 
 580 // Check that the klass is assignable to a type with the given signature.
 581 // Another solution could be to use the function Klass::is_subtype_of(type).
 582 // But the type class can be forced to load/initialize eagerly in such a case.
 583 // This may cause unexpected consequences like CFLH or class-init JVMTI events.
 584 // It is better to avoid such a behavior.
 585 bool VM_GetOrSetLocal::is_assignable(const char* ty_sign, Klass* klass, Thread* thread) {
 586   assert(ty_sign != NULL, "type signature must not be NULL");
 587   assert(thread != NULL, "thread must not be NULL");
 588   assert(klass != NULL, "klass must not be NULL");
 589 
 590   int len = (int) strlen(ty_sign);
 591   if ((ty_sign[0] == 'L' || ty_sign[0] == 'Q') && ty_sign[len-1] == ';') { // Need pure class/interface name
 592     ty_sign++;
 593     len -= 2;
 594   }
 595   TempNewSymbol ty_sym = SymbolTable::new_symbol(ty_sign, len);
 596   if (klass->name() == ty_sym) {
 597     return true;
 598   }
 599   // Compare primary supers
 600   int super_depth = klass->super_depth();
 601   int idx;
 602   for (idx = 0; idx < super_depth; idx++) {
 603     if (klass->primary_super_of_depth(idx)->name() == ty_sym) {
 604       return true;
 605     }
 606   }
 607   // Compare secondary supers
 608   const Array<Klass*>* sec_supers = klass->secondary_supers();
 609   for (idx = 0; idx < sec_supers->length(); idx++) {
 610     if (((Klass*) sec_supers->at(idx))->name() == ty_sym) {
 611       return true;


 754     // Force deoptimization of frame if compiled because it's
 755     // possible the compiler emitted some locals as constant values,
 756     // meaning they are not mutable.
 757     if (can_be_deoptimized(_jvf)) {
 758 
 759       // Schedule deoptimization so that eventually the local
 760       // update will be written to an interpreter frame.
 761       Deoptimization::deoptimize_frame(_jvf->thread(), _jvf->fr().id());
 762 
 763       // Now store a new value for the local which will be applied
 764       // once deoptimization occurs. Note however that while this
 765       // write is deferred until deoptimization actually happens
 766       // can vframe created after this point will have its locals
 767       // reflecting this update so as far as anyone can see the
 768       // write has already taken place.
 769 
 770       // If we are updating an oop then get the oop from the handle
 771       // since the handle will be long gone by the time the deopt
 772       // happens. The oop stored in the deferred local will be
 773       // gc'd on its own.
 774       if (_type == T_OBJECT || _type == T_VALUETYPE) {
 775         _value.l = (jobject) (JNIHandles::resolve_external_guard(_value.l));
 776       }
 777       // Re-read the vframe so we can see that it is deoptimized
 778       // [ Only need because of assert in update_local() ]
 779       _jvf = get_java_vframe();
 780       ((compiledVFrame*)_jvf)->update_local(_type, _index, _value);
 781       return;
 782     }
 783     StackValueCollection *locals = _jvf->locals();
 784     HandleMark hm;
 785 
 786     switch (_type) {
 787       case T_INT:    locals->set_int_at   (_index, _value.i); break;
 788       case T_LONG:   locals->set_long_at  (_index, _value.j); break;
 789       case T_FLOAT:  locals->set_float_at (_index, _value.f); break;
 790       case T_DOUBLE: locals->set_double_at(_index, _value.d); break;
 791       case T_OBJECT:
 792       case T_VALUETYPE: {
 793         Handle ob_h(Thread::current(), JNIHandles::resolve_external_guard(_value.l));
 794         locals->set_obj_at (_index, ob_h);
 795         break;
 796       }
 797       default: ShouldNotReachHere();
 798     }
 799     _jvf->set_locals(locals);
 800   } else {
 801     if (_jvf->method()->is_native() && _jvf->is_compiled_frame()) {
 802       assert(getting_receiver(), "Can only get here when getting receiver");
 803       oop receiver = _jvf->fr().get_native_receiver();
 804       _value.l = JNIHandles::make_local(_calling_thread, receiver);
 805     } else {
 806       StackValueCollection *locals = _jvf->locals();
 807 
 808       switch (_type) {
 809         case T_INT:    _value.i = locals->int_at   (_index);   break;
 810         case T_LONG:   _value.j = locals->long_at  (_index);   break;
 811         case T_FLOAT:  _value.f = locals->float_at (_index);   break;
 812         case T_DOUBLE: _value.d = locals->double_at(_index);   break;
 813         case T_OBJECT:
 814         case T_VALUETYPE: {
 815           // Wrap the oop to be returned in a local JNI handle since
 816           // oops_do() no longer applies after doit() is finished.
 817           oop obj = locals->obj_at(_index)();
 818           _value.l = JNIHandles::make_local(_calling_thread, obj);
 819           break;
 820         }
 821         default: ShouldNotReachHere();
 822       }
 823     }
 824   }
 825 }
 826 
 827 
 828 bool VM_GetOrSetLocal::allow_nested_vm_operations() const {
 829   return true; // May need to deoptimize
 830 }
 831 
 832 
 833 VM_GetReceiver::VM_GetReceiver(
 834     JavaThread* thread, JavaThread* caller_thread, jint depth)


< prev index next >