< prev index next >

src/share/vm/classfile/javaClasses.cpp

Print this page




  36 #include "oops/fieldStreams.hpp"
  37 #include "oops/instanceKlass.hpp"
  38 #include "oops/instanceMirrorKlass.hpp"
  39 #include "oops/klass.hpp"
  40 #include "oops/method.hpp"
  41 #include "oops/objArrayOop.inline.hpp"
  42 #include "oops/oop.inline.hpp"
  43 #include "oops/symbol.hpp"
  44 #include "oops/typeArrayOop.hpp"
  45 #include "prims/jvmtiRedefineClassesTrace.hpp"
  46 #include "runtime/fieldDescriptor.hpp"
  47 #include "runtime/handles.inline.hpp"
  48 #include "runtime/interfaceSupport.hpp"
  49 #include "runtime/java.hpp"
  50 #include "runtime/javaCalls.hpp"
  51 #include "runtime/safepoint.hpp"
  52 #include "runtime/thread.inline.hpp"
  53 #include "runtime/vframe.hpp"
  54 #include "utilities/preserveException.hpp"
  55 




  56 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
  57 
  58 #define INJECTED_FIELD_COMPUTE_OFFSET(klass, name, signature, may_be_java)    \
  59   klass::_##name##_offset = JavaClasses::compute_injected_offset(JavaClasses::klass##_##name##_enum);
  60 
  61 #define DECLARE_INJECTED_FIELD(klass, name, signature, may_be_java)           \
  62   { SystemDictionary::WK_KLASS_ENUM_NAME(klass), vmSymbols::VM_SYMBOL_ENUM_NAME(name##_name), vmSymbols::VM_SYMBOL_ENUM_NAME(signature), may_be_java },
  63 
  64 InjectedField JavaClasses::_injected_fields[] = {
  65   ALL_INJECTED_FIELDS(DECLARE_INJECTED_FIELD)
  66 };
  67 
  68 int JavaClasses::compute_injected_offset(InjectedFieldID id) {
  69   return _injected_fields[id].compute_offset();
  70 }
  71 
  72 
  73 InjectedField* JavaClasses::get_injected(Symbol* class_name, int* field_count) {
  74   *field_count = 0;
  75 


1562 void java_lang_Throwable::print_stack_element(outputStream *st, methodHandle method, int bci) {
1563   Handle mirror = method->method_holder()->java_mirror();
1564   int method_id = method->orig_method_idnum();
1565   int version = method->constants()->version();
1566   int cpref = method->name_index();
1567   print_stack_element(st, mirror, method_id, version, bci, cpref);
1568 }
1569 
1570 const char* java_lang_Throwable::no_stack_trace_message() {
1571   return "\t<<no stack trace available>>";
1572 }
1573 
1574 
1575 // Currently used only for exceptions occurring during startup
1576 void java_lang_Throwable::print_stack_trace(oop throwable, outputStream* st) {
1577   Thread *THREAD = Thread::current();
1578   Handle h_throwable(THREAD, throwable);
1579   while (h_throwable.not_null()) {
1580     objArrayHandle result (THREAD, objArrayOop(backtrace(h_throwable())));
1581     if (result.is_null()) {
1582       st->print_cr("%s", no_stack_trace_message());
1583       return;
1584     }
1585 
1586     while (result.not_null()) {
1587 
1588       // Get method id, bci, version and mirror from chunk
1589       typeArrayHandle methods (THREAD, BacktraceBuilder::get_methods(result));
1590       typeArrayHandle bcis (THREAD, BacktraceBuilder::get_bcis(result));
1591       objArrayHandle mirrors (THREAD, BacktraceBuilder::get_mirrors(result));
1592       typeArrayHandle cprefs (THREAD, BacktraceBuilder::get_cprefs(result));
1593 
1594       int length = methods()->length();
1595       for (int index = 0; index < length; index++) {
1596         Handle mirror(THREAD, mirrors->obj_at(index));
1597         // NULL mirror means end of stack trace
1598         if (mirror.is_null()) goto handle_cause;
1599         int method = methods->short_at(index);
1600         int version = version_at(bcis->int_at(index));
1601         int bci = bci_at(bcis->int_at(index));
1602         int cpref = cprefs->short_at(index);




  36 #include "oops/fieldStreams.hpp"
  37 #include "oops/instanceKlass.hpp"
  38 #include "oops/instanceMirrorKlass.hpp"
  39 #include "oops/klass.hpp"
  40 #include "oops/method.hpp"
  41 #include "oops/objArrayOop.inline.hpp"
  42 #include "oops/oop.inline.hpp"
  43 #include "oops/symbol.hpp"
  44 #include "oops/typeArrayOop.hpp"
  45 #include "prims/jvmtiRedefineClassesTrace.hpp"
  46 #include "runtime/fieldDescriptor.hpp"
  47 #include "runtime/handles.inline.hpp"
  48 #include "runtime/interfaceSupport.hpp"
  49 #include "runtime/java.hpp"
  50 #include "runtime/javaCalls.hpp"
  51 #include "runtime/safepoint.hpp"
  52 #include "runtime/thread.inline.hpp"
  53 #include "runtime/vframe.hpp"
  54 #include "utilities/preserveException.hpp"
  55 
  56 #if INCLUDE_JVMCI
  57 #include "jvmci/jvmciJavaClasses.hpp"
  58 #endif
  59 
  60 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
  61 
  62 #define INJECTED_FIELD_COMPUTE_OFFSET(klass, name, signature, may_be_java)    \
  63   klass::_##name##_offset = JavaClasses::compute_injected_offset(JavaClasses::klass##_##name##_enum);
  64 
  65 #define DECLARE_INJECTED_FIELD(klass, name, signature, may_be_java)           \
  66   { SystemDictionary::WK_KLASS_ENUM_NAME(klass), vmSymbols::VM_SYMBOL_ENUM_NAME(name##_name), vmSymbols::VM_SYMBOL_ENUM_NAME(signature), may_be_java },
  67 
  68 InjectedField JavaClasses::_injected_fields[] = {
  69   ALL_INJECTED_FIELDS(DECLARE_INJECTED_FIELD)
  70 };
  71 
  72 int JavaClasses::compute_injected_offset(InjectedFieldID id) {
  73   return _injected_fields[id].compute_offset();
  74 }
  75 
  76 
  77 InjectedField* JavaClasses::get_injected(Symbol* class_name, int* field_count) {
  78   *field_count = 0;
  79 


1566 void java_lang_Throwable::print_stack_element(outputStream *st, methodHandle method, int bci) {
1567   Handle mirror = method->method_holder()->java_mirror();
1568   int method_id = method->orig_method_idnum();
1569   int version = method->constants()->version();
1570   int cpref = method->name_index();
1571   print_stack_element(st, mirror, method_id, version, bci, cpref);
1572 }
1573 
1574 const char* java_lang_Throwable::no_stack_trace_message() {
1575   return "\t<<no stack trace available>>";
1576 }
1577 
1578 
1579 // Currently used only for exceptions occurring during startup
1580 void java_lang_Throwable::print_stack_trace(oop throwable, outputStream* st) {
1581   Thread *THREAD = Thread::current();
1582   Handle h_throwable(THREAD, throwable);
1583   while (h_throwable.not_null()) {
1584     objArrayHandle result (THREAD, objArrayOop(backtrace(h_throwable())));
1585     if (result.is_null()) {
1586       st->print_raw_cr(no_stack_trace_message());
1587       return;
1588     }
1589 
1590     while (result.not_null()) {
1591 
1592       // Get method id, bci, version and mirror from chunk
1593       typeArrayHandle methods (THREAD, BacktraceBuilder::get_methods(result));
1594       typeArrayHandle bcis (THREAD, BacktraceBuilder::get_bcis(result));
1595       objArrayHandle mirrors (THREAD, BacktraceBuilder::get_mirrors(result));
1596       typeArrayHandle cprefs (THREAD, BacktraceBuilder::get_cprefs(result));
1597 
1598       int length = methods()->length();
1599       for (int index = 0; index < length; index++) {
1600         Handle mirror(THREAD, mirrors->obj_at(index));
1601         // NULL mirror means end of stack trace
1602         if (mirror.is_null()) goto handle_cause;
1603         int method = methods->short_at(index);
1604         int version = version_at(bcis->int_at(index));
1605         int bci = bci_at(bcis->int_at(index));
1606         int cpref = cprefs->short_at(index);


< prev index next >