221 } |
221 } |
222 |
222 |
223 // Wrapper to trace JVM functions |
223 // Wrapper to trace JVM functions |
224 |
224 |
225 #ifdef ASSERT |
225 #ifdef ASSERT |
226 class JVMTraceWrapper : public StackObj { |
|
227 public: |
|
228 JVMTraceWrapper(const char* format, ...) ATTRIBUTE_PRINTF(2, 3) { |
|
229 if (TraceJVMCalls) { |
|
230 va_list ap; |
|
231 va_start(ap, format); |
|
232 tty->print("JVM "); |
|
233 tty->vprint_cr(format, ap); |
|
234 va_end(ap); |
|
235 } |
|
236 } |
|
237 }; |
|
238 |
|
239 Histogram* JVMHistogram; |
226 Histogram* JVMHistogram; |
240 volatile jint JVMHistogram_lock = 0; |
227 volatile jint JVMHistogram_lock = 0; |
241 |
228 |
242 class JVMHistogramElement : public HistogramElement { |
229 class JVMHistogramElement : public HistogramElement { |
243 public: |
230 public: |
267 |
254 |
268 #define JVMCountWrapper(arg) \ |
255 #define JVMCountWrapper(arg) \ |
269 static JVMHistogramElement* e = new JVMHistogramElement(arg); \ |
256 static JVMHistogramElement* e = new JVMHistogramElement(arg); \ |
270 if (e != NULL) e->increment_count(); // Due to bug in VC++, we need a NULL check here eventhough it should never happen! |
257 if (e != NULL) e->increment_count(); // Due to bug in VC++, we need a NULL check here eventhough it should never happen! |
271 |
258 |
272 #define JVMWrapper(arg1) JVMCountWrapper(arg1); JVMTraceWrapper(arg1) |
259 #define JVMWrapper(arg) JVMCountWrapper(arg); |
273 #define JVMWrapper2(arg1, arg2) JVMCountWrapper(arg1); JVMTraceWrapper(arg1, arg2) |
|
274 #define JVMWrapper3(arg1, arg2, arg3) JVMCountWrapper(arg1); JVMTraceWrapper(arg1, arg2, arg3) |
|
275 #define JVMWrapper4(arg1, arg2, arg3, arg4) JVMCountWrapper(arg1); JVMTraceWrapper(arg1, arg2, arg3, arg4) |
|
276 #else |
260 #else |
277 #define JVMWrapper(arg1) |
261 #define JVMWrapper(arg) |
278 #define JVMWrapper2(arg1, arg2) |
|
279 #define JVMWrapper3(arg1, arg2, arg3) |
|
280 #define JVMWrapper4(arg1, arg2, arg3, arg4) |
|
281 #endif |
262 #endif |
282 |
263 |
283 |
264 |
284 // Interface version ///////////////////////////////////////////////////////////////////// |
265 // Interface version ///////////////////////////////////////////////////////////////////// |
285 |
266 |
670 JVM_END |
651 JVM_END |
671 |
652 |
672 // java.io.File /////////////////////////////////////////////////////////////// |
653 // java.io.File /////////////////////////////////////////////////////////////// |
673 |
654 |
674 JVM_LEAF(char*, JVM_NativePath(char* path)) |
655 JVM_LEAF(char*, JVM_NativePath(char* path)) |
675 JVMWrapper2("JVM_NativePath (%s)", path); |
656 JVMWrapper("JVM_NativePath"); |
676 return os::native_path(path); |
657 return os::native_path(path); |
677 JVM_END |
658 JVM_END |
678 |
659 |
679 |
660 |
680 // Misc. class handling /////////////////////////////////////////////////////////// |
661 // Misc. class handling /////////////////////////////////////////////////////////// |
747 // Returns a class loaded by the bootstrap class loader; or null |
728 // Returns a class loaded by the bootstrap class loader; or null |
748 // if not found. ClassNotFoundException is not thrown. |
729 // if not found. ClassNotFoundException is not thrown. |
749 // FindClassFromBootLoader is exported to the launcher for windows. |
730 // FindClassFromBootLoader is exported to the launcher for windows. |
750 JVM_ENTRY(jclass, JVM_FindClassFromBootLoader(JNIEnv* env, |
731 JVM_ENTRY(jclass, JVM_FindClassFromBootLoader(JNIEnv* env, |
751 const char* name)) |
732 const char* name)) |
752 JVMWrapper2("JVM_FindClassFromBootLoader %s", name); |
733 JVMWrapper("JVM_FindClassFromBootLoader"); |
753 |
734 |
754 // Java libraries should ensure that name is never null... |
735 // Java libraries should ensure that name is never null... |
755 if (name == NULL || (int)strlen(name) > Symbol::max_length()) { |
736 if (name == NULL || (int)strlen(name) > Symbol::max_length()) { |
756 // It's impossible to create this class; the name cannot fit |
737 // It's impossible to create this class; the name cannot fit |
757 // into the constant pool. |
738 // into the constant pool. |
772 |
753 |
773 // Find a class with this name in this loader, using the caller's protection domain. |
754 // Find a class with this name in this loader, using the caller's protection domain. |
774 JVM_ENTRY(jclass, JVM_FindClassFromCaller(JNIEnv* env, const char* name, |
755 JVM_ENTRY(jclass, JVM_FindClassFromCaller(JNIEnv* env, const char* name, |
775 jboolean init, jobject loader, |
756 jboolean init, jobject loader, |
776 jclass caller)) |
757 jclass caller)) |
777 JVMWrapper2("JVM_FindClassFromCaller %s throws ClassNotFoundException", name); |
758 JVMWrapper("JVM_FindClassFromCaller throws ClassNotFoundException"); |
778 // Java libraries should ensure that name is never null... |
759 // Java libraries should ensure that name is never null... |
779 if (name == NULL || (int)strlen(name) > Symbol::max_length()) { |
760 if (name == NULL || (int)strlen(name) > Symbol::max_length()) { |
780 // It's impossible to create this class; the name cannot fit |
761 // It's impossible to create this class; the name cannot fit |
781 // into the constant pool. |
762 // into the constant pool. |
782 THROW_MSG_0(vmSymbols::java_lang_ClassNotFoundException(), name); |
763 THROW_MSG_0(vmSymbols::java_lang_ClassNotFoundException(), name); |
807 return result; |
788 return result; |
808 JVM_END |
789 JVM_END |
809 |
790 |
810 JVM_ENTRY(jclass, JVM_FindClassFromClass(JNIEnv *env, const char *name, |
791 JVM_ENTRY(jclass, JVM_FindClassFromClass(JNIEnv *env, const char *name, |
811 jboolean init, jclass from)) |
792 jboolean init, jclass from)) |
812 JVMWrapper2("JVM_FindClassFromClass %s", name); |
793 JVMWrapper("JVM_FindClassFromClass"); |
813 if (name == NULL || (int)strlen(name) > Symbol::max_length()) { |
794 if (name == NULL || (int)strlen(name) > Symbol::max_length()) { |
814 // It's impossible to create this class; the name cannot fit |
795 // It's impossible to create this class; the name cannot fit |
815 // into the constant pool. |
796 // into the constant pool. |
816 THROW_MSG_0(vmSymbols::java_lang_NoClassDefFoundError(), name); |
797 THROW_MSG_0(vmSymbols::java_lang_NoClassDefFoundError(), name); |
817 } |
798 } |
914 return (jclass) JNIHandles::make_local(env, k->java_mirror()); |
895 return (jclass) JNIHandles::make_local(env, k->java_mirror()); |
915 } |
896 } |
916 |
897 |
917 |
898 |
918 JVM_ENTRY(jclass, JVM_DefineClass(JNIEnv *env, const char *name, jobject loader, const jbyte *buf, jsize len, jobject pd)) |
899 JVM_ENTRY(jclass, JVM_DefineClass(JNIEnv *env, const char *name, jobject loader, const jbyte *buf, jsize len, jobject pd)) |
919 JVMWrapper2("JVM_DefineClass %s", name); |
900 JVMWrapper("JVM_DefineClass"); |
920 |
901 |
921 return jvm_define_class_common(env, name, loader, buf, len, pd, NULL, THREAD); |
902 return jvm_define_class_common(env, name, loader, buf, len, pd, NULL, THREAD); |
922 JVM_END |
903 JVM_END |
923 |
904 |
924 |
905 |
925 JVM_ENTRY(jclass, JVM_DefineClassWithSource(JNIEnv *env, const char *name, jobject loader, const jbyte *buf, jsize len, jobject pd, const char *source)) |
906 JVM_ENTRY(jclass, JVM_DefineClassWithSource(JNIEnv *env, const char *name, jobject loader, const jbyte *buf, jsize len, jobject pd, const char *source)) |
926 JVMWrapper2("JVM_DefineClassWithSource %s", name); |
907 JVMWrapper("JVM_DefineClassWithSource"); |
927 |
908 |
928 return jvm_define_class_common(env, name, loader, buf, len, pd, source, THREAD); |
909 return jvm_define_class_common(env, name, loader, buf, len, pd, source, THREAD); |
929 JVM_END |
910 JVM_END |
930 |
911 |
931 JVM_ENTRY(jclass, JVM_FindLoadedClass(JNIEnv *env, jobject loader, jstring name)) |
912 JVM_ENTRY(jclass, JVM_FindLoadedClass(JNIEnv *env, jobject loader, jstring name)) |
3348 |
3329 |
3349 // Library support /////////////////////////////////////////////////////////////////////////// |
3330 // Library support /////////////////////////////////////////////////////////////////////////// |
3350 |
3331 |
3351 JVM_ENTRY_NO_ENV(void*, JVM_LoadLibrary(const char* name)) |
3332 JVM_ENTRY_NO_ENV(void*, JVM_LoadLibrary(const char* name)) |
3352 //%note jvm_ct |
3333 //%note jvm_ct |
3353 JVMWrapper2("JVM_LoadLibrary (%s)", name); |
3334 JVMWrapper("JVM_LoadLibrary"); |
3354 char ebuf[1024]; |
3335 char ebuf[1024]; |
3355 void *load_result; |
3336 void *load_result; |
3356 { |
3337 { |
3357 ThreadToNativeFromVM ttnfvm(thread); |
3338 ThreadToNativeFromVM ttnfvm(thread); |
3358 load_result = os::dll_load(name, ebuf, sizeof ebuf); |
3339 load_result = os::dll_load(name, ebuf, sizeof ebuf); |
3380 os::dll_unload(handle); |
3361 os::dll_unload(handle); |
3381 JVM_END |
3362 JVM_END |
3382 |
3363 |
3383 |
3364 |
3384 JVM_LEAF(void*, JVM_FindLibraryEntry(void* handle, const char* name)) |
3365 JVM_LEAF(void*, JVM_FindLibraryEntry(void* handle, const char* name)) |
3385 JVMWrapper2("JVM_FindLibraryEntry (%s)", name); |
3366 JVMWrapper("JVM_FindLibraryEntry"); |
3386 return os::dll_lookup(handle, name); |
3367 return os::dll_lookup(handle, name); |
3387 JVM_END |
3368 JVM_END |
3388 |
3369 |
3389 |
3370 |
3390 // JNI version /////////////////////////////////////////////////////////////////////////////// |
3371 // JNI version /////////////////////////////////////////////////////////////////////////////// |
3391 |
3372 |
3392 JVM_LEAF(jboolean, JVM_IsSupportedJNIVersion(jint version)) |
3373 JVM_LEAF(jboolean, JVM_IsSupportedJNIVersion(jint version)) |
3393 JVMWrapper2("JVM_IsSupportedJNIVersion (%d)", version); |
3374 JVMWrapper("JVM_IsSupportedJNIVersion"); |
3394 return Threads::is_supported_jni_version_including_1_1(version); |
3375 return Threads::is_supported_jni_version_including_1_1(version); |
3395 JVM_END |
3376 JVM_END |
3396 |
3377 |
3397 |
3378 |
3398 // String support /////////////////////////////////////////////////////////////////////////// |
3379 // String support /////////////////////////////////////////////////////////////////////////// |