src/share/vm/classfile/javaClasses.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File 7089790_full Sdiff src/share/vm/classfile

src/share/vm/classfile/javaClasses.cpp

Print this page
rev 2694 : imported patch headers_only
rev 2695 : shared changes


  41 #include "oops/methodOop.hpp"
  42 #include "oops/symbol.hpp"
  43 #include "oops/typeArrayOop.hpp"
  44 #include "runtime/fieldDescriptor.hpp"
  45 #include "runtime/handles.inline.hpp"
  46 #include "runtime/interfaceSupport.hpp"
  47 #include "runtime/java.hpp"
  48 #include "runtime/javaCalls.hpp"
  49 #include "runtime/safepoint.hpp"
  50 #include "runtime/vframe.hpp"
  51 #include "utilities/preserveException.hpp"
  52 #ifdef TARGET_OS_FAMILY_linux
  53 # include "thread_linux.inline.hpp"
  54 #endif
  55 #ifdef TARGET_OS_FAMILY_solaris
  56 # include "thread_solaris.inline.hpp"
  57 #endif
  58 #ifdef TARGET_OS_FAMILY_windows
  59 # include "thread_windows.inline.hpp"
  60 #endif



  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 
  80   vmSymbols::SID sid = vmSymbols::find_sid(class_name);


1128   char* buf = NEW_RESOURCE_ARRAY(char, buf_len + 64);
1129 
1130   // Print stack trace line in buffer
1131   sprintf(buf, "\tat %s.%s", klass_name, method_name);
1132   if (method->is_native()) {
1133     strcat(buf, "(Native Method)");
1134   } else {
1135     int line_number = method->line_number_from_bci(bci);
1136     if (source_file_name != NULL && (line_number != -1)) {
1137       // Sourcename and linenumber
1138       sprintf(buf + (int)strlen(buf), "(%s:%d)", source_file_name, line_number);
1139     } else if (source_file_name != NULL) {
1140       // Just sourcename
1141       sprintf(buf + (int)strlen(buf), "(%s)", source_file_name);
1142     } else {
1143       // Neither soucename and linenumber
1144       sprintf(buf + (int)strlen(buf), "(Unknown Source)");
1145     }
1146     nmethod* nm = method->code();
1147     if (WizardMode && nm != NULL) {
1148       sprintf(buf + (int)strlen(buf), "(nmethod " PTR_FORMAT ")", (intptr_t)nm);
1149     }
1150   }
1151 
1152   return buf;
1153 }
1154 
1155 
1156 void java_lang_Throwable::print_stack_element(Handle stream, methodOop method, int bci) {
1157   ResourceMark rm;
1158   char* buf = print_stack_element_to_buffer(method, bci);
1159   print_to_stream(stream, buf);
1160 }
1161 
1162 void java_lang_Throwable::print_stack_element(outputStream *st, methodOop method, int bci) {
1163   ResourceMark rm;
1164   char* buf = print_stack_element_to_buffer(method, bci);
1165   st->print_cr("%s", buf);
1166 }
1167 
1168 void java_lang_Throwable::print_to_stream(Handle stream, const char* str) {


2677 }
2678 
2679 
2680 // Support for java_lang_invoke_CallSite
2681 
2682 int java_lang_invoke_CallSite::_target_offset;
2683 
2684 void java_lang_invoke_CallSite::compute_offsets() {
2685   if (!EnableInvokeDynamic)  return;
2686   klassOop k = SystemDictionary::CallSite_klass();
2687   if (k != NULL) {
2688     compute_offset(_target_offset, k, vmSymbols::target_name(), vmSymbols::java_lang_invoke_MethodHandle_signature());
2689   }
2690 
2691   // Disallow compilation of CallSite.setTargetNormal and CallSite.setTargetVolatile
2692   // (For C2:  keep this until we have throttling logic for uncommon traps.)
2693   if (k != NULL) {
2694     instanceKlass* ik = instanceKlass::cast(k);
2695     methodOop m_normal   = ik->lookup_method(vmSymbols::setTargetNormal_name(),   vmSymbols::setTarget_signature());
2696     methodOop m_volatile = ik->lookup_method(vmSymbols::setTargetVolatile_name(), vmSymbols::setTarget_signature());
2697     guarantee(m_normal && m_volatile, "must exist");
2698     m_normal->set_not_compilable_quietly();
2699     m_volatile->set_not_compilable_quietly();
2700   }
2701 }
2702 
2703 
2704 // Support for java_security_AccessControlContext
2705 
2706 int java_security_AccessControlContext::_context_offset = 0;
2707 int java_security_AccessControlContext::_privilegedContext_offset = 0;
2708 int java_security_AccessControlContext::_isPrivileged_offset = 0;
2709 
2710 void java_security_AccessControlContext::compute_offsets() {
2711   assert(_isPrivileged_offset == 0, "offsets should be initialized only once");
2712   fieldDescriptor fd;
2713   instanceKlass* ik = instanceKlass::cast(SystemDictionary::AccessControlContext_klass());
2714 
2715   if (!ik->find_local_field(vmSymbols::context_name(), vmSymbols::protectiondomain_signature(), &fd)) {
2716     fatal("Invalid layout of java.security.AccessControlContext");
2717   }




  41 #include "oops/methodOop.hpp"
  42 #include "oops/symbol.hpp"
  43 #include "oops/typeArrayOop.hpp"
  44 #include "runtime/fieldDescriptor.hpp"
  45 #include "runtime/handles.inline.hpp"
  46 #include "runtime/interfaceSupport.hpp"
  47 #include "runtime/java.hpp"
  48 #include "runtime/javaCalls.hpp"
  49 #include "runtime/safepoint.hpp"
  50 #include "runtime/vframe.hpp"
  51 #include "utilities/preserveException.hpp"
  52 #ifdef TARGET_OS_FAMILY_linux
  53 # include "thread_linux.inline.hpp"
  54 #endif
  55 #ifdef TARGET_OS_FAMILY_solaris
  56 # include "thread_solaris.inline.hpp"
  57 #endif
  58 #ifdef TARGET_OS_FAMILY_windows
  59 # include "thread_windows.inline.hpp"
  60 #endif
  61 #ifdef TARGET_OS_FAMILY_bsd
  62 # include "thread_bsd.inline.hpp"
  63 #endif
  64 
  65 #define INJECTED_FIELD_COMPUTE_OFFSET(klass, name, signature, may_be_java)    \
  66   klass::_##name##_offset = JavaClasses::compute_injected_offset(JavaClasses::klass##_##name##_enum);
  67 
  68 #define DECLARE_INJECTED_FIELD(klass, name, signature, may_be_java)           \
  69   { SystemDictionary::WK_KLASS_ENUM_NAME(klass), vmSymbols::VM_SYMBOL_ENUM_NAME(name##_name), vmSymbols::VM_SYMBOL_ENUM_NAME(signature), may_be_java },
  70 
  71 InjectedField JavaClasses::_injected_fields[] = {
  72   ALL_INJECTED_FIELDS(DECLARE_INJECTED_FIELD)
  73 };
  74 
  75 int JavaClasses::compute_injected_offset(InjectedFieldID id) {
  76   return _injected_fields[id].compute_offset();
  77 }
  78 
  79 
  80 InjectedField* JavaClasses::get_injected(Symbol* class_name, int* field_count) {
  81   *field_count = 0;
  82 
  83   vmSymbols::SID sid = vmSymbols::find_sid(class_name);


1131   char* buf = NEW_RESOURCE_ARRAY(char, buf_len + 64);
1132 
1133   // Print stack trace line in buffer
1134   sprintf(buf, "\tat %s.%s", klass_name, method_name);
1135   if (method->is_native()) {
1136     strcat(buf, "(Native Method)");
1137   } else {
1138     int line_number = method->line_number_from_bci(bci);
1139     if (source_file_name != NULL && (line_number != -1)) {
1140       // Sourcename and linenumber
1141       sprintf(buf + (int)strlen(buf), "(%s:%d)", source_file_name, line_number);
1142     } else if (source_file_name != NULL) {
1143       // Just sourcename
1144       sprintf(buf + (int)strlen(buf), "(%s)", source_file_name);
1145     } else {
1146       // Neither soucename and linenumber
1147       sprintf(buf + (int)strlen(buf), "(Unknown Source)");
1148     }
1149     nmethod* nm = method->code();
1150     if (WizardMode && nm != NULL) {
1151       sprintf(buf + (int)strlen(buf), "(nmethod " INTPTR_FORMAT ")", (intptr_t)nm);
1152     }
1153   }
1154 
1155   return buf;
1156 }
1157 
1158 
1159 void java_lang_Throwable::print_stack_element(Handle stream, methodOop method, int bci) {
1160   ResourceMark rm;
1161   char* buf = print_stack_element_to_buffer(method, bci);
1162   print_to_stream(stream, buf);
1163 }
1164 
1165 void java_lang_Throwable::print_stack_element(outputStream *st, methodOop method, int bci) {
1166   ResourceMark rm;
1167   char* buf = print_stack_element_to_buffer(method, bci);
1168   st->print_cr("%s", buf);
1169 }
1170 
1171 void java_lang_Throwable::print_to_stream(Handle stream, const char* str) {


2680 }
2681 
2682 
2683 // Support for java_lang_invoke_CallSite
2684 
2685 int java_lang_invoke_CallSite::_target_offset;
2686 
2687 void java_lang_invoke_CallSite::compute_offsets() {
2688   if (!EnableInvokeDynamic)  return;
2689   klassOop k = SystemDictionary::CallSite_klass();
2690   if (k != NULL) {
2691     compute_offset(_target_offset, k, vmSymbols::target_name(), vmSymbols::java_lang_invoke_MethodHandle_signature());
2692   }
2693 
2694   // Disallow compilation of CallSite.setTargetNormal and CallSite.setTargetVolatile
2695   // (For C2:  keep this until we have throttling logic for uncommon traps.)
2696   if (k != NULL) {
2697     instanceKlass* ik = instanceKlass::cast(k);
2698     methodOop m_normal   = ik->lookup_method(vmSymbols::setTargetNormal_name(),   vmSymbols::setTarget_signature());
2699     methodOop m_volatile = ik->lookup_method(vmSymbols::setTargetVolatile_name(), vmSymbols::setTarget_signature());
2700     guarantee(m_normal != NULL && m_volatile != NULL, "must exist");
2701     m_normal->set_not_compilable_quietly();
2702     m_volatile->set_not_compilable_quietly();
2703   }
2704 }
2705 
2706 
2707 // Support for java_security_AccessControlContext
2708 
2709 int java_security_AccessControlContext::_context_offset = 0;
2710 int java_security_AccessControlContext::_privilegedContext_offset = 0;
2711 int java_security_AccessControlContext::_isPrivileged_offset = 0;
2712 
2713 void java_security_AccessControlContext::compute_offsets() {
2714   assert(_isPrivileged_offset == 0, "offsets should be initialized only once");
2715   fieldDescriptor fd;
2716   instanceKlass* ik = instanceKlass::cast(SystemDictionary::AccessControlContext_klass());
2717 
2718   if (!ik->find_local_field(vmSymbols::context_name(), vmSymbols::protectiondomain_signature(), &fd)) {
2719     fatal("Invalid layout of java.security.AccessControlContext");
2720   }


src/share/vm/classfile/javaClasses.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File