< prev index next >

src/share/vm/jvmci/jvmciRuntime.cpp

Print this page




 922         first = p;
 923       }
 924       count++;
 925     }
 926   }
 927   if (count != 0) {
 928     _options_count = count;
 929     _options = NEW_C_HEAP_ARRAY(SystemProperty*, count, mtCompiler);
 930     _options[0] = first;
 931     SystemProperty** insert_pos = _options + 1;
 932     for (SystemProperty* p = first->next(); p != NULL; p = p->next()) {
 933       if (strncmp(p->key(), OPTION_PREFIX, OPTION_PREFIX_LEN) == 0) {
 934         *insert_pos = p;
 935         insert_pos++;
 936       }
 937     }
 938     assert (insert_pos - _options == count, "must be");
 939   }
 940 }
 941 
 942 void JVMCIRuntime::shutdown() {
 943   if (_HotSpotJVMCIRuntime_instance != NULL) {
 944     _shutdown_called = true;
 945     JavaThread* THREAD = JavaThread::current();
 946     HandleMark hm(THREAD);
 947     Handle receiver = get_HotSpotJVMCIRuntime(CHECK_ABORT);
 948     JavaValue result(T_VOID);
 949     JavaCallArguments args;
 950     args.push_oop(receiver);
 951     JavaCalls::call_special(&result, receiver->klass(), vmSymbols::shutdown_method_name(), vmSymbols::void_method_signature(), &args, CHECK_ABORT);
 952   }
 953 }
 954 
 955 bool JVMCIRuntime::treat_as_trivial(Method* method) {
 956   if (_HotSpotJVMCIRuntime_initialized) {
 957     oop loader = method->method_holder()->class_loader();
 958     if (loader == NULL) {
 959       for (int i = 0; i < _trivial_prefixes_count; i++) {
 960         if (method->method_holder()->name()->starts_with(_trivial_prefixes[i])) {
 961           return true;
 962         }
 963       }
 964     }
 965   }
 966   return false;
 967 }
 968 
 969 void JVMCIRuntime::call_printStackTrace(Handle exception, Thread* thread) {
 970   assert(exception->is_a(SystemDictionary::Throwable_klass()), "Throwable instance expected");
 971   JavaValue result(T_VOID);
 972   JavaCalls::call_virtual(&result,
 973                           exception,
 974                           KlassHandle(thread,
 975                           SystemDictionary::Throwable_klass()),
 976                           vmSymbols::printStackTrace_name(),
 977                           vmSymbols::void_method_signature(),
 978                           thread);
 979 }
 980 
 981 void JVMCIRuntime::abort_on_pending_exception(Handle exception, const char* message, bool dump_core) {
 982   Thread* THREAD = Thread::current();
 983   CLEAR_PENDING_EXCEPTION;
 984   tty->print_raw_cr(message);
 985   call_printStackTrace(exception, THREAD);
 986 
 987   // Give other aborting threads to also print their stack traces.
 988   // This can be very useful when debugging class initialization
 989   // failures.
 990   os::sleep(THREAD, 200, false);
 991 
 992   vm_abort(dump_core);
 993 }
 994 
 995 void JVMCIRuntime::parse_lines(char* path, ParseClosure* closure, bool warnStatFailure) {
 996   struct stat st;
 997   if (::stat(path, &st) == 0 && (st.st_mode & S_IFREG) == S_IFREG) { // exists & is regular file
 998     int file_handle = ::open(path, os::default_file_open_flags(), 0);
 999     if (file_handle != -1) {
1000       char* buffer = NEW_C_HEAP_ARRAY(char, st.st_size + 1, mtInternal);
1001       int num_read;
1002       num_read = (int) ::read(file_handle, (char*) buffer, st.st_size);
1003       if (num_read == -1) {
1004         warning("Error reading file %s due to %s", path, strerror(errno));
1005       } else if (num_read != st.st_size) {
1006         warning("Only read %d of " SIZE_FORMAT " bytes from %s", num_read, (size_t) st.st_size, path);
1007       }
1008       ::close(file_handle);
1009       closure->set_filename(path);
1010       if (num_read == st.st_size) {
1011         buffer[num_read] = '\0';
1012 
1013         char* line = buffer;
1014         while (line - buffer < num_read && !closure->is_aborted()) {




 922         first = p;
 923       }
 924       count++;
 925     }
 926   }
 927   if (count != 0) {
 928     _options_count = count;
 929     _options = NEW_C_HEAP_ARRAY(SystemProperty*, count, mtCompiler);
 930     _options[0] = first;
 931     SystemProperty** insert_pos = _options + 1;
 932     for (SystemProperty* p = first->next(); p != NULL; p = p->next()) {
 933       if (strncmp(p->key(), OPTION_PREFIX, OPTION_PREFIX_LEN) == 0) {
 934         *insert_pos = p;
 935         insert_pos++;
 936       }
 937     }
 938     assert (insert_pos - _options == count, "must be");
 939   }
 940 }
 941 
 942 void JVMCIRuntime::shutdown(TRAPS) {
 943   if (_HotSpotJVMCIRuntime_instance != NULL) {
 944     _shutdown_called = true;

 945     HandleMark hm(THREAD);
 946     Handle receiver = get_HotSpotJVMCIRuntime(CHECK);
 947     JavaValue result(T_VOID);
 948     JavaCallArguments args;
 949     args.push_oop(receiver);
 950     JavaCalls::call_special(&result, receiver->klass(), vmSymbols::shutdown_method_name(), vmSymbols::void_method_signature(), &args, CHECK);
 951   }
 952 }
 953 
 954 bool JVMCIRuntime::treat_as_trivial(Method* method) {
 955   if (_HotSpotJVMCIRuntime_initialized) {
 956     oop loader = method->method_holder()->class_loader();
 957     if (loader == NULL) {
 958       for (int i = 0; i < _trivial_prefixes_count; i++) {
 959         if (method->method_holder()->name()->starts_with(_trivial_prefixes[i])) {
 960           return true;
 961         }
 962       }
 963     }
 964   }
 965   return false;
 966 }
 967 


























 968 void JVMCIRuntime::parse_lines(char* path, ParseClosure* closure, bool warnStatFailure) {
 969   struct stat st;
 970   if (::stat(path, &st) == 0 && (st.st_mode & S_IFREG) == S_IFREG) { // exists & is regular file
 971     int file_handle = ::open(path, os::default_file_open_flags(), 0);
 972     if (file_handle != -1) {
 973       char* buffer = NEW_C_HEAP_ARRAY(char, st.st_size + 1, mtInternal);
 974       int num_read;
 975       num_read = (int) ::read(file_handle, (char*) buffer, st.st_size);
 976       if (num_read == -1) {
 977         warning("Error reading file %s due to %s", path, strerror(errno));
 978       } else if (num_read != st.st_size) {
 979         warning("Only read %d of " SIZE_FORMAT " bytes from %s", num_read, (size_t) st.st_size, path);
 980       }
 981       ::close(file_handle);
 982       closure->set_filename(path);
 983       if (num_read == st.st_size) {
 984         buffer[num_read] = '\0';
 985 
 986         char* line = buffer;
 987         while (line - buffer < num_read && !closure->is_aborted()) {


< prev index next >