Mercurial > hg > truffle
comparison src/share/vm/prims/jvm.cpp @ 18041:52b4284cb496
Merge with jdk8u20-b26
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Wed, 15 Oct 2014 16:02:50 +0200 |
parents | 3482684330ee a103c376459a |
children | eaf39a954227 |
comparison
equal
deleted
inserted
replaced
17606:45d7b2c7029d | 18041:52b4284cb496 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
74 # include "jvm_solaris.h" | 74 # include "jvm_solaris.h" |
75 #endif | 75 #endif |
76 #ifdef TARGET_OS_FAMILY_windows | 76 #ifdef TARGET_OS_FAMILY_windows |
77 # include "jvm_windows.h" | 77 # include "jvm_windows.h" |
78 #endif | 78 #endif |
79 #ifdef TARGET_OS_FAMILY_aix | |
80 # include "jvm_aix.h" | |
81 #endif | |
79 #ifdef TARGET_OS_FAMILY_bsd | 82 #ifdef TARGET_OS_FAMILY_bsd |
80 # include "jvm_bsd.h" | 83 # include "jvm_bsd.h" |
81 #endif | 84 #endif |
82 | 85 |
83 #include <errno.h> | 86 #include <errno.h> |
215 // Wrapper to trace JVM functions | 218 // Wrapper to trace JVM functions |
216 | 219 |
217 #ifdef ASSERT | 220 #ifdef ASSERT |
218 class JVMTraceWrapper : public StackObj { | 221 class JVMTraceWrapper : public StackObj { |
219 public: | 222 public: |
220 JVMTraceWrapper(const char* format, ...) { | 223 JVMTraceWrapper(const char* format, ...) ATTRIBUTE_PRINTF(2, 3) { |
221 if (TraceJVMCalls) { | 224 if (TraceJVMCalls) { |
222 va_list ap; | 225 va_list ap; |
223 va_start(ap, format); | 226 va_start(ap, format); |
224 tty->print("JVM "); | 227 tty->print("JVM "); |
225 tty->vprint_cr(format, ap); | 228 tty->vprint_cr(format, ap); |
535 JVMWrapper("JVM_MonitorWait"); | 538 JVMWrapper("JVM_MonitorWait"); |
536 Handle obj(THREAD, JNIHandles::resolve_non_null(handle)); | 539 Handle obj(THREAD, JNIHandles::resolve_non_null(handle)); |
537 JavaThreadInObjectWaitState jtiows(thread, ms != 0); | 540 JavaThreadInObjectWaitState jtiows(thread, ms != 0); |
538 if (JvmtiExport::should_post_monitor_wait()) { | 541 if (JvmtiExport::should_post_monitor_wait()) { |
539 JvmtiExport::post_monitor_wait((JavaThread *)THREAD, (oop)obj(), ms); | 542 JvmtiExport::post_monitor_wait((JavaThread *)THREAD, (oop)obj(), ms); |
543 | |
544 // The current thread already owns the monitor and it has not yet | |
545 // been added to the wait queue so the current thread cannot be | |
546 // made the successor. This means that the JVMTI_EVENT_MONITOR_WAIT | |
547 // event handler cannot accidentally consume an unpark() meant for | |
548 // the ParkEvent associated with this ObjectMonitor. | |
540 } | 549 } |
541 ObjectSynchronizer::wait(obj, ms, CHECK); | 550 ObjectSynchronizer::wait(obj, ms, CHECK); |
542 JVM_END | 551 JVM_END |
543 | 552 |
544 | 553 |
1224 Handle object (THREAD, JNIHandles::resolve(action)); | 1233 Handle object (THREAD, JNIHandles::resolve(action)); |
1225 | 1234 |
1226 // get run() method | 1235 // get run() method |
1227 Method* m_oop = object->klass()->uncached_lookup_method( | 1236 Method* m_oop = object->klass()->uncached_lookup_method( |
1228 vmSymbols::run_method_name(), | 1237 vmSymbols::run_method_name(), |
1229 vmSymbols::void_object_signature()); | 1238 vmSymbols::void_object_signature(), |
1239 Klass::normal); | |
1230 methodHandle m (THREAD, m_oop); | 1240 methodHandle m (THREAD, m_oop); |
1231 if (m.is_null() || !m->is_method() || !m()->is_public() || m()->is_static()) { | 1241 if (m.is_null() || !m->is_method() || !m()->is_public() || m()->is_static()) { |
1232 THROW_MSG_0(vmSymbols::java_lang_InternalError(), "No run method"); | 1242 THROW_MSG_0(vmSymbols::java_lang_InternalError(), "No run method"); |
1233 } | 1243 } |
1234 | 1244 |
2722 return os::available(fd, pbytes); | 2732 return os::available(fd, pbytes); |
2723 JVM_END | 2733 JVM_END |
2724 | 2734 |
2725 | 2735 |
2726 JVM_LEAF(jlong, JVM_Lseek(jint fd, jlong offset, jint whence)) | 2736 JVM_LEAF(jlong, JVM_Lseek(jint fd, jlong offset, jint whence)) |
2727 JVMWrapper4("JVM_Lseek (0x%x, %Ld, %d)", fd, offset, whence); | 2737 JVMWrapper4("JVM_Lseek (0x%x, " INT64_FORMAT ", %d)", fd, (int64_t) offset, whence); |
2728 //%note jvm_r6 | 2738 //%note jvm_r6 |
2729 return os::lseek(fd, offset, whence); | 2739 return os::lseek(fd, offset, whence); |
2730 JVM_END | 2740 JVM_END |
2731 | 2741 |
2732 | 2742 |
2733 JVM_LEAF(jint, JVM_SetLength(jint fd, jlong length)) | 2743 JVM_LEAF(jint, JVM_SetLength(jint fd, jlong length)) |
2734 JVMWrapper3("JVM_SetLength (0x%x, %Ld)", fd, length); | 2744 JVMWrapper3("JVM_SetLength (0x%x, " INT64_FORMAT ")", fd, (int64_t) length); |
2735 return os::ftruncate(fd, length); | 2745 return os::ftruncate(fd, length); |
2736 JVM_END | 2746 JVM_END |
2737 | 2747 |
2738 | 2748 |
2739 JVM_LEAF(jint, JVM_Sync(jint fd)) | 2749 JVM_LEAF(jint, JVM_Sync(jint fd)) |
2744 | 2754 |
2745 | 2755 |
2746 // Printing support ////////////////////////////////////////////////// | 2756 // Printing support ////////////////////////////////////////////////// |
2747 extern "C" { | 2757 extern "C" { |
2748 | 2758 |
2759 ATTRIBUTE_PRINTF(3, 0) | |
2749 int jio_vsnprintf(char *str, size_t count, const char *fmt, va_list args) { | 2760 int jio_vsnprintf(char *str, size_t count, const char *fmt, va_list args) { |
2750 // see bug 4399518, 4417214 | 2761 // see bug 4399518, 4417214 |
2751 if ((intptr_t)count <= 0) return -1; | 2762 if ((intptr_t)count <= 0) return -1; |
2752 return vsnprintf(str, count, fmt, args); | 2763 return vsnprintf(str, count, fmt, args); |
2753 } | 2764 } |
2754 | 2765 |
2755 | 2766 ATTRIBUTE_PRINTF(3, 0) |
2756 int jio_snprintf(char *str, size_t count, const char *fmt, ...) { | 2767 int jio_snprintf(char *str, size_t count, const char *fmt, ...) { |
2757 va_list args; | 2768 va_list args; |
2758 int len; | 2769 int len; |
2759 va_start(args, fmt); | 2770 va_start(args, fmt); |
2760 len = jio_vsnprintf(str, count, fmt, args); | 2771 len = jio_vsnprintf(str, count, fmt, args); |
2761 va_end(args); | 2772 va_end(args); |
2762 return len; | 2773 return len; |
2763 } | 2774 } |
2764 | 2775 |
2765 | 2776 ATTRIBUTE_PRINTF(2,3) |
2766 int jio_fprintf(FILE* f, const char *fmt, ...) { | 2777 int jio_fprintf(FILE* f, const char *fmt, ...) { |
2767 int len; | 2778 int len; |
2768 va_list args; | 2779 va_list args; |
2769 va_start(args, fmt); | 2780 va_start(args, fmt); |
2770 len = jio_vfprintf(f, fmt, args); | 2781 len = jio_vfprintf(f, fmt, args); |
2771 va_end(args); | 2782 va_end(args); |
2772 return len; | 2783 return len; |
2773 } | 2784 } |
2774 | 2785 |
2775 | 2786 ATTRIBUTE_PRINTF(2, 0) |
2776 int jio_vfprintf(FILE* f, const char *fmt, va_list args) { | 2787 int jio_vfprintf(FILE* f, const char *fmt, va_list args) { |
2777 if (Arguments::vfprintf_hook() != NULL) { | 2788 if (Arguments::vfprintf_hook() != NULL) { |
2778 return Arguments::vfprintf_hook()(f, fmt, args); | 2789 return Arguments::vfprintf_hook()(f, fmt, args); |
2779 } else { | 2790 } else { |
2780 return vfprintf(f, fmt, args); | 2791 return vfprintf(f, fmt, args); |
2781 } | 2792 } |
2782 } | 2793 } |
2783 | 2794 |
2784 | 2795 ATTRIBUTE_PRINTF(1, 2) |
2785 JNIEXPORT int jio_printf(const char *fmt, ...) { | 2796 JNIEXPORT int jio_printf(const char *fmt, ...) { |
2786 int len; | 2797 int len; |
2787 va_list args; | 2798 va_list args; |
2788 va_start(args, fmt); | 2799 va_start(args, fmt); |
2789 len = jio_vfprintf(defaultStream::output_stream(), fmt, args); | 2800 len = jio_vfprintf(defaultStream::output_stream(), fmt, args); |
2916 } | 2927 } |
2917 oop java_thread = JNIHandles::resolve_non_null(jthread); | 2928 oop java_thread = JNIHandles::resolve_non_null(jthread); |
2918 JavaThread* receiver = java_lang_Thread::thread(java_thread); | 2929 JavaThread* receiver = java_lang_Thread::thread(java_thread); |
2919 Events::log_exception(JavaThread::current(), | 2930 Events::log_exception(JavaThread::current(), |
2920 "JVM_StopThread thread JavaThread " INTPTR_FORMAT " as oop " INTPTR_FORMAT " [exception " INTPTR_FORMAT "]", | 2931 "JVM_StopThread thread JavaThread " INTPTR_FORMAT " as oop " INTPTR_FORMAT " [exception " INTPTR_FORMAT "]", |
2921 receiver, (address)java_thread, throwable); | 2932 p2i(receiver), p2i((address)java_thread), p2i(throwable)); |
2922 // First check if thread is alive | 2933 // First check if thread is alive |
2923 if (receiver != NULL) { | 2934 if (receiver != NULL) { |
2924 // Check if exception is getting thrown at self (use oop equality, since the | 2935 // Check if exception is getting thrown at self (use oop equality, since the |
2925 // target object might exit) | 2936 // target object might exit) |
2926 if (java_thread == thread->threadObj()) { | 2937 if (java_thread == thread->threadObj()) { |