hotspot/src/share/vm/prims/stackwalk.cpp
changeset 43677 5228814c1da2
parent 41664 07e88a4b405f
child 46289 1904e7ec236e
equal deleted inserted replaced
43675:a2b322083029 43677:5228814c1da2
   171   } else {
   171   } else {
   172     frames_array->obj_at_put(index, method->method_holder()->java_mirror());
   172     frames_array->obj_at_put(index, method->method_holder()->java_mirror());
   173   }
   173   }
   174 }
   174 }
   175 
   175 
   176 oop LiveFrameStream::create_primitive_value_instance(StackValueCollection* values, int i, TRAPS) {
   176 // Create and return a LiveStackFrame.PrimitiveSlot (if needed) for the
       
   177 // StackValue at the given index. 'type' is expected to be T_INT, T_LONG,
       
   178 // T_OBJECT, or T_CONFLICT.
       
   179 oop LiveFrameStream::create_primitive_slot_instance(StackValueCollection* values,
       
   180                                                     int i, BasicType type, TRAPS) {
   177   Klass* k = SystemDictionary::resolve_or_null(vmSymbols::java_lang_LiveStackFrameInfo(), CHECK_NULL);
   181   Klass* k = SystemDictionary::resolve_or_null(vmSymbols::java_lang_LiveStackFrameInfo(), CHECK_NULL);
   178   instanceKlassHandle ik (THREAD, k);
   182   instanceKlassHandle ik (THREAD, k);
   179 
   183 
   180   JavaValue result(T_OBJECT);
   184   JavaValue result(T_OBJECT);
   181   JavaCallArguments args;
   185   JavaCallArguments args;
   182   Symbol* signature = NULL;
   186   Symbol* signature = NULL;
   183 
   187 
   184   // ## TODO: type is only available in LocalVariable table, if present.
   188   // ## TODO: type is only available in LocalVariable table, if present.
   185   // ## StackValue type is T_INT or T_OBJECT.
   189   // ## StackValue type is T_INT or T_OBJECT (or converted to T_LONG on 64-bit)
   186   switch (values->at(i)->type()) {
   190   switch (type) {
   187     case T_INT:
   191     case T_INT:
   188       args.push_int(values->int_at(i));
   192       args.push_int(values->int_at(i));
   189       signature = vmSymbols::asPrimitive_int_signature();
   193       signature = vmSymbols::asPrimitive_int_signature();
   190       break;
   194       break;
   191 
   195 
   193       args.push_long(values->long_at(i));
   197       args.push_long(values->long_at(i));
   194       signature = vmSymbols::asPrimitive_long_signature();
   198       signature = vmSymbols::asPrimitive_long_signature();
   195       break;
   199       break;
   196 
   200 
   197     case T_FLOAT:
   201     case T_FLOAT:
   198       args.push_float(values->float_at(i));
       
   199       signature = vmSymbols::asPrimitive_float_signature();
       
   200       break;
       
   201 
       
   202     case T_DOUBLE:
   202     case T_DOUBLE:
   203       args.push_double(values->double_at(i));
       
   204       signature = vmSymbols::asPrimitive_double_signature();
       
   205       break;
       
   206 
       
   207     case T_BYTE:
   203     case T_BYTE:
   208       args.push_int(values->int_at(i));
       
   209       signature = vmSymbols::asPrimitive_byte_signature();
       
   210       break;
       
   211 
       
   212     case T_SHORT:
   204     case T_SHORT:
   213       args.push_int(values->int_at(i));
       
   214       signature = vmSymbols::asPrimitive_short_signature();
       
   215       break;
       
   216 
       
   217     case T_CHAR:
   205     case T_CHAR:
   218       args.push_int(values->int_at(i));
       
   219       signature = vmSymbols::asPrimitive_char_signature();
       
   220       break;
       
   221 
       
   222     case T_BOOLEAN:
   206     case T_BOOLEAN:
   223       args.push_int(values->int_at(i));
   207       THROW_MSG_(vmSymbols::java_lang_InternalError(), "Unexpected StackValue type", NULL);
   224       signature = vmSymbols::asPrimitive_boolean_signature();
       
   225       break;
       
   226 
   208 
   227     case T_OBJECT:
   209     case T_OBJECT:
   228       return values->obj_at(i)();
   210       return values->obj_at(i)();
   229 
   211 
   230     case T_CONFLICT:
   212     case T_CONFLICT:
   231       // put a non-null slot
   213       // put a non-null slot
   232       args.push_int(0);
   214       #ifdef _LP64
   233       signature = vmSymbols::asPrimitive_int_signature();
   215         args.push_long(0);
       
   216         signature = vmSymbols::asPrimitive_long_signature();
       
   217       #else
       
   218         args.push_int(0);
       
   219         signature = vmSymbols::asPrimitive_int_signature();
       
   220       #endif
       
   221 
   234       break;
   222       break;
   235 
   223 
   236     default: ShouldNotReachHere();
   224     default: ShouldNotReachHere();
   237   }
   225   }
   238   JavaCalls::call_static(&result,
   226   JavaCalls::call_static(&result,
   250   objArrayOop array_oop = oopFactory::new_objArray(SystemDictionary::Object_klass(),
   238   objArrayOop array_oop = oopFactory::new_objArray(SystemDictionary::Object_klass(),
   251                                                    length, CHECK_(empty));
   239                                                    length, CHECK_(empty));
   252   objArrayHandle array_h(THREAD, array_oop);
   240   objArrayHandle array_h(THREAD, array_oop);
   253   for (int i = 0; i < values->size(); i++) {
   241   for (int i = 0; i < values->size(); i++) {
   254     StackValue* st = values->at(i);
   242     StackValue* st = values->at(i);
   255     oop obj = create_primitive_value_instance(values, i, CHECK_(empty));
   243     BasicType type = st->type();
   256     if (obj != NULL)
   244     int index = i;
       
   245 #ifdef _LP64
       
   246     if (type != T_OBJECT && type != T_CONFLICT) {
       
   247         intptr_t ret = st->get_int(); // read full 64-bit slot
       
   248         type = T_LONG;                // treat as long
       
   249         index--;                      // undo +1 in StackValueCollection::long_at
       
   250     }
       
   251 #endif
       
   252     oop obj = create_primitive_slot_instance(values, index, type, CHECK_(empty));
       
   253     if (obj != NULL) {
   257       array_h->obj_at_put(i, obj);
   254       array_h->obj_at_put(i, obj);
       
   255     }
   258   }
   256   }
   259   return array_h;
   257   return array_h;
   260 }
   258 }
   261 
   259 
   262 objArrayHandle LiveFrameStream::monitors_to_object_array(GrowableArray<MonitorInfo*>* monitors, TRAPS) {
   260 objArrayHandle LiveFrameStream::monitors_to_object_array(GrowableArray<MonitorInfo*>* monitors, TRAPS) {
   284   if (_jvf != NULL) {
   282   if (_jvf != NULL) {
   285     StackValueCollection* locals = _jvf->locals();
   283     StackValueCollection* locals = _jvf->locals();
   286     StackValueCollection* expressions = _jvf->expressions();
   284     StackValueCollection* expressions = _jvf->expressions();
   287     GrowableArray<MonitorInfo*>* monitors = _jvf->monitors();
   285     GrowableArray<MonitorInfo*>* monitors = _jvf->monitors();
   288 
   286 
       
   287     int mode = 0;
       
   288     if (_jvf->is_interpreted_frame()) {
       
   289       mode = MODE_INTERPRETED;
       
   290     } else if (_jvf->is_compiled_frame()) {
       
   291       mode = MODE_COMPILED;
       
   292     }
       
   293 
   289     if (!locals->is_empty()) {
   294     if (!locals->is_empty()) {
   290       objArrayHandle locals_h = values_to_object_array(locals, CHECK);
   295       objArrayHandle locals_h = values_to_object_array(locals, CHECK);
   291       java_lang_LiveStackFrameInfo::set_locals(stackFrame(), locals_h());
   296       java_lang_LiveStackFrameInfo::set_locals(stackFrame(), locals_h());
   292     }
   297     }
   293     if (!expressions->is_empty()) {
   298     if (!expressions->is_empty()) {
   296     }
   301     }
   297     if (monitors->length() > 0) {
   302     if (monitors->length() > 0) {
   298       objArrayHandle monitors_h = monitors_to_object_array(monitors, CHECK);
   303       objArrayHandle monitors_h = monitors_to_object_array(monitors, CHECK);
   299       java_lang_LiveStackFrameInfo::set_monitors(stackFrame(), monitors_h());
   304       java_lang_LiveStackFrameInfo::set_monitors(stackFrame(), monitors_h());
   300     }
   305     }
       
   306     java_lang_LiveStackFrameInfo::set_mode(stackFrame(), mode);
   301   }
   307   }
   302 }
   308 }
   303 
   309 
   304 // Begins stack walking.
   310 // Begins stack walking.
   305 //
   311 //